etni3s Posted June 22, 2009 Share Posted June 22, 2009 Hi. Is there any way to test if a menu item in a menubar is enabled? Alternatively if that isn't possible, can I test if an icon in a toolbar in enabled? Thanks for any help. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 22, 2009 Moderators Share Posted June 22, 2009 etni3s,First, welcome to the AutoIt forums.Try looking at _GUICtrlMenu_GetItemEnabled in the Help file.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
etni3s Posted June 23, 2009 Author Share Posted June 23, 2009 Thanks for the warm welcome and help, but I've run into a new problem now I'm getting inconsistent values from the function you pointed me towards, depending on if I start the program via the script or if i start it my self before i execute the script.See in the code at the bottom where it says: MsgBox(0,"debug","connect: " & $hConnect & @LF & "disconnect: " & $hDisconnect)When I start the program myself it works fine. The box says True, False. When I let the script start the program it says True, True though.. Really wierd, because when I check it by hand, the "Connect" is enabled and the "Disconnect" is disabled. I've tried with all sorts of sleeps and stuff but to no avail. See code: http://pastebin.com/m1700a5f1 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 23, 2009 Moderators Share Posted June 23, 2009 etni3s,I cannot see anything wrong which jumps out at me.I know you said that Sleep did not help - but I wonder if the app needs a moment to determine the correct state of the menu items. You might like to see if opening the menu immediately as you start the app independently shows this. This could well be the case if it involves polling a connection, as there must be a finite time-out period before deciding there is none. And it would chime with the fact that a pre-opened app gives the correct response when tested, while a script-opened app does not. So perhaps a short wait after having determined the menu handle?A couple of other suggestions:1. Try using _GUICtrlMenu_GetItemState which should give you 0 for enabled and 12 for disabled if my testing is correct - but I am pretty confident that the result will be the same.2. Try not minimising the window and opening the menu before checking. You could use ControlClick or MouseClick (depends on your app which is better suited). Although this is really the same as waiting a bit before testing. ;-)M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
etni3s Posted June 24, 2009 Author Share Posted June 24, 2009 Didn't work, still getting the same results. :|Updated code: http://pastebin.com/m2d3de4e3I think i've found where it goes wrong though..When the script gets to:While $i > 0 ; And $hConnect == 0 And $hDisconnect == 0..It doesn't actually update the values until i manually click the menu. If i let it run through the loops without interaction it doesn't alter the values at all between the runthroughs. It's as if it can't read the values until i open the menu for it. Could be some wierd programming in the client software i'm trying to controll. I guess i could try using the Send command, but it seems like an ugly fix. Maybe there's a way i could read the status of the icons in the toolbar instead? (visible in screenshot)Here's a screenshot of the program if you need it: http://i43.tinypic.com/104gpld.jpg Link to comment Share on other sites More sharing options...
etni3s Posted June 24, 2009 Author Share Posted June 24, 2009 Never mind, I figured out how to do a toolbar test, and it's working now. Thanks for the previous help $hToolbar = ControlGetHandle("[CLASS:Afx:00400000:0]", "", "[CLASSNN:ToolbarWindow321]") $idConnect = _GUICtrlToolbar_IndexToCommand ($hToolbar, 5); Connect button $idDisconnect = _GUICtrlToolbar_IndexToCommand ($hToolbar, 6); Disconnect button $hConnect = _GUICtrlToolbar_IsButtonEnabled($hToolbar, $idConnect); Get connect status $hDisconnect = _GUICtrlToolbar_IsButtonEnabled($hToolbar, $idDisconnect); Get disconnect status Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 24, 2009 Moderators Share Posted June 24, 2009 etni3s,I would go forsome wierd programming in the client software i'm trying to controllThat way it is not our fault!Glad you got it running - I hate unresolved problems.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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