Location Earth, (I Think)
Home
About Us
Contact Us
Links
Home
Forcing MouseClick Events, (User32.dll)
 
Using the Code below, you can Access the User32.dll to Force a Window Mouse Click, To use the Code simple copy the Contents of the Panel at the Bottom and Paste it into a DarkBasic Window, Press F5 and it will work instantly.
 
This is very simple system to use, for example you can force a left MouseClick like this

MOUSE_LEFTCLICK

or like this

MOUSE_LEFTDOWN
MOUSE_LEFTUP

The second version, If you delay the MOUSE_LEFTUP, then it should force a click and drag situation.
 
This source also includes commands for Middle + Right Click and Double Click, but by calling MOUSE_EVENT(Btns), you can also simulate Combos, Double Right Click, Whatever you want, Please note that the Constants are the Commands, as a result, this would make a great #Include File as it gives about 10 new mouse commands.
 

` -----------------------------------------------------------------
` By Michael Mihalyfi, (MSon)
` Mihalyfi@hotmail.co.uk
` -----------------------------------------------------------------
` Setup -----------------------------------------------------------

  #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)
  #CONSTANT DLL_User32 1

  LOAD DLL "User32.dll",DLL_User32
` -----------------------------------------------------------------


  SET WINDOW OFF
  MOUSE_RIGHTCLICK
  END


`        ----------------------------------------------------------

FUNCTION SetCursorPos(x,y)
         CALL DLL DLL_User32,"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 DLL_User32,"mouse_event",0x2 ,0,0,0,0
          IF v = 2 THEN CALL DLL DLL_User32,"mouse_event",0x4 ,0,0,0,0
          IF v = 3 THEN CALL DLL DLL_User32,"mouse_event",0x8 ,0,0,0,0
          IF v = 4 THEN CALL DLL DLL_User32,"mouse_event",0x10,0,0,0,0
          IF v = 5 THEN CALL DLL DLL_User32,"mouse_event",0x20,0,0,0,0
          IF v = 6 THEN CALL DLL DLL_User32,"mouse_event",0x40,0,0,0,0
          NEXT n

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