Click relative to named window?

So, maybe this has been covered elsewhere (I’ve searched the forums and the wiki and not found much, though). In QuickKeys, you can click relative to a window whose name is/contains text. This is super handy! Sometimes I have multiple documents open that all have similar toolbars to click, so ‘relative to found image’ doesn’t really work. Is there any way to click relative to a named window?

You could make the window whose title contains text X frontmost, and then click relative to the frontmost window:

[test] Click Relative to Window with Title X.kmmacros (3.0 KB)

You could also try an "If Then/Else" action with a front window title condition that is or contains the text you want (optionally adding an application condition for greater precision) followed by clicking the mouse relative to that window.

What if the windows I would like to click relative to are floating windows? For example, Pro Tools has numerous audio plugins, and while the window titlebar themselves only say ‘AudioSuite,’ QuickKeys will actually recognize them as “AudioSuite: PluginName” (where PluginName is the name of the plugin). I’m not sure how telling a floating window to become the ‘front’ window would actually work, since they’re always above everything else.

If that's the case, I can think of two possible solutions. Assuming the location of these windows is static, the first is to forget about the front window and just have the mouse click relative to the main screen.

Another would be to try GUI scripting with an Execute AppleScript action. This solution is more complex, and would probably require UI Browser to find just the element you want to click, but it would definitely be more reliable than relative mouse clicks.

Just to make sure: is clicking the only way to access the actions you want to automate, or are they also accessible by, say, menus, keyboard shortcuts, or "regular" (i.e. non-GUI) scripting?

Yeah, sadly they’re not static positions at all (otherwise I’d just use screen position), and there’s no other avenue for interfacing with them aside from clicking - hence wanting to use quickeys or preferably keyboard maestro! Ideally without any plugin actions or anything, as these might need to be passed around to other editors on other computers to use.

In that case, I suspect that GUI scripting may be your only solution. As far as I know (which, to be fair, is not nearly as much as some of the other posters here) that should work fine once you’ve figured out how to specify which elements of which windows you want to click via AppleScript (again, you will almost certainly need UI Browser for this), and the resulting macros should be shareable with other editors as-is.

@mushoo, see this tool to help you identify the windows:

1 Like

For the GUI-scripting route @JMichaelTX has pointed you to a good thread. For starters I would try this simple script (execute it in Script Editor, replace “Preview” with the name of your application):

tell application "System Events"
  tell application process "Preview"
    every window
  end tell
end tell

Turn on the Result view of Script Editor. I you are lucky you see something like this:

If the floating windows are seen by System Events they should appear in the Result view. If not, try every UI element instead of every window.

@mushoo
iam also using protools and looking for a way to access audiosuite plugin (render and preset) buttons.
are you willing to share how you finally achieve this task?
appreciate your feedback.
thanks! johannes