How can I detect an inactive (grey-ed out) menu?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
BridgeScore
Newbie
Posts: 14
Joined: Sun Feb 26, 2006 3:55 pm
Location: Florida
Contact:

How can I detect an inactive (grey-ed out) menu?

Post by BridgeScore » Mon Mar 06, 2006 10:35 pm

I have been using a particular menu in the application I am writing a macro for. I just discovered that in some instances the menu item is inactive. I need to do something to cover that situation. Is there a way to detect if the menu item is inactive (grey-ed out). I am the using keyboard to access the menu item. It is the first menu item in the list. I would prefer not to use a timeout since it slows down the entire process.

press alt
send>v
release alt
press enter

Thanks,
___________________________________
Writing the program is easy
finishing the program is hard

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Mar 06, 2006 11:24 pm

Hi,
One way is to send the alt-v and then set a timeout and wait to see if the desired outcome arises. If not, you know it was greyed out. e.g. if alt-v normally causes a new window to appear you can see if it appears after sending the alt-v. If it doesn't appear within a certain time you know it must have been greyed out because alt-v has had no effect.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

BridgeScore
Newbie
Posts: 14
Joined: Sun Feb 26, 2006 3:55 pm
Location: Florida
Contact:

Post by BridgeScore » Tue Mar 07, 2006 12:29 am

Is ther another way? As I said in my original post I would rather not use a timeout since it slows the entire process.
___________________________________
Writing the program is easy
finishing the program is hard

IanSmith
Junior Coder
Posts: 24
Joined: Tue Jul 12, 2005 2:31 pm

Post by IanSmith » Tue Mar 07, 2006 9:38 am

It will depend on how fast your window will usually open (I've had the same problem in the past).

Let's say your ALT+V window pops up very quickly - you would only need a timeout of one second to spot whether nothing happened; if the button was not greyed out the window will pop up and the script continues. If it was, one second is not too much to wait.

If you are _really_ fast you could have a wwx>0.5, but that might be cutting it fine :)

Take care, Ian

BridgeScore
Newbie
Posts: 14
Joined: Sun Feb 26, 2006 3:55 pm
Location: Florida
Contact:

Post by BridgeScore » Tue Mar 07, 2006 12:51 pm

My problem is that this macro will be used as a compiled version by many poeople on many types of pc's using various operating systems from XP down to win 95. So some of those systems could be quite slow.
___________________________________
Writing the program is easy
finishing the program is hard

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Mar 07, 2006 1:44 pm

Hi,

What type of object is this menu item? It may not even be a standard menu class - most menus these days are custom toolbar objects made to look like menus. Therefore there is not necessarily one single standard API.

Can you use Tools/View System Windows to identify the menu object and tell us what the class name is?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

BridgeScore
Newbie
Posts: 14
Joined: Sun Feb 26, 2006 3:55 pm
Location: Florida
Contact:

Post by BridgeScore » Tue Mar 07, 2006 2:48 pm

These are all the references to the application window form that I can find in View System Windows. I believe that the application is using standard windows gui menus no java code.

Image
___________________________________
Writing the program is easy
finishing the program is hard

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Thu Mar 09, 2006 2:35 pm

Image Recognition!

Use the image recognition add-on to catalog the appearance of the menu when your desired selections are enabled, then compare that with the image of the menu when you are running your app. A disabled menu will certainly produce a different image.

BridgeScore
Newbie
Posts: 14
Joined: Sun Feb 26, 2006 3:55 pm
Location: Florida
Contact:

Post by BridgeScore » Thu Mar 09, 2006 4:39 pm

Good Idea! However it will not work with this macro. Different people will either have it or not. You can not compare with the menu to without the menu unless you have both images. The users all have different resolutions so I can not include examples of the images from my machine because their machine can display the screens and mages differently.

There is no way for me to tell in advance if they will have a greyed-out menu.

I appreciate your input. It is a good idea and I might be able to use it on other macros.

Thanks
___________________________________
Writing the program is easy
finishing the program is hard

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Thu Mar 09, 2006 7:14 pm

the fact that some users will have it and some won't (grey menu) is the reason for using this technique. All you would need to do is capture an example from one system and use that as the baseline. As for resolution, there aren't an unlimited number of settings and it's easy to detect that with MacroScheduler....save a few images, have the script check the resolution (do a mouse move to 4000,4000...then get the mouse coordinates, there's your resolution), then check against the corresponding image.

I still think it could be possible.....

BridgeScore
Newbie
Posts: 14
Joined: Sun Feb 26, 2006 3:55 pm
Location: Florida
Contact:

Post by BridgeScore » Fri Mar 10, 2006 5:30 am

I will take another look at it. The image would have to be a real narrow window. The main window where the menu drops down to will have different text in it each time the application is used. I would have to be real careful not to capture any of the window where the menu drops into. Don't know if I can do that with a bunch of different resolutions. And yes there could be a good number of them. On my laptop I have six different resolution options.

Some of these new graphic cards most likely have more.
___________________________________
Writing the program is easy
finishing the program is hard

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts