Jump to content
Sign in to follow this  
etni3s

Menubar/Toobar test

Recommended Posts

etni3s

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.

Share this post


Link to post
Share on other sites
Melba23

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
etni3s

Thanks for the warm welcome and help, but I've run into a new problem now :D

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

Share this post


Link to post
Share on other sites
Melba23

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
etni3s

Didn't work, still getting the same results. :|

Updated code: http://pastebin.com/m2d3de4e3

I 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. :D

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

Share this post


Link to post
Share on other sites
etni3s

Never mind, I figured out how to do a toolbar test, and it's working now. Thanks for the previous help :D

$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

Share this post


Link to post
Share on other sites
Melba23

etni3s,

I would go for

some wierd programming in the client software i'm trying to controll

That 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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×