Jump to content
Sign in to follow this  
b3lorixx

Wait for Mouse Click

Recommended Posts

b3lorixx

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

Share this post


Link to post
Share on other sites
Kondro

http://www.autoitscript.com/autoit3/docs/functions/MouseGetPos.htm

Share this post


Link to post
Share on other sites
Cake

#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

Share this post


Link to post
Share on other sites
b3lorixx

Yes, however im using an IE embed (which i should have specified) and that method is not working

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.