quick_sliver007 Posted June 22, 2006 Share Posted June 22, 2006 How do I know if a control is right clicked in a gui? I try this but it is not right. expandcollapse popup#include <GUIConstants.au3> Opt("GUICoordMode",2) Opt("GUIResizeMode", 1) Opt("GUIOnEventMode", 1) $parent1 = GUICreate("Parent1") GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "SpecialEvents");Here;;;;;;;;;;;; $ok1 = GUICtrlCreateButton ("OK", 10, 30, 50) GUICtrlSetOnEvent(-1, "OKPressed") $cancel1 = GUICtrlCreateButton ( "Cancel", 0, -1) GUICtrlSetOnEvent(-1, "CancelPressed") GUISetState(@SW_SHOW) While 1 Sleep(10) Wend Func OKPressed() MsgBox(0, "OK Pressed", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE & " CtrlHandle=" & @GUI_CTRLHANDLE) EndFunc Func CancelPressed() MsgBox(0, "Cancel Pressed", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE & " CtrlHandle=" & @GUI_CTRLHANDLE) EndFunc Func SpecialEvents() Select Case @GUI_CTRLID = $GUI_EVENT_CLOSE MsgBox(0, "Close Pressed", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE) Exit Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE MsgBox(0, "Window Minimized", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE) Case @GUI_CTRLID = $GUI_EVENT_RESTORE MsgBox(0, "Window Restored", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE) Case @GUI_CTRLID = $GUI_EVENT_SECONDARYDOWN; and here;;;;;;;is what i tried $ctrlfocus = ControlGetFocus($parent1,"parent1") MsgBox(0, "ControlGetFocus is " & $ctrlfocus,"ControlGetFocus is " & $ctrlfocus) EndSelect EndFunc . Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 22, 2006 Moderators Share Posted June 22, 2006 (edited) What's not working? I get the message box with whatever has focus at the moment. I would change this: $ctrlfocus = ControlGetFocus($parent1,"parent1")To this:$ctrlfocus = ControlGetFocus($parent1) Edited June 22, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
quick_sliver007 Posted June 23, 2006 Author Share Posted June 23, 2006 What's not working? I get the message box with whatever has focus at the moment. I would change this: $ctrlfocus = ControlGetFocus($parent1,"parent1")To this:$ctrlfocus = ControlGetFocus($parent1)Thank you, but that did not do it either. It only gets the button that was last left click, both ways. . Link to comment Share on other sites More sharing options...
syberschmo Posted June 23, 2006 Share Posted June 23, 2006 I found a workaround.... I'm sure theres a better way. Insert this under the @GUI_CTRLID = $GUI_EVENT_SECONDARYDOWN Opt("MouseCoordMode", 0) $pos = MouseGetPos() Select Case $pos[1]<75 AND $pos[1]>50 Select Case $pos[0]<50 AND $pos[0]>8 ControlFocus("Parent1", "", 3) Case $pos[0]<108 AND $pos[0]>58 ControlFocus("Parent1", "", 4) EndSelect EndSelect $ctrlfocus = ControlGetFocus($parent1) MsgBox(0, "ControlGetFocus is " & $ctrlfocus,"ControlGetFocus is " & $ctrlfocus) Gradient-Filled Progress Bars UDF Link to comment Share on other sites More sharing options...
quick_sliver007 Posted June 24, 2006 Author Share Posted June 24, 2006 I found a workaround.... I'm sure theres a better way. Insert this under the @GUI_CTRLID = $GUI_EVENT_SECONDARYDOWN Opt("MouseCoordMode", 0) $pos = MouseGetPos() Select Case $pos[1]<75 AND $pos[1]>50 Select Case $pos[0]<50 AND $pos[0]>8 ControlFocus("Parent1", "", 3) Case $pos[0]<108 AND $pos[0]>58 ControlFocus("Parent1", "", 4) EndSelect EndSelect $ctrlfocus = ControlGetFocus($parent1) MsgBox(0, "ControlGetFocus is " & $ctrlfocus,"ControlGetFocus is " & $ctrlfocus)Thats a big work around, thanks for the help though. I don't think there is any good way to do this. There may be a DLL way to do this, but I am no good with DLLs. . Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 24, 2006 Moderators Share Posted June 24, 2006 (edited) Thank you, but that did not do it either. It only gets the button that was last left click, both ways.It wasn't intended to do "anything", it was a visual correction I thought you should make because if the title ever changed, then that function would not work at all. Edited June 24, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
syberschmo Posted June 26, 2006 Share Posted June 26, 2006 I re-visited this problem and I came up with a really simple solution that I can't believe I missed. Is this what you are looking for? (in the While loop) Case @GUI_CTRLID = $GUI_EVENT_SECONDARYDOWN; and here;;;;;;;is what i tried $pos = GuiGetCursorInfo() MsgBox(0, "ControlGetFocus", "ControlGetFocus is " & $pos[4]) $pos[4] is the control that the mouse is hovering over. You could easily give it focus with the code I posted earlier, above. Regards, Gradient-Filled Progress Bars UDF Link to comment Share on other sites More sharing options...
quick_sliver007 Posted June 27, 2006 Author Share Posted June 27, 2006 I re-visited this problem and I came up with a really simple solution that I can't believe I missed. Is this what you are looking for? (in the While loop) Case @GUI_CTRLID = $GUI_EVENT_SECONDARYDOWN; and here;;;;;;;is what i tried $pos = GuiGetCursorInfo() MsgBox(0, "ControlGetFocus", "ControlGetFocus is " & $pos[4]) $pos[4] is the control that the mouse is hovering over. You could easily give it focus with the code I posted earlier, above. Regards,Thank you for the help. . 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