Jump to content

WinMenuSelectItem sometimes works?


cdude
 Share

Recommended Posts

Hi,

I'm new to AutoIt and should start out by saying this is a TOTALLY fantastic scripting application and so far has been amazing.

Anyway, despite my searches in the help and here in the forum, I am still having some beginner issues of which I'd like help with.

I am using the AutoIt COM/ActiveX component from within Excel 2003's VBA. I am attempting to make my Excel Spreadsheet which is full of data control Adobe Premiere Pro 1.5 and automate some complex edits based on my spread sheet.

I have been going back and forth and things generally work, but since Premiere has context sensitive keyboard shortcuts, the right window has to be active for the keyboard functions I am doing to work. And I have to go back and forth between multiple windows in Premiere to complete my task.

So to that end I have Excel VBA / AutoIT controlling Premiere but every now and then the WinMenuSelectItem doesn't work. I understand that if it wasn't a real menu that it wouldn't work, but why would it work sometimes and not others? I am using it to select the &Window > &Project and &Window > &Timeline menu items which should give focus to the right Premiere child windows. It was working fairly solidly and then something changed (not my code) and it stopped working? Memory leak? no idea...??

Anyway, I was using the default Title matching of 1 and was using the title "Adobe Premiere Pro -" and that was working. Then it stopped working for some reason. So I did try Advanced matching mode of 4 and used the title "[TITLE:Adobe Premiere Pro;CLASS:PremierePro;]"

which is what the AutoIT Window Util said. However I've tried every permutation of the title with and without the class and with the full path of the file as in "Adobe Premiere Pro - C:\temp\myproject.prproj *" even with the Asterisk for file changes all to no avail.

Can someone please help me (hopefully without me having to write tons of handle management code) on how to just select a simple menu item from this program?? Because it did work, I know it can - I don't know why the result would return 0 and it not find the menu item? because it is there....

Any ideas for a beginner like me? I tried even activating the Premiere window with WinActivate before the menu select but that didn't help. I'm really at my wits end. I can't figure out why my vba script is rock solid sometimes and out of whack other times (but once it gets out of whack it doesn't right itself...?)..

thanks for any and all help or pointing me to the right information if I missed it in my search.

:-)

Link to comment
Share on other sites

hmmm I'm still going crazy about this... ^_^

This is weird. It started working again and then now is failing sporadically...??

(I assume my problem is not related to the ActiveX issue and just a WinMenuSelectItem issue hence the post in this forum)

My AutoIT/VBA script launches Premiere and starts to do stuff. Obviously as I debug the script I have to keep closing Premiere and not saving the Premiere project I am trying to edit, and then re-running my script to try again. Is it possible that the re-running of this somehow makes WinMenuSelectItem not work because multiple menus are in memory due to a leak in Premiere? I'm grasping at straws here - taskmanager doesn't say that more than one premiere is running...?

Any ideas are totally appreciated. Thanks! :)

Link to comment
Share on other sites

Sounds like the issue is that there are multiple windows, one of which might not have the same menus.

See if you can find unique text on the one you need, or try different instances.

If not text, what about unique controls?

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Link to comment
Share on other sites

Thanks for your reply. :)

If there are multiple windows it must be one of the child (MDI?) windows of Premiere inside it...? I'm not sure how to detect the unique text? I thought I tried using the filename as part of the text, but I'll try again. Can you clarify what you mean about unique controls? How could I use controls to determine which menu to select?

Sounds like the issue is that there are multiple windows, one of which might not have the same menus.

See if you can find unique text on the one you need, or try different instances.

If not text, what about unique controls?

Link to comment
Share on other sites

I don't have Premiere, so I can't say for sure.

If the AutoIt Window Info isn't specific enough, see what controls exist with WinGetClassList.

Usually the Parent window has menus, toolbars, etc... while the child windows have the

One other thing to try would be to ignore child windows:

Opt("WinSearchChildren",   0)       ;0=no, 1=search children also

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Link to comment
Share on other sites

I don't have Premiere, so I can't say for sure.

If the AutoIt Window Info isn't specific enough, see what controls exist with WinGetClassList.

Usually the Parent window has menus, toolbars, etc... while the child windows have the

One other thing to try would be to ignore child windows:

Opt("WinSearchChildren",   0)       ;0=no, 1=search children also

Thanks I'll try that. :)

I use ControlFocus ("Some Title", "", "Some Control") before WinMenuSelectItem() because menu items in my automatized application are enabled only if that control has focus.

You may also try cycle:

While Not WinMenuSelectItem(...)

Sleep(250)

WEnd

I never thought of doing a loop like that... I'd need a timeout in case its infinite or something. But that's a good idea to try the Control Focus... I use that for all the track headers in Premiere and it works great as the only way to rename a video track in Premiere is to right click it. For those controls ControlFocus and ControlSend/Click work great. Though what do I send the ControlFocus to for the Menu? AutoIt window tool doesn't show anything when I mouseover the menus - the control tab with all the info is blank when I go over the Menu items...?

or is that what I should use WinGetClassList for as Skruge said above? Thanks again to both of you for your help!

Link to comment
Share on other sites

I never thought of doing a loop like that... I'd need a timeout in case its infinite or something. But that's a good idea to try the Control Focus... I use that for all the track headers in Premiere and it works great as the only way to rename a video track in Premiere is to right click it. For those controls ControlFocus and ControlSend/Click work great. Though what do I send the ControlFocus to for the Menu? AutoIt window tool doesn't show anything when I mouseover the menus - the control tab with all the info is blank when I go over the Menu items...?

or is that what I should use WinGetClassList for as Skruge said above? Thanks again to both of you for your help!

ControlFocus is not meant for menu control. It's only for case when your menu is enabled if some other control has focus. Then make ControlFocus on this control first.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...