Swimming_Bird Posted July 14, 2006 Posted July 14, 2006 This is the question i was really forumlating fo rmy other post. I was wondering how i would go about registering a right click on a checkbox control (text et all)
rakudave Posted July 14, 2006 Posted July 14, 2006 hmm, what about GUIGetCursorInfo ( [winhandle] )? If successful, returns a five-element array that containing the mouse cursor information: $array[0]= X coord (horizontal) $array[1] = Y coord (vertical) $array[2] = Primary down (1 if pressed, 0 if not pressed) $array[3] = Secondary down (1 if pressed, 0 if not pressed) $array[4] = ID of the control that the mouse cursor is hovering over (or 0 if none) the array[4] will contain the id of your checkbox... Pangaea Ruler new, UDF: _GUICtrlCreateContainer(), Pangaea Desktops, Pangaea Notepad, SuDoku, UDF: Table
Swimming_Bird Posted July 14, 2006 Author Posted July 14, 2006 (edited) how would it register the click? if you right click on a control does it get passed to GUIGetMsg()? In that case would i just have If $msg = $control Then<br /> $array = GUIGetCursorInfo ()<br /> If $array[3] Then<br /> _RightClick ()<br /> Else<br /> _LeftClick ()<br /> EndIf<br />EndIf hrm autoit tags dont seem to be working $msg = GUIGetMsg() If $msg = $control Then $array = GUIGetCursorInfo () If $array[3] Then _RightClick () Else _LeftClick () EndIf EndIf Would it respond fast enough to register the click? Edited July 14, 2006 by Swimming_BIrd
rakudave Posted July 15, 2006 Posted July 15, 2006 (edited) yes... here's a working example... #include <GUIConstants.au3> GUICreate("my gui",100,100,-1,-1) $checkbox = GUICtrlCreateCheckbox("my checkbox",10,40) GUISetState() do $msg = GUIGetMsg() $cur = GUIGetCursorInfo() If $cur[3] = 1 AND $cur[4] = $checkbox then RightClick() until $msg = $GUI_EVENT_CLOSE Func RightClick() msgbox(0,"RightClick","you rightclicked on the checkbox!") ; ... something else here ... EndFunc ...hope this helps... Edited July 15, 2006 by rakudave Pangaea Ruler new, UDF: _GUICtrlCreateContainer(), Pangaea Desktops, Pangaea Notepad, SuDoku, UDF: Table
Swimming_Bird Posted July 18, 2006 Author Posted July 18, 2006 hrm your script will trigger the rightclick function as many times as i right click. however when i tried to extend your code i broke it somehow. with this it will only triger the select statement the first time i right click #include <GUIConstants.au3> $parent = GUICreate("my gui",100,100,-1,-1) $checkbox = GUICtrlCreateCheckbox("my checkbox",10,40) GUISetState ( @SW_SHOW , $parent ) While WinActive ( 'my gui' ) Or WinActive ( 'Child' ) $msg = GUIGetMsg() $cur = GUIGetCursorInfo() Select Case $cur[3] = 1 AND $cur[4] = $checkbox MsgBox ( 0 , '' , '' ) RightClick() EndSelect WEnd Func RightClick() $popu = GUICreate ( 'Child' , 100 , 100 , 50 , 50 , $WS_POPUP + $WS_BORDER , -1 , $parent ) GUICtrlCreateLabel ( 'blahblahblah' , 10 , 10 ) GUISetState ( @SW_SHOW , $popu ) While WinActive ( 'Child' ) Sleep ( 350 ) WEnd GUISetState ( @SW_HIDE , $popu ) EndFunc
Swimming_Bird Posted July 18, 2006 Author Posted July 18, 2006 what confuses me is why it wont even call the function. maybe the guicreate is screwed up or something on a second run. i'm guessing that somehow i make it so the guigetmsg isnt grabbing from the correct gui
Swimming_Bird Posted July 18, 2006 Author Posted July 18, 2006 I think i've fixed my problem, however i'm unsure if having a set state for the gui in the while loop is poor coding? #include <GUIConstants.au3> $parent = GUICreate("my gui",100,100,-1,-1) $checkbox = GUICtrlCreateCheckbox("my checkbox",10,40) GUISetState ( @SW_SHOW , $parent ) While WinActive ( 'my gui' ) Or WinActive ( 'Child' ) GUISetState ( @SW_SHOW , $parent ) $msg = GUIGetMsg() $cur = GUIGetCursorInfo() Select Case $cur[3] = 1 AND $cur[4] = $checkbox RightClick() EndSelect WEnd Func RightClick() $popu = GUICreate ( 'Child' , 100 , 100 , 50 , 50 , $WS_POPUP + $WS_BORDER , -1 , $parent ) GUICtrlCreateLabel ( 'blahblahblah' , 10 , 10 ) GUISetState ( @SW_SHOW , $popu ) While WinActive ( 'Child' ) Sleep ( 350 ) WEnd GUISetState ( @SW_HIDE , $popu ) $popu = '' EndFunc
rakudave Posted July 18, 2006 Posted July 18, 2006 yes, it is not necessary... Pangaea Ruler new, UDF: _GUICtrlCreateContainer(), Pangaea Desktops, Pangaea Notepad, SuDoku, UDF: Table
Swimming_Bird Posted July 18, 2006 Author Posted July 18, 2006 if i didnt have it in there the creation of the other gui would make the GUIGetMsg and GUIGetCursorInfo try and grab info from the wrong gui. however i just discovered the GUIDelete function i'll see if that allows me not to use that. EDIT: yup that worked beautifully
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