Вот есть код как его переписать чтобы он выполнял какие либо действия когда пользователь нажмёт кнопку "ОК" в другой программе...
Код | program p1;
uses Windows, Messages,WinCls;
var H: hHook; hApp: THandle; wClass: TWndClass; wMSG: TMSG;
function DoIt(nCode: integer; WParam: word; LParam: Longint): Longint; stdcall; var msg: PEVENTMSG; hh: HWND; pp: TPoint; buffer: array[0..1023] of Char; s: string; begin if nCode>=0 then begin result:=0; msg:=Pointer(LParam); if msg.message=wm_LButtonDown then begin GetCursorPos(pp); hh:=ChildWindowFromPoint(WindowFromPoint(pp),pp); if hh=0 then hh:=WindowFromPoint(pp); if hh<>0 then begin GetClassName(hh,@buffer,1024); s:=Buffer; TextOut(GetDC(0),20,20,PChar(s),Length(s)); end; end; result := CallNextHookEx(H,ncode,WParam,LParam); end; end;
procedure SetMyHook; begin repeat H := SetWindowsHookEx(WH_JOURNALRECORD, @DoIt, hInstance, 0); until H<>0; end;
procedure UnhookMyHook; begin if H <> 0 then UnhookWindowsHookEx(H); end;
function WndMessageProc(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): UINT; stdcall; begin Result := 0; case Msg of WM_CREATE: SetMyHook; WM_DESTROY: begin UnhookMyHook; halt(0); end; end; Result := DefWindowProc(hWnd,Msg,wParam,lParam); end;
begin wClass:=WndClass1(hInstance,0,0,0,0,0,COLOR_BTNFACE,'MYCLASS','',@WndMessageProc); RegisterClass(wClass); hApp:=CreateWindow(wClass.lpszClassName, '',0, Integer(CW_USEDEFAULT), Integer(CW_USEDEFAULT), 0, 0, 0, 0, hInstance, nil); if hApp=0 then begin UnregisterClass('MYCLASS',hInstance); halt(0); end; loopWindow(wMsg); end.
|
Срочно нужно ато весь проект стоит из за этого!!! |