#include <GuiConstants.au3>
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
#include <Misc.au3>
$dll = DllOpen("user32.dll")
main()
Func main()
Global $GUI = GUICreate("Coordinates",190,115)
$guiLabel = GUICtrlCreateLabel("Type, or click coordinates?",10,10)
Global $btnType = GUICtrlCreateButton("Type",20,60,60,20)
Global $btnClick = GUICtrlCreateButton("Click",80,60,60,20)
GUISetState(@SW_SHOW,$GUI)
EndFunc
Func typeCoords()
Local $zCoordChoose = InputBox("Type coordinates", "Enter the coordinates to click", "", "")
Local $xNew = StringSplit($zCoordChoose, ",")
Global $xCoord = StringStripWS($xNew[1], $STR_STRIPALL)
Global $yCoord = StringStripWS($xNew[2], $STR_STRIPALL)
watButton()
EndFunc
Func clickCoords()
GUIDelete($GUI)
While 1
If _IsPressed("01", $dll) Then
$avMousePos = MouseGetPos()
Global $xCoord = $avMousePos[0]
Global $yCoord = $avMousePos[1]
watButton()
EndIf
WEnd
EndFunc
Func watButton()
Global $zMouseChoose = InputBox("Mouse click at "&$xCoord&","&$yCoord, "Mouse button to click?"&@LF&@LF&"'PRIMARY': Left Mouse Button"&@LF&"'SECONDARY': Right Mouse Button"&@LF&"'MIDDLE': Middle Mouse Button (a.k.a. Scroll click)", "", "")
startClick()
EndFunc
Func startClick()
Do
MouseClick ($zMouseChoose,$xCoord,$yCoord)
Sleep(100) ; 500ms = .5sec
Until _IsPressed ("09") ;TAB
Exit
EndFunc
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
GUISetState(@SW_HIDE, $GUI)
Case $btnType
typeCoords()
Case $btnClick
clickCoords()
EndSwitch
WEnd