Markos Posted June 13, 2008 Share Posted June 13, 2008 (edited) 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 June 14, 2008 by Markos Link to comment Share on other sites More sharing options...
Markos Posted June 14, 2008 Author Share Posted June 14, 2008 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 More sharing options...
Millenia Posted August 31, 2010 Share Posted August 31, 2010 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 More sharing options...
JohnOne Posted August 31, 2010 Share Posted August 31, 2010 Or you could use the standard WinAPI/Ex UDFs, _WinAPI_Mouse_Event() << helpfile AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now