What I was trying to do was use a script to voice control window switching. Here’s how without a script: if you have voice recognition installed, turn it on. When you click to open a file, leave it highlighted and say “make this speakable”. Do this with multiple files. These items can now be opened or called to the frontwindow by saying their file names. You can further customize by going to the speakable items folder, and give each file a name easy to call.“Presentation one” is easier than “breakdancer.mpg”. So if you have four movie windows open, you will be able to call any of these windows to the front by voice. I get the feeling I’m like, 5 years behind the times here, but hey, ya gotta start somewhere!
Generally speaking, no. Some apps allow window control but the syntax will vary from one app to the next.
– Rob
Sorry Rob, I started typing this up before lunch and you snuck one in.
There is no general syntax to command windows in all applications, Applescript commands are pretty much specific to the application and it’s own Applescript Dictionary.
If the application is “BTV pro”, from your earlier post, I downloaded a demo and found that while it is scriptable, toggling the windows doesn’t appear to be within the power of it’s Applescript dictionary. It doesn’t even appear to have a keyboard shortcut assigned to it, I think you can only jump to other movies by selecting them from the Window menu.
But, that doesn’t mean you can’t do it with Applescript. You could download Akua Sweets, which is basically a plug-in, or extension, for Applescript that extends your power by adding commands and functionality. Within the list of commands in Akua Sweets, you’ll find a command called “the active menus” which will list everything in an application menu. In our case, BTV helps us out by listing the back-most document at the bottom of the “Window” menu. By using the Akua command you can list the “Window” menu and get the number of items in that menu. Then, get the text of the last item in that menu, (name of the movie you want to bring to the front), and use it to open it.
There are a few catches though, you can only open files in BTV by defining a path to the movie. So for this to work, your movies will have to all be in the same place. And, Akua Sweets is not free.
Here is the code. You can compile it as an application and drop it in your speakable items folder to get the speech triggered app you wanted.
(*This is the path to the folder that houses all your movies.
If your movies are scattered about, this script will not work
as you need a path to the file in order to open the movie
which is how we bring the movie to the front
Replace with the path to your folder*)
property sourceFolder : "Mac HD:Desktop Folder:Movies:"
tell application "BTV Pro"
activate --you don't have to activate, it is up to you
--akua sweets provides the active menus command
set listWindowMenu to the active menus named "Window"
--get the count of menu items
set btvMenuItems to the count of items in item 2 of item 1 of listWindowMenu
--this should be the movie that is last in the order of window's, according to the BTV "Window" menu
set pathOfLastMovie to sourceFolder & item btvMenuItems of item 2 of item 1 of listWindowMenu as string
open alias pathOfLastMovie --open the path to the back-most file
end tell
Best of luck,