Home > Software engineering >  How to use PostMessage background form to send the mouse to click any set of position
How to use PostMessage background form to send the mouse to click any set of position

Time:10-17

Saw these years about PostMessage background form to send the mouse to click any set of position, didn't find a code is achievable, depressed ah, don't know where the code error

 
Private Declare Function PostMessage Lib "user32. DLL" Alias "PostMessageA" (ByVal HWND As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam) As Long As Long
Private Const WM_LBUTTONDOWN As Long=& amp; H201
Private Const WM_LBUTTONUP As Long=& amp; H202

Private Sub Command1_Click ()
SendClick Me. HWND, 10, 10
End Sub

Private Sub Form_Click ()
MsgBox "dasd
"End Sub

Private Function SendClick (HWND As Long, mX, As Long As mY Long)
'
click messages sentDim As Long I
I=PostMessage (HWND, WM_LBUTTONDOWN, 0, (mX And & amp; HFFFF) + (mY And & amp; HFFFF) * & amp; H10000)
I=PostMessage (HWND, WM_LBUTTONUP, 0, (mX And & amp; HFFFF) + (mY And & amp; HFFFF) * & amp; H10000)
End the Function




HWND if you said is wrong, so no sent to, if not so back to things, don't know why, now don't have gone?

CodePudding user response:

PostMessage Settings window position? The building Lord why trifles?

CodePudding user response:

I have this code, the form coordinates can be click, no problem,
If is ordinary creat form, even the buttons inside the can, but if you are a GUI Windows gdi can only be generated background, button is not can point,
Also, if is a messagebox dialog box is not clickable, and if there is a dialog box, also can't click form inside the handle, messagebox is only the handle to desktop level can click, the tested very strange,

CodePudding user response:

If is ordinary creat form, even inside the button can order

Creat form is what meaning, is not a general program to generate the form?

CodePudding user response:

Do you have a will?

CodePudding user response:

Top, I also want to know why it doesn't work?

In many BBS have all witnessed the building of the code, there is a call "widely spread-and deeply felt the horse" to send several times, but why I can't test on the machine of success ~?


The same code must have a lot of people is successful, why some people can't succeed? What reason do ~! ?

CodePudding user response:

reference 5 floor guaimu reply:
top, I also want to know why it doesn't work?

In many BBS have all witnessed the building of the code, there is a call "widely spread-and deeply felt the horse" to send several times, but why I can't test on the machine of success ~?


The same code must have a lot of people is successful, why some people can't succeed? What reason do ~! ?


I am that widely spread-and deeply felt the old - -!

Your test code should be unsuccessful, because VB forms seems to produce the click event message response condition is not only the two messages.

I tried before, only the two messages, even if with manual click when the same news, also won't produce the click event.

So let alone want to relative coordinates, click on the form of internal control.

This deep to get to know the specific reason I don't have, but other controls, for example, the button is can response.

The building code change, add a button, and then add a message box, like this:

 private sub Command2_Click () 
Msgbox "Click!"
End sub


Then the button 1 in the handle with a handle to the button 2:

 SendClick Command2 HWND, 10, 10 


With respect to OK.

In addition, this code as long as coordinates, right, you can click on the web, has made a lot of XXXXXX it software, ahem.

CodePudding user response:

Click the free horse, look at the postmessage any position, I have a few months, and I can't help

CodePudding user response:

https://code.csdn.net/snippets/112740
Help to have a look, thanks!

CodePudding user response:

http://www.autohotkey.com
  •  Tags:  
  • API
  • Related