Sign in to follow this  
Followers 0
William Wise

How do I prompt user to click the left mouse button?

5 posts in this topic

Hi Folks,

I'm a newbie so please be kind!

:-)

I need to prompt the user to click the left mouse button and then grab the mouse coordinates of where they clicked. Any help? (I need to do this twice to get the start and stop locations for a drag and drop operation.)

Kind Regards,

Will

Share this post


Link to post
Share on other sites



Take a peek in the helpfile at the following functions.

MsgBox()

MouseGetPos()

MouseClickDrag()

Something along those lines.

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Welcome to the forums.

You might try this code. (Change it as you need.)

;see the help file (desktop / app window?)
AutoItSetOption("MouseCoordMode", 1)


;this loop repeats until a left mouse click occurs
Do
    $pos1 = MouseGetPos()
    ToolTip("Click on first position." & @CR & _
            "Desktop X: " & $pos1[0] & ", " & "Y: " & $pos1[1])
    Sleep(10)
Until _IsPressed('01')
$pos1 = MouseGetPos()


;this loop repeats unitl the left mouse click is released
Do
    Sleep(10)
Until Not _IsPressed('01')


;this loop repeats until a left mouse click occurs again
Do
    $pos2 = MouseGetPos()
    ToolTip("Click on second position." & @CR & _
            "Desktop X: " & $pos2[0] & ", " & "Y: " & $pos2[1])
    Sleep(10)
Until _IsPressed('01')
$pos2 = MouseGetPos()


ToolTip("")
MsgBox(0, "1st", "Desktop X: " & $pos1[0] & ", " & "Y: " & $pos1[1])
MsgBox(0, "2nd", "Desktop X: " & $pos2[0] & ", " & "Y: " & $pos2[1])


;UDF by ezzetabi
Func _IsPressed($hexKey)
    
    Local $aR, $bO
    
    $hexKey = '0x' & $hexKey
    $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
    If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then
        $bO = 1
    Else
        $bO = 0
    EndIf
    
    Return $bO
EndFunc  ;==>_IsPressed
You can read more about ezzetabi's "IsPressed" UDF here:

http://www.autoitscript.com/forum/index.php?showtopic=5760

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Thanks much. Works great!

Is there a GUI builder for AutoIT ala VB6? This would be a fantastic addition!

Will

Share this post


Link to post
Share on other sites

Thanks much. Works great!

Is there a GUI builder for AutoIT ala VB6? This would be a fantastic addition!

Will

Checkout the SciTE4AutoIt3 editor:

http://www.autoitscript.com/autoit3/scite/

Then look thru the tools in the menu bar for "GuiBuilder".


[size="1"][font="Arial"].[u].[/u][/font][/size]

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  
Followers 0