Forcing a Mouse Click

BlitzPlus Forums/BlitzPlus Programming/Forcing a Mouse Click

UUICEO(Posted 2008) [#1]
Does anyone know of a way to make the mouse click on a location without actually having to have a person do it manually? I've been working on writing an auto-clicking program but it never occurred to me to see if Blitz was able to click the mouse by itself. Any help or info would be appreciated.


Snarkbait(Posted 2008) [#2]
Someone just posted some code in the archives, for blitzmax, however, but it was easily possible with API calls.


Andres(Posted 2008) [#3]
Function SimulateMouseClick(x%, y%)
	cur_x% = MouseX():cur_y% = MouseY()
	api_SetCursorPos(x%, y%)
	api_mouse_event($0201, 0, 0, 0, 0)
	api_mouse_event($0202, 0, 0, 0, 0)
	api_SetCursorPos(cur_x%, cur_y%)
End Function



Snarkbait(Posted 2008) [#4]
needs a .decls file, too
.lib "user32.dll"
api_SetCursorPos% (x%, y%) : "SetCursorPos"
api_mouse_event (dwFlags%, dx%, dy%, cButtons%, dwExtraInfo%) : "mouse_event"



Snarkbait(Posted 2008) [#5]
Just read on MSD the 'mouse_event' command is not supposed to be used anymore, you're supposed to use SendInput. meh.


Andres(Posted 2008) [#6]
Let me guess, because of the new and cool OS Vista?