Jump to content

[Solved] MouseClick('XBUTTON1')


Recommended Posts

I need to click mouse buttons X1 and X2. Autoit does not have this feature so I need to do this via a dllcall. I have very limited knowlege about dlls.

On msdn I found that function 'mouse_event' should be able to do that.

First I wanted to left click (I know autoit can do that but I wanted to learn it that way), but I wasnt able to get it working.

I tried many combinations, some of them:

;http://msdn.microsoft.com/en-us/library/ms646260(VS.85).aspx

DllCall('user32.dll', 'none', 'mouse_event', 'dword', 'MOUSEEVENTF_LEFTDOWN')
DllCall('user32.dll', 'none', 'mouse_event', 'dword', 'MOUSEEVENTF_LEFTDOWN', 'dword', 0, 'dword', 0)
DllCall('user32.dll', 'none', 'mouse_event', 'dword', 'MOUSEEVENTF_LEFTDOWN', 'dword', 0, 'dword', 0, 'dword', 0, 'ptr', 0)
DllCall('user32.dll', 'none', 'mouse_event', 'dword', 'MOUSEEVENTF_LEFTDOWN', 'dword', 300, 'dword', 300, 'dword', 0, 'ptr', 0)

DllCall('user32.dll', 'none', 'mouse_event', 'dword', 'MOUSEEVENTF_LEFTDOWN', 'dword', '0', 'dword', '0', 'dword', '0', 'ptr', '0')

the autoit crashes (or what?) because when i tried to:

DllCall .... 
MsgBox(0, '', @error)

For some of the posted calls it does:

nothing, the script ends, and in console appears:

!>20:09:00 AutoIT3.exe ended.rc:1073807366

for some it does nothing and msg box shows error 0 (=success)

Edited by Markos
Link to comment
Share on other sites

so I figured that out.

If anybody cares how to mouse click mid,X1,X2 buttons (which autoit does not support) here is the code:

DllCall('user32.dll', 'none', 'mouse_event', 'dword',32, 'dword', 0, 'dword', 0, 'dword', 0, 'ptr', 0) ;middle button push
DllCall('user32.dll', 'none', 'mouse_event', 'dword',64, 'dword', 0, 'dword', 0, 'dword', 0, 'ptr', 0) ;middle button release

DllCall('user32.dll', 'none', 'mouse_event', 'dword', 128, 'dword', 0, 'dword', 0, 'dword', 1, 'ptr', 0) ;X1 push
DllCall('user32.dll', 'none', 'mouse_event', 'dword', 256, 'dword', 0, 'dword', 0, 'dword', 1, 'ptr', 0) ;X1 release

DllCall('user32.dll', 'none', 'mouse_event', 'dword', 128, 'dword', 0, 'dword', 0, 'dword', 2, 'ptr', 0) ;X2 push
DllCall('user32.dll', 'none', 'mouse_event', 'dword', 256, 'dword', 0, 'dword', 0, 'dword', 2, 'ptr', 0) ;X2 release

Might be usefull to add this to normal mouseclick command.

Link to comment
Share on other sites

  • 2 years later...

I'll just add M1 and M2 mouse events and wheel up\down for user32.dll.

MOUSEEVENTF_LEFTDOWN 0x0002

MOUSEEVENTF_LEFTUP 0x0004

MOUSEEVENTF_RIGHTDOWN 0x0008

MOUSEEVENTF_RIGHTUP 0x0010

MOUSEEVENTF_MIDDLEDOWN 0x0020

MOUSEEVENTF_MIDDLEUP 0x0040

MOUSEEVENTF_WHEEL 0x0800 That just returns 1 when mouse wheel is moved. Use dwData to return amount moved.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...