此种网页技术,应如何访问其中的元素? ( 积分: 100 )

  • 主题发起人 主题发起人 dazzling
  • 开始时间 开始时间
D

dazzling

Unregistered / Unconfirmed
GUEST, unregistred user!
例如在头部:
<script language=&quot;javascript&quot; src=&quot;../js/validator.js&quot; type=&quot;&quot;></script>
这个JS中包括了一些FORM等,它与本页进行交互.
现在用OLEDOCUMENT可以访问本页面中的所有元素,但JS中的就无能为力了,
谁有办法解决这个问题???
 
我试试看,等着

====
好了

library PHotkey;

{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }

uses
SysUtils,
Classes,
DllHotKey in 'DllHotKey.pas';

{$R *.res}
exports
SetHotKey,
UnHotKey;

begin



unit DllHotKey;

interface


uses
Windows, SysUtils, Classes, Menus;

procedure SetHotKey(ShortCut: PAnsiChar; const HotHwnd: HWND = 0); stdcaLL;
procedure UnHotKey(); stdcaLL;

implementation

const
Atom_Name = 'HHmianatom';
Class_Name = 'HHMainName';
var
HotKey: string;
ATom: TATOM;
HHMain: THandle;
Wnc: TWndClass;
hWnc: THandle;
OldMethod: Pointer = nil;

function showMessage(Msg: string; Flag: UINT = MB_OK): Integer;
begin
Result := Windows.messageBox(Windows.GetForegroundWindow, PChar(Msg), 'DllHotKey', Flag);
end;

function WindProc(H: HWND; Msg: UINT; wParam, lParam: Integer): LRESULT; stdcall;
begin
if (wParam <> 0) and (wParam = ATom) then
begin
ShowMessage(HotKey);
end;
if OldMethod <> nil then {不安全的方法}
Result := CallWindowProc(OldMethod, H, Msg, wParam, lParam)
else
Result := Windows.DefWindowProc(H, Msg, wParam, lParam);
end;

procedure SetHotKey(ShortCut: PAnsiChar; const HotHwnd: HWND = 0);
var
AShortCut: TShortCut;
Key: Word;
Shift: TShiftState;
Vk, fsModifiers: UINT;
begin
HotKey := ShortCut;

AShortCut := TextToShortCut(HotKey);

ShortCutToKey(AShortCut, Key, Shift);
VK := Key;
fsModifiers := 0;

if ssCTRL in Shift then fsModifiers := MOD_CONTROL;
if ssALT in Shift then fsModifiers := fsModifiers or MOD_CONTROL;
if ssSHIFT in Shift then fsModifiers := fsModifiers or MOD_SHIFT;
///if then fsModifiers := fsModifiers or MOD_WIN;

if HotHwnd = 0 then
begin
Wnc.style := windows.CS_VREDRAW;
wnc.hInstance := hInstance;
wnc.lpfnWndProc := @WindProc;
wnc.lpszClassName := Class_Name;
hWnc := Windows.RegisterClass(Wnc);
if hWnc <> 0 then
begin
HHMain := Windows.CreateWindowEx(WS_EX_OVERLAPPEDWINDOW,
Class_Name, Class_Name, windows.WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, 0, 0, hInstance, nil);
if HHMain = 0 then
showMessage('注册窗口失败.');
end else showMessage('注册窗口类失败.')
end
else begin
HHMain := HotHwnd;
OldMethod := Pointer(Windows.GetWindowLong(HHMain, windows.GWL_WNDPROC));
if OldMethod <> nil then
Windows.SetWindowLong(HHMain, GWL_WNDPROC, Integer(@WindProc));
end;

if HHMain <> 0 then
begin
ATom := Windows.AddAtom(Atom_Name);
if not Windows.RegisterHotKey(HHMain, ATom, fsModifiers, vk) then
showMessage('注册热键失败.')
end;
end;

procedure UnHotKey;
begin
if (HHMain <> 0) and (ATom <> 0) then
begin
Windows.UnregisterHotKey(HHMain, ATom);
Windows.DestroyWindow(HHMain);
HHMain := 0;
ATom := 0;
end;
if hWnc <> 0 then
Windows.UnregisterClass(Class_Name, hInstance);
end;


end.


调用的地方
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Menus;

type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
MainMenu1: TMainMenu;
PopupMenu1: TPopupMenu;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

procedure SetHotKey(ShortCut: PAnsiChar; const HotHwnd: HWND = 0); stdcaLL; external 'PHotkey.dll';
procedure UnHotKey(); stdcall; external 'PHotkey.dll';

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin

SetHotKey('CTRL+SHIFT+F4', Handle);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
UnHotKey
end;

end.
 
我是这么做的:
1、用当前窗口的Hwnd
2、将主程序的handle传给Dll
 
var
HotKeyID: Cardinal;
Msg:TMsg;
begin
HotKeyID:=0;
try
HotKeyID:= GlobalAddAtom(Pchar('AtomOfWawa')); //申请全局原子
RegisterHotKey(0,HotKeyID,MOD_ALT,ord('Y')); //注册热键
while TRUE do
begin
if PeekMessage(Msg, 0, 0, 0, PM_REMOVE) and (Msg.message = WM_HOTKEY)
then
begin
//
break;

end;
end;
//撤消热键
finally
UnRegisterHotKey(0, HotKeyID);
DeleteAtom(HotKeyID); //释放全局原子
end;
 
都没明白我的意思.
我是在DLL中定义热键并处理.与窗体无关.
而且截取热键不用消息循环,用广播消息到线程的方法吧?
100分哪那么好赚[:D]
 
LZ:
你不管是替换Dll中的窗口,还是在Dll中创建窗口,除非不用RegisterHotKey注册热键,目前还没有找到一种不用RegisterHotKey注册系统热键的方法。
=====用广播消息到线程的方法吧?
不明白你说是什么意思?
谁来广播消息,通过什么广播消息?

100分,好多分啊,没有见到分的啊!
呵呵,LZ的问题100多都没有结贴,真晕!
http://www.delphibbs.com/delphibbs/dispu.asp?username=dazzling
好像你的贴子大部分都不曾结贴,诚信太令人质疑
http://www.delphibbs.com/delphibbs/listq.asp?type=1&amp;userfrom=dazzling
 
分对我来说 不重要
 
to:jfyes,
发送消息到线程.可能我说的不对.

好吧兄弟,你能把我那些未结贴的问题顺利解决,所有分都给你,绝不食言!
 
哈哈,你的那些问题,大部分找得到答案,有的别人虽然没有给明确的答案也提供了方法,
不结贴,不厚道.
致于你这个问题,用HooK就可以的,因为你的快捷键是你自己的DLL处理,
只要HOOK监视你的相应快捷键被按下,HOOK处理便是了,不用RegisterHotKey
来注册热键。
 
是吗? 你有看过问题吗? 你是不是连&quot;顶&quot;一个字的也结贴? 我可没那么大方,我很穷,才剩18分.

用HOOK的话我还会来这里问吗? 别人不都是菜鸟
呵呵
 
我是来逛的,不是来拿分的,呵呵,我不需要分
需要的只是互相交流而已
 
多人接受答案了。
 
后退
顶部