Recent

Author Topic: Check the windows desktop to send mouse clicks  (Read 10315 times)

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Check the windows desktop to send mouse clicks
« Reply #15 on: September 02, 2014, 12:28:51 pm »
the link click is not part of the windows handling mechanism like the button click. In other words there is no way that can be emulated with out taking apart how the browser works and what expects be thankful if the only think you have to do is to move the mouse.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Check the windows desktop to send mouse clicks
« Reply #16 on: September 02, 2014, 04:35:32 pm »
The 2nd code finds the window and clicks around the middle of its client area. It needs to find the client coordinates of the same point you provide instead.

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Check the windows desktop to send mouse clicks
« Reply #17 on: September 03, 2014, 01:49:41 am »
For some reason GetWindowInfo is not in Windows unit, I feel lazy so I replaced Windows unit with JwaWinUser and JwaWinType units:
Code: [Select]
uses
  JwaWinUser, JwaWinType{, Windows};

procedure TForm1.Timer1Timer(Sender: TObject);
var
  Coordinates: TSmallPoint;
  aPt: POINT;
  aWnd: HWND;
  aRect: TRect;
  aInfo: TWindowInfo;
begin
  aPt.x := 124;  //<--- provide the correct values
  aPt.y := 214;

  aWnd := WindowFromPoint(aPt);

  GetWindowInfo(aWnd, aInfo);
  Coordinates.X := aPt.x - aInfo.rcClient.Left;
  Coordinates.Y := aPt.y - aInfo.rcClient.Top;

  SendMessage(aWnd, WM_LBUTTONDOWN, 0, LParam(Coordinates));
  SendMessage(aWnd, WM_LBUTTONUP, 0, LParam(Coordinates));
end;

I tried it on FireFox and it worked.

 

TinyPortal © 2005-2018