TGC Codebase Backup



Force MouseClick,. (User32.dll) by MSon

8th Apr 2008 16:55
Summary

Force a Windows Left, Middle, RightClick, Double Click and more



Description

Force a Windows Left, Middle, RightClick, Double Click and more

Please note that the Constants are the commands, (Run source for Example Usage)



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    ` --------------------------------------------------------------------------------
` By Michael Mihalyfi, (MSon)
` Mihalyfi@hotmail.co.uk
` --------------------------------------------------------------------------------

` Setup --------------------------------------------------------------------------------
  #Constant User32 1
  #Constant MOUSE_LEFTDOWN     Mouse_Event(   1)
  #Constant MOUSE_LEFTUP       Mouse_Event(   2)
  #Constant MOUSE_LEFTCLICK    Mouse_Event(  12)
  #Constant MOUSE_DOUBLECLICK  Mouse_Event(1212)
  #Constant MOUSE_RIGHTDOWN    Mouse_Event(   3)
  #Constant MOUSE_RIGHTUP      Mouse_Event(   4)
  #Constant MOUSE_RIGHTCLICK   Mouse_Event(  34)
  #Constant MOUSE_MIDDLEDOWN   Mouse_Event(   5)
  #Constant MOUSE_MIDDLEUP     Mouse_Event(   6)
  #Constant MOUSE_MIDDLECLICK  Mouse_Event(  56)
  load dll "user32.dll",User32
` --------------------------------------------------------------------------------


  MOUSE_LEFTCLICK
  END



`        --------------------------------------------------------------------------------
FUNCTION SetCursorPos(x,y)
         CALL DLL 1,"SetCursorPos",x,y

ENDFUNCTION
`        --------------------------------------------------------------------------------
FUNCTION Mouse_Event(Btn)
         FOR n = 1 to LEN(STR$(Btn))  : v = Val(Mid$(STR$(Btn),n))
         IF v = 1 THEN CALL DLL User32,"mouse_event",0x2 ,0,0,0,0
         IF v = 2 THEN CALL DLL User32,"mouse_event",0x4 ,0,0,0,0
         IF v = 3 THEN CALL DLL User32,"mouse_event",0x8 ,0,0,0,0
         IF v = 4 THEN CALL DLL User32,"mouse_event",0x10,0,0,0,0
         IF v = 5 THEN CALL DLL User32,"mouse_event",0x20,0,0,0,0
         IF v = 6 THEN CALL DLL User32,"mouse_event",0x40,0,0,0,0
         NEXT n

ENDFUNCTION
`        --------------------------------------------------------------------------------