Keyboard shortcut for "clicking" on the title in a document window (name, tags, where)?

As near as I can tell, Apple hasn't made it possible to key-shortcut your way to an open document's Name/Tags/Where overlay:


I have found this thread explaining how to make an AppleScript to perform this function...but it's written specifically for Preview.app...and it often doesn't work:


1) Any idea how I fix whatever is causing this error?


2) Is there a way to create such an AppleScript that is universal, so I don't have to create separate ones for every app where I want to be able to hotkey my way to this overlay?

MacBook Pro 13″, macOS 10.13

Posted on Jan 28, 2021 11:21 PM

Reply
Question marked as Top-ranking reply

Posted on Jan 29, 2021 4:02 PM

> 1) Any idea how I fix whatever is causing this error?


Yes, kinda... although the OS should normally prompt you to authorize this the first time any script is run.

In any case, Automator needs to have Automation and Accessibility enabled in System Preferences -> Security & Privacy -> Privacy. That should prevent this from happening.


> 2) Is there a way to create such an AppleScript that is universal, so I don't have to create separate ones for every app where I want to be able to hotkey my way to this overlay?


No, because there is no standard for doing this. In fact, the rules/syntax can even change from one version of the same application to another - for example, the script you reference for Preview.app doesn't work in Big Sur because Preview.app now considers the menu button as part of toolbar 1 so you need another level of indirection.

The only way you could make this work is to have explicit instructions for each application where you want to use it. Then you have to do something like:


	set appName to name of (get application process 1 whose frontmost is true)


so now you know the frontmost app, then:


if appName is "Preview" then
	-- code for Preview.app goes here
else if appName is "TextEdit" then
	-- code for TextEdit.app goes here
else if appName is "SuperDuperApp" then
	-- code for SuperDuper.app goes here
else
	-- etc
end if


but this will only work for as many apps as you add to the if clause. That may be sufficient if you only have a handful of apps you care about.


Ultimately, though, this comes down to the fact that UI scripting (where you write a script to emulate user actions/clicks/keypresses/etc.) is a poor way to go about this. If you already need to have application-specific code for each app, then you might as well work out how to directly do what you want (e.g. "save the document in a given location/filename") rather than hacking together what you would do manually.

2 replies
Question marked as Top-ranking reply

Jan 29, 2021 4:02 PM in response to 100 Watt Walrus

> 1) Any idea how I fix whatever is causing this error?


Yes, kinda... although the OS should normally prompt you to authorize this the first time any script is run.

In any case, Automator needs to have Automation and Accessibility enabled in System Preferences -> Security & Privacy -> Privacy. That should prevent this from happening.


> 2) Is there a way to create such an AppleScript that is universal, so I don't have to create separate ones for every app where I want to be able to hotkey my way to this overlay?


No, because there is no standard for doing this. In fact, the rules/syntax can even change from one version of the same application to another - for example, the script you reference for Preview.app doesn't work in Big Sur because Preview.app now considers the menu button as part of toolbar 1 so you need another level of indirection.

The only way you could make this work is to have explicit instructions for each application where you want to use it. Then you have to do something like:


	set appName to name of (get application process 1 whose frontmost is true)


so now you know the frontmost app, then:


if appName is "Preview" then
	-- code for Preview.app goes here
else if appName is "TextEdit" then
	-- code for TextEdit.app goes here
else if appName is "SuperDuperApp" then
	-- code for SuperDuper.app goes here
else
	-- etc
end if


but this will only work for as many apps as you add to the if clause. That may be sufficient if you only have a handful of apps you care about.


Ultimately, though, this comes down to the fact that UI scripting (where you write a script to emulate user actions/clicks/keypresses/etc.) is a poor way to go about this. If you already need to have application-specific code for each app, then you might as well work out how to directly do what you want (e.g. "save the document in a given location/filename") rather than hacking together what you would do manually.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Keyboard shortcut for "clicking" on the title in a document window (name, tags, where)?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.