I’ve searched and searhced, and hopefully this is really simple, but is there a way to get the name of the frontmost window in an app and set it to a variable as text? Thanks so much.
Hi,
something like this
set FrontWindow to name of front window of current application
PS: but I’m worrying that it doesn’t work with every application
Can you specify a different application than the current one? I tried:
set FrontWindow to name of front window of application “Pro Tools Academic” but I get the following error:
Pro Tools Academic got an error: Can’t get title of window 1.
Any way to do this? Thanks.
I don’t use ProTools so I can’t test this
set FrontWindow to title of front window of application "Pro Tools Academic"
Has ProTools a dictionary? If yes, read the properties of “Window”
Yeah, I tried that, no dice. Pro Tools is completely not Applescriptable. Oh well. I though maybe there was a generic way to do it. Thanks.
Ok I think I got it. I tested this with Firefox and it worked fine, but it could be different for whatever app your using.
tell application "Finder"
set FrontWindow to (name of window of process "Pro Tools Academic") as string
end tell
set FrontWindow1 to text 1 thru -14 of FrontWindow
return FrontWindow1
Hmm. I tried that in Safari and Pro Tools, even Script Editor, and it didn’t work. It seems to return “”
“Can’t get text 1 thru -14 of “”.”
tell application “Finder”
set FrontWindow to (name of window of process “Script Editor”) as string
end tell
set FrontWindow1 to text 1 thru -14 of FrontWindow
return FrontWindow1
This didn’t work either. Any other ideas? I feel like we’re getting close.
just try this then, maybe only Firefox gave the weird extra parameter I had to cut out
tell application "Finder"
set FrontWindow to (name of window of process "Pro Tools Academic") as string
end tell
I’m still only getting “” as a return. Pro Tools has a lot of floating windows, so perhaps what actually is the front window doesn’t have a name? Are there any extras packages that might be able to do this? It seems straight Applescript may not be able to get this info from Pro Tools. Thanks for all the help.
hmmm…this maybe?
tell application "Finder"
set FrontWindow to (name of front window of process "Pro Tools Academic") as string
end tell
Make sure that Pro Tools Academic is the exact name of the application. If that doesn’t work, then I don’t know because I have tested this on non-applescriptable apps and it works perfectly fine. Maybe instead of this:
set FrontWindow to (name of front window of process "Pro Tools Academic") as string
just try this:
set FrontWindow to (name of front window of process "Pro Tools") as string
Just another suggestion I’m afraid:/
try this:
property docName: ""
tell application "Pro Tools Academic" to copy (the name of the front document) as string to docName
Then do something like:
--display dialog docName
--set the clipboard to docName
--tell application "Finder" to make new folder at (choose folder)) with properties {name:docName}
Greetings, twistit.
Try this:
tell application "System Events" to set allProc to name of every process whose visible is not false and windows is not {}
set myProc to choose from list allProc
tell application "System Events" to get name of window 1 of process (myProc as string)
Hope it works,
ief2
Hi,
your script assumes that Pro Tools is scriptable. As far as I know it isn’t at all