Jump to content

_MouseClick


GaryFrost
 Share

Recommended Posts

This is something I did a while back for automated scripts so the user could see the automation was doing something, the mouse moves and clicks the controls

Func _MouseClick($TITLE, $TEXT, $CONTROLID)
    Local $MouseCoordModeBAK = AutoItSetOption("MouseCoordMode", 2)
   Local $POS = ControlGetPos($TITLE, $TEXT, $CONTROLID)
   MouseMove($POS[0] + 10, $POS[1] + 10, 4)
   MouseDown("left")
   Sleep(500)
   MouseUp("left")
    AutoItSetOption("MouseCoordMode", $MouseCoordModeBAK)
EndFunc  ;==>_MouseClick

Below is short example:

#region --- GuiBuilder code Start ---
; Script generated by AutoBuilder 0.5 Prototype

#include <GuiConstants.au3>

If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

$GUI_WIN = GuiCreate("MyGUI", 392, 323,(@DesktopWidth-392)/2, (@DesktopHeight-323)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$Button_1 = GuiCtrlCreateButton("&OK", 70, 210, 90, 40)
$Button_2 = GuiCtrlCreateButton("E&xit", 230, 210, 90, 40)
$Button_3 = GuiCtrlCreateButton("Test Mouse Click", (392/2) - 45, (323/2) - 20, 90, 40)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button_1
        ConsoleWrite("_MouseClick Button 1" & @CR)
    Case $msg = $Button_2
        ConsoleWrite("_MouseClick Button 2" & @CR)
        ExitLoop
    Case $msg = $Button_3
        _MouseClick($GUI_WIN,"","Button1")
        _MouseClick($GUI_WIN,"","Button2")
    EndSelect
WEnd
Exit
#endregion --- GuiBuilder generated code End ---

Func _MouseClick($TITLE, $TEXT, $CONTROLID)
    Local $MouseCoordModeBAK = AutoItSetOption("MouseCoordMode", 2)
   Local $POS = ControlGetPos($TITLE, $TEXT, $CONTROLID)
   MouseMove($POS[0] + 10, $POS[1] + 10, 4)
   MouseDown("left")
   Sleep(500)
   MouseUp("left")
    AutoItSetOption("MouseCoordMode", $MouseCoordModeBAK)
EndFunc  ;==>_MouseClick

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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...