mike1950r Posted July 24 Share Posted July 24 Hi, I want to get the state of menu-items created with GUICtrlCreateMenuItem. I want to get the state which has been set with GUICtrlSetState($n, $GUI_ENABLE) Or GUICtrlSetState($n, $GUI_DISABLE) But whatever I try I cannot get it working. Thanks for assistance. Cheers mike Link to comment Share on other sites More sharing options...
Developers Jos Posted July 24 Developers Share Posted July 24 Please show a code snippet showing what you want and isn't working, so we have something to work with. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
mike1950r Posted July 24 Author Share Posted July 24 If GUICtrlGetState($id) = $GUI_ENABLE Then MsgBox($MB_SYSTEMMODAL, "", "Enabled") EndIf If GUICtrlGetState($id) = $GUI_DISABLE Then MsgBox($MB_SYSTEMMODAL, "", "Disabled") EndIf Cheers mike Link to comment Share on other sites More sharing options...
Nine Posted July 24 Share Posted July 24 Try with a BitAND instead of = “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
mike1950r Posted July 24 Author Share Posted July 24 Hi, thanks for the answer. I think, the problem comes from the initial value. If the controls are created but not state is set yet, i get the value 0, which is not $enabled or $disabled. So far as I see the values should be: $enabled = 128 $disabled = 64 If i have set the values first time I get the right values with my code above. i just do not understand, that controls, which are active by default respond with 0, until setting is changed for the first time. cheers mike pixelsearch 1 Link to comment Share on other sites More sharing options...
Developers Jos Posted July 24 Developers Share Posted July 24 (edited) Use the bitand as suggested already or post that piece of code so we can suggest the change. Edited July 24 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
mike1950r Posted July 24 Author Share Posted July 24 Hi again, have come to this code piece, which works me: If GUICtrlGetState($idGlo_WE_Replace) <= $GUI_ENABLE Then ;Enabled EndIf If GUICtrlGetState($idGlo_WE_Replace) > $GUI_ENABLE Then ;Disabled EndIf This works also if the control has not received a GUICtrlSetState before. In this case GUICtrlGetState would get 0 instead of 64. $GUI_ENABLE is 64 $GUI_DISABLE is 128 Thanks for your help. Cheers mike Link to comment Share on other sites More sharing options...
Developers Jos Posted July 24 Developers Share Posted July 24 Try something like this with BitAnd() : If BitAND(GUICtrlGetState($idGlo_WE_Replace),$GUI_ENABLE) = $GUI_ENABLE Then SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
pixelsearch Posted July 24 Share Posted July 24 Guys, could you have a look at the script below. As Mike noticed, why GUICtrlSetState returns 0 when you click the button "Menu Item State" for the 1st time ? It seems strange, because when you add a button in a GUI, an immediate BitAnd(GUICtrlGetState(... $GUI_ENABLE)) indicates that the button IS enabled, so why is it different when it comes to a menuitem control ? expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration Local $hGUI = GUICreate("Test", 250, 200) Local $idMenu = GUICtrlCreateMenu("Languages") ; control id 3 Local $idMenuItem = GUICtrlCreateMenuItem("English", $idMenu) ; control id 4 Local $idState = GUICtrlCreateButton("Menu Item State", 50, 20, 150, 30) ; control id 5 Local $idDisable = GUICtrlCreateButton("Menu Item Disable", 50, 70, 150, 30) ; control id 6 Local $idEnable = GUICtrlCreateButton("Menu Item Enable", 50, 120, 150, 30) ; control id 7 GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $idState For $i = $idMenu To $idEnable If BitAND(GUICtrlGetState($i), $GUI_ENABLE) = $GUI_ENABLE Then ConsoleWrite("Controle #" & $i & " enable" & @crlf) EndIf Next ConsoleWrite("------------------" & @crlf) MsgBox($MB_TOPMOST, "State", _ "GuiCtrlGetState($idMenuItem) = " & GUICtrlGetState($idMenuItem) & @crlf & _ "GuiCtrlRead($idMenuItem) = " & GUICtrlRead($idMenuItem)) Case $idDisable GUICtrlSetState($idMenuItem, $GUI_DISABLE) Case $idEnable GUICtrlSetState($idMenuItem, $GUI_ENABLE) EndSwitch WEnd Link to comment Share on other sites More sharing options...
Nine Posted July 24 Share Posted July 24 (edited) It doesn't matter much. If equals to 0, it means enable. Same goes for _GUICtrlMenu_GetItemState. You can alternatively use this function and it will return 0 also. ps. i know it does not mean the same, but... It is not possible (but did not extensively tested it) to have a disabled menu item to be at state 0. So just test for disable, and if not then (you got your answer) Edited July 24 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
mike1950r Posted July 25 Author Share Posted July 25 (edited) 18 hours ago, Jos said: Try something like this with BitAnd() : If BitAND(GUICtrlGetState($idGlo_WE_Replace),$GUI_ENABLE) = $GUI_ENABLE Then same result for enabled: first time 0 , when set before 64 the problem is that GUICtrlCreateMenuItem creates items, which are enabled by default, but the value is not 64. Ofcourse you can workaround like this or that. If GUICtrlCreateMenuItem would be in a library, this could be corrected by setting up GUICtrlSetState($id, $GUI_ENABLE) after. cheers mike Edited July 25 by mike1950r Link to comment Share on other sites More sharing options...
Developers Jos Posted July 25 Developers Share Posted July 25 41 minutes ago, mike1950r said: same result for enabled: first time 0 , when set before 64 Why care? I shown a way to test for enabled. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Solution Nine Posted July 25 Solution Share Posted July 25 Alright, since you have not read my reply, here the code that will solve your "issue" : Func IsMenuEnable($iID) Return Not BitAND(GUICtrlGetState($iID), $GUI_DISABLE) EndFunc “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
mike1950r Posted July 25 Author Share Posted July 25 20 hours ago, Jos said: Try something like this with BitAnd() : If BitAND(GUICtrlGetState($idGlo_WE_Replace),$GUI_ENABLE) = $GUI_ENABLE Then Hi Jos, I tried this, but without success. Cheers mike Link to comment Share on other sites More sharing options...
mike1950r Posted July 25 Author Share Posted July 25 1 hour ago, Nine said: Alright, since you have not read my reply, here the code that will solve your "issue" : Func IsMenuEnable($iID) Return Not BitAND(GUICtrlGetState($iID), $GUI_DISABLE) EndFunc Hi Nine, sorry if I did not pay attention for your post. (english is not my mother language, sometimes I miss something) This function, testing via opposite of enabled works, cause disable is always sent allright. Cheers mike Link to comment Share on other sites More sharing options...
Developers Jos Posted July 25 Developers Share Posted July 25 26 minutes ago, mike1950r said: Hi Jos, I tried this, but without success. Cheers mike Show us what you tried so we see what is happening! SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
mike1950r Posted July 26 Author Share Posted July 26 Jos, BitAND(GUICtrlGetState($idGlo_WE_Replace),$GUI_ENABLE) does not change the result. I get 0 or 64 like posted above. If I want to use $GUI_ENABLE I must use: If GUICtrlGetState($idGlo_WE_Replace) <= $GUI_ENABLE Then ;Enabled EndIf Or use $GUI_DISABLE instead: If Not (GUICtrlGetState($idGlo_WE_Replace) = $GUI_DISABLE) Then ;Enabled EndIf I can live with these posibilities. Cheers mike Link to comment Share on other sites More sharing options...
Developers Jos Posted July 26 Developers Share Posted July 26 Again, post me an example that shows your issue, and I am happy to take a look, but am not in business to code a testscript for you! SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
mike1950r Posted July 26 Author Share Posted July 26 (edited) Jos, I have no issue anymore and you don't need to code a testscript for me. Last post I have told the solutions which are fine. Thanks for your help. Cheers mike 🙂 Edited July 26 by mike1950r 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