YellowLab Posted May 5, 2009 Share Posted May 5, 2009 I have a script where I want a left click to do something different than a left click and hold, drag. I already have the RMB with another command so they cannot be separated in that manner. The following code is how I have distinguished the two, but it isn't 100% foolproof. Is there a better way? CODE ;---SNIP! Func _LeftClick() Local $nCID=@GUI_CtrlId Local $arTemp=MouseGetPos() Sleep(75) ;<----- THIS COULD BE A SETTING, I GUESS??? Local $Temp=GUIGetCursorInfo() ;after sleep - if the primary button is still down, then cursor is moving If $Temp[2]=1 Then _Move($nCID, $arTemp) ;send ctrlId and original mouse position Else _Rotate($nCID) EndIf EndFunc ;==>_LeftClick ;---SNIP! Thanks, Bob You can't see a rainbow without first experiencing the rain. Link to comment Share on other sites More sharing options...
JackDinn Posted May 5, 2009 Share Posted May 5, 2009 (edited) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 633, 452, 193, 125) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit EndSwitch $ans = mousetest() ; returns -1 if mousetest() finds mouse button not down If $ans = 1 Then MsgBox(0, "", "mouse dragged") If $ans = 0 Then MsgBox(0, "", "mouse clicked") WEnd Func mousetest() $cur_info = GUIGetCursorInfo($Form1) If $cur_info[2] = 0 Then Return -1; mouse not down Do $cur_info2 = GUIGetCursorInfo($Form1) If $cur_info2[2] = 0 Then Return 0; mouse clicked Sleep(50) Until $cur_info[0] <> $cur_info2[0] Or $cur_info[1] <> $cur_info2[1] Return 1; dragged mouse EndFunc;==>mousetest hope it is what your after . Edited May 5, 2009 by JackDinn Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now