Selectmenu not working properly?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
McFrede
Newbie
Posts: 10
Joined: Fri Dec 03, 2004 2:24 pm
Location: Denmark
Contact:

Selectmenu not working properly?

Post by McFrede » Fri Dec 03, 2004 2:27 pm

Hi all,

I cannot seem to get the SelectMenu> command to work, not even with notepad as in the example given.
Anyone who can confirm this, or tell me what I am doing wrong.
Examples are welcome.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Fri Dec 03, 2004 2:32 pm

The example in the help file works fine for me. Remember that this will only work with standard menu objects. Unfortunately many applications these days have menus that aren't really menus at all but custom objects that look and behave like menus but don't have the same underlying structure.

However, Notepad uses a bog-standard Windows menu bar so the example works fine.
MJT Net Support
[email protected]

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Fri Dec 03, 2004 5:05 pm

I think that I am able to duplicate problem from McFrede

I tried the SelectMenu command in TextPad, MacroScheduler, Notepad, and Wiindows Explore (98ME). It only worked in Notepad. All program windows were open, and work fine manually.
//Should be TextPad MainMenu, File,Open. - NG
SetFocus>TextPad*
SelectMenu>TextPad*,0,1

//Should be MacroScheduler MainMenu, File,New Macro. - NG
SetFocus>Macro Scheduler*
SelectMenu>Macro Scheduler*,0,0

//Modified Sample from Help - Notepad, Main Menu, File, SaveAs. - OK
SetFocus>Notepad*
SelectMenu>Notepad*,0,3

//Should be Windows Explore MainMenu, View, Large Icons. - NG
SetFocus>Windows*
SelectMenu>Windows*,2,3
I chose programs that I thought would be using standard Windows menus.
What am I missing here? :?:
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Fri Dec 03, 2004 5:28 pm

Only Notepad is using a standard windows menu object.

But I don't think you have duplicated the OPs problem because McFrede said he couldn't get it to work in Notepad. And you can.
MJT Net Support
[email protected]

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Fri Dec 03, 2004 5:29 pm

The simplest solution is to use age-old tried-and-tested ALT keystrokes:

SetFocus>WindowTitle
Press ALT
Send>fx etc
Release ALT

This will work with any type of menu.
MJT Net Support
[email protected]

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Fri Dec 03, 2004 5:37 pm

I understand the old tried and true,
But now am curious about the new.
--------------------
Windows Explore does not use standard windows menus?
Macro Scheduler does not use standard windows menus?

How does one determine if standard windows menus are being used?
Is that the purpose of SelectMenu?
If it works, then the program has standard menus, and if it fails, then it does not? (That was rhetorical.....ha, ha). :wink:

We are getting into areas that I am not familiar with, but are we talking about which APIs the developers use in their source code?
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Fri Dec 03, 2004 6:41 pm

Standard menus are handled by the system. They are system objects. The visible portion of a system menu is a window owned and handled by the system. They have their own set of APIs, such as GetMenu and GetSubMenu and respond to messages such as WM_COMMAND.

However, many modern apps have their own custom 'menu' objects. Often a menu bar is really just a set of buttons drawn to look like menus and therefore have completely separate propriotary handlers. Therefore they aren't exposed by the system menu APIs and don't respond to the same messages.

Macro Scheduler's SelectMenu command uses the system menu APIs and messages. So will only work with windows menu objects such as the one in Notepad.

There is no way we can make a command that will work with all objects that appear to humans as menus. In the same way that the PushButton command can only push standard system button objects. It is impossible to know about every possible object that has ever been created or is yet to be created. That of course is why we have Macro Scheduler in the first place - because often the only way to automate an application is by simulating a user. This is the only thing that IS always the same.

To determine whether or not an app has a regular standard menu you could use something like Microsoft's Spy++ or in fact as you say, use SelectMenu. If SelectMenu works it is a proper system menu. If it doesn't it isn't. Don't be surprised if you find most apps these days do NOT use regular system menus.
MJT Net Support
[email protected]

McFrede
Newbie
Posts: 10
Joined: Fri Dec 03, 2004 2:24 pm
Location: Denmark
Contact:

Finally, something works, but not all...

Post by McFrede » Mon Dec 06, 2004 6:51 am

OK, i was posting too quick last time, I actually could get it to work with SelectMenu>, but only some of the menu points, the save as was a definitely no-go. Why is that?

tim167
Newbie
Posts: 13
Joined: Thu Sep 16, 2004 11:38 am

mnu> not working

Post by tim167 » Tue May 24, 2005 11:55 am

I tried to use this command in several applications.
In Cubase for example it seems like the numbering of the menu items is not strictly 0 1 2 3 4 etc..., sometimes it skips from 5 to 8 or something. It's as if there are more menu items in between that you can't see...
I spent some time trying to figure it out but its time consuming and mainly trial and error...Having read this thread I will probably go back to using alt key combinations although I find those less efficient and more sensitive to errors... It would be nice to have a better alternative.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Tue May 24, 2005 12:08 pm

Menu breaks (the horizontal line between items) are items themselves. This could explain why it appears to jump indexes. If you have two items separated by a break then the last item is 2 more than the first. You have to count the breaks.
MJT Net Support
[email protected]

tim167
Newbie
Posts: 13
Joined: Thu Sep 16, 2004 11:38 am

Post by tim167 » Tue May 24, 2005 4:49 pm

Yes I think that was the problem!
I was not counting them because the cursor skips them too.
Thanks!

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