Malkey Posted May 18, 2008 Share Posted May 18, 2008 (edited) I have been trying to get the check/uncheck working in a context menu under v3.2.12.0.This script from this thread worked ok with v3.2.11.http://www.autoitscript.com/forum/index.ph...st&p=521662Duplicated here:expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) Local $hGui, $ContextMenu, $menu1,$menu2,$subMenu1,$separator1,$MenuItemExit $hGui = GUICreate("GDI1",200, 200, -1,-1) $ContextMenu = GUICtrlCreateContextMenu() $menu1 = GUICtrlCreateMenuItem("Toggle on/off", $ContextMenu) GUICtrlSetState($menu1, $GUI_UNCHECKED) GUICtrlSetOnEvent($menu1, "menu1Func") $menu2 = GUICtrlCreateMenu("To Submenu", $ContextMenu) $subMenu1 = GUICtrlCreateMenuItem("Submenu1)", $menu2) GUICtrlSetOnEvent($subMenu1, "Submenu1Func") $separator1 = GUICtrlCreateMenuItem("", $ContextMenu) ; create a separator line $radiotest = GUICtrlCreateMenu("Radio Test", $ContextMenu) $radio1 = GUICtrlCreateMenuItem("Radio Option1", $radiotest, -1, 1) GUICtrlSetState(-1, $GUI_CHECKED) $radio2 = GUICtrlCreateMenuItem("Radio Option2", $radiotest, -1, 1) $radio3 = GUICtrlCreateMenuItem("Radio Option3", $radiotest, -1, 1) $radio4 = GUICtrlCreateMenuItem("Radio Option4", $radiotest, -1, 1) GUICtrlCreateMenuItem("", $radiotest) $radioa = GUICtrlCreateMenuItem("Radio OptionA", $radiotest, -1, 1) $radiob = GUICtrlCreateMenuItem("Radio OptionB", $radiotest, -1, 1) GUICtrlSetState(-1, $GUI_CHECKED) $radioc = GUICtrlCreateMenuItem("Radio OptionC", $radiotest, -1, 1) GUICtrlCreateMenuItem("", $ContextMenu) $MenuItemExit = GUICtrlCreateMenuItem("Exit", $ContextMenu) GUICtrlSetOnEvent($MenuItemExit, "Quit") GUISetState() While 1 sleep(10) Wend Func menu1func() If BitAND(GUICtrlRead($menu1), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($menu1, $GUI_UNCHECKED) ;Extra Commands here, if needed.... Else GUICtrlSetState($menu1, $GUI_CHECKED) ;Extra Commands here, if needed.... EndIf Return 1 EndFunc ;==>ShowaOrig Func Submenu1Func() MsgBox(0,"","Submenu function here") EndFunc Func Quit() Local $e $e = MsgBox(1, "Exit", "Press OK to Exit") If $e = 1 Then Exit Return 1 EndFunc ;==>QuitDoes anyone know why the above script does not work with AutoIt v3.2.12.0. ?And is there a work around which will get the script working as it did with v3.2.11 ?Help would be greatly appreciated.Edit: removed unwanted command in script. Edited May 18, 2008 by Malkey Link to comment Share on other sites More sharing options...
monoceres Posted May 18, 2008 Share Posted May 18, 2008 Not sure but you might want to create a ticket for this. I made a small script that will illustrate the problem: #include <guiconstantsex.au3> Opt("GUIOnEventMode",1) GUICreate("") GUICtrlCreateButton("check",75,10) GUICtrlSetOnEvent(-1,"checkthebox") GUICtrlCreateButton("uncheck",10,10) GUICtrlSetOnEvent(-1,"uncheckthebox") $menu=GUICtrlCreateContextMenu() $item=GUICtrlCreateMenuItem("test",$menu) GUICtrlSetOnEvent(-1,"checker") GUISetOnEvent(-3,"close") GUISetState() Do Sleep(100) Until 2+2=5 Func close () Exit EndFunc Func checker() MsgBox(0,GUICtrlRead($item),GUICtrlGetState($item)) EndFunc Func checkthebox() GUICtrlSetState($item,$GUI_CHECKED) EndFunc Func uncheckthebox() GUICtrlSetState($item,$GUI_UNCHECKED) EndFunc It seems to be impossible to get the state of the menu! Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Malkey Posted May 18, 2008 Author Share Posted May 18, 2008 (edited) A work around: Declare Global $menu1Chk = 1 then Func menu1func() If $menu1Chk = 1 Then GUICtrlSetState($menu1, $GUI_UNCHECKED) $menu1Chk = 0 ;Extra Commands here, if needed.... Else GUICtrlSetState($menu1, $GUI_CHECKED) $menu1Chk = 1 ;Extra Commands here, if needed.... EndIf Return 1 EndFunc Edited May 18, 2008 by Malkey 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