SendMessageA or PostMessageA Mouse Click

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
mhcha
Junior Coder
Posts: 23
Joined: Sat Jan 01, 2022 11:10 am

SendMessageA or PostMessageA Mouse Click

Post by mhcha » Sat Feb 11, 2023 12:23 pm

Hello.

I want to use left-click via SendMessage or PostMessage functions in User32.dll.
I made it by referring to the post below, but I'm not sure.

https://www.mjtnet.com/blog/2006/01/19/ ... positions/
https://www.mjtnet.com/scripts/winmsgs.txt

Code: Select all

VBSTART
Function LoWord(wInt)
LoWord = wInt AND &HFFFF&
End Function

Function HiWord(wInt)
HiWord = wInt  &H10000 AND &HFFFF&  // Returns the error here.
End Function

Function MAKELPARAM(wLow, wHigh)
MAKELPARAM = LoWord(wLow) Or (&H10000 * LoWord(wHigh))
End Function
VBEND
Below is the code I wrote.

Code: Select all

FindImagePos>C:\Users\admin\Desktop\test.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0

VBSTART
Function LoWord(wInt)
LoWord = wInt AND &HFFFF&
End Function
Function HiWord(wInt)
HiWord = wInt &H10000 AND &HFFFF&
End Function
Function MAKELPARAM(wLow, wHigh)
MAKELPARAM = LoWord(wLow) Or (&H10000 * LoWord(wHigh))
End Function
VBEND
VBEval>MAKELPARAM(%XArr_0%,%YArr_0%),lparam

Let>WM_LBUTTONDOWN=513 // convert 0x0201 to decimal.

LibFunc>User32,SendMessageA,r,DIALOG1.PANEL1.HANDLE,WM_LBUTTONDOWN,1,lparam

Endif
I ask for your help.
Thank you.

mhcha
Junior Coder
Posts: 23
Joined: Sat Jan 01, 2022 11:10 am

Re: SendMessageA or PostMessageA Mouse Click

Post by mhcha » Sat Feb 11, 2023 7:46 pm

As a test, I made a code that simply clicks the coordinates of 100 and 200, but an error occurs saying ')' is required.

Code: Select all

VBSTART
Function LoWord(wInt)
LoWord = wInt AND &HFFFF&
End Function
Function HiWord(wInt)
HiWord = (wInt SHR 16) AND &HFFFF&
End Function
Function MAKELPARAM(wLow, wHigh)
MAKELPARAM = (wLow AND &HFFFF&) OR ((wHigh AND &HFFFF&) * &H10000)
End Function
VBEND
Let>X=100
Let>Y=200

VBEval>MAKELPARAM(X, Y), lparam

Let>WM_LBUTTONDOWN=513
Let>WM_LBUTTONUP=514
LibFunc>User32,PostMessageA,r,0,WM_LBUTTONDOWN,1,lparam
LibFunc>User32,PostMessageA,r,0,WM_LBUTTONUP,0,lparam

mhcha
Junior Coder
Posts: 23
Joined: Sat Jan 01, 2022 11:10 am

Re: SendMessageA or PostMessageA Mouse Click

Post by mhcha » Sun Feb 12, 2023 1:45 am

Since the macro scheduler can calculate bitwise logical operators, I tried using it as below, but it doesn't work.

Code: Select all

Let>X=100
Let>Y=200
Let>lparam2={%Y% SHL 16}
Let>lparam={%X% OR %lparam2%}

Let>WM_LBUTTONDOWN=513
Let>WM_LBUTTONUP=514
LibFunc>User32,PostMessageA,r,0,WM_LBUTTONDOWN,1,lparam
LibFunc>User32,PostMessageA,r,0,WM_LBUTTONUP,0,lparam

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: SendMessageA or PostMessageA Mouse Click

Post by Marcus Tettmar » Mon Feb 13, 2023 2:54 pm

I think you want:

Code: Select all

Let>lparam={(%y% * 65536) OR (%x% AND 65535)}
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts