Jump to content

Wait for Mouse Click


Recommended Posts

Im looking for a script that will wait for a mouse click then give the coords of the mouse click from within a Control so i can use Controlclick, ive tried _IfPressed and i have no luck.

Edited by b3lorixx
Link to comment
Share on other sites

#include <Misc.au3>
#Include <WinAPI.au3>
HotKeySet("{esc}", "_exit")

$_Title     = "[CLASS:Notepad]"                                     ; I've used the text field in notepad as an example.
$_Text      = ""
$_ControlID = "[CLASS:Edit; INSTANCE:1]"

$hWnd = ControlGetHandle($_Title, $_Text, $_ControlID)              ; Get the handle of the control you want to check.

While 1
    If _IsPressed(0x01) Then                                        ; Check if left mouse button is clicked.
        $tPoint = _WinAPI_GetMousePos()                             ; Get the position of the mouse.
        If _WinAPI_WindowFromPoint($tPoint) = $hWnd Then            ; Retrieve the handle of the window that contains the specified point (mouse position) &
            MsgBox(0,"","The Cake Is Alive!")                       ; do stuff if the the handles are the same.
        EndIf
    EndIf
WEnd

Func _exit()
    Exit
EndFunc

Edit: Added some comments.

Edited by Cake
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...