How to Bring Floating Window Only (Not the App) to the Front

Preamble: I don’t think that you would need to have or even know Scrivener to answer this question. It could apply to many other apps with floating and non floating windows.

Using Scrivener, I created (or rather, the moderator in the Scrivener forum helped me create) a utility which allows me to take notes on the fly when I am in other apps. The utility is basically a custom make Scrivener file which is a floating window. It is very useful.

My last step was to use Keyboard Maestro to open / close the Scrivener utility using bring to the front and hide window actions and a global keyboard shortcut.

My problem is that when I bring the floating window to the front, the floating utility window does come to the front which is great, but also the Scrivener app with all its active tabs.
According to a keyboard maestro forum moderator and expert (he is brilliant - ccstone) this is not possible using keyboard maestro.

I was wondering if the problem could be solved using an appleScript to show the Scrivener floating window with the name “Scratchpad based on Amber” to the front without showing the Scrivener app itself?

Thank you very much for your time and help

I don’t have Scrivener, so I can’t tell you if something like this will work with it, but I can raise a particular BBEdit window (in this case, named “”) without bringing the others forward with this AppleScript:

tell application "System Events"
	tell process "BBEdit"
		click menu item "" of menu "Window" of menu bar 1
	end tell
end tell

You might be able to adapt this for Scrivener if it has a menu with a list of all the windows. Good luck!

1 Like

thank you very much for your reply and taking the time to write a script.

I am used to keyboard maestro where it is possible to specify window with title containing … instead of window name is …

In Scrivener this is important because the actual window name changes depending on which document is open in that window (windows contain a multitude of documents). A suffix is added to the window name depending on which document is active.

Is it possible to edit the script to say

click menu item WITH TITLE CONTAINING "" of menu "Window" of menu bar 1

thanks again very much

You can do it with a little more work (again, I’m testing on BBEdit—this may not work on Scrivener). You have to get all the items in the Window menu and then loop through them to see if they contain the string of interest. Like this:

tell application "System Events"
	tell process "BBEdit"
		set mItems to every menu item of menu "Window" of menu bar 1
		set mItems to reverse of mItems
		repeat with m in mItems
			if name of m contains "post" then
				click m
				exit repeat
			end if
		end repeat
	end tell
end tell

The line that reverses the mItems list isn’t necessary, but it speeds up the script. BBEdit’s Window menu starts with a bunch of window manipulation commands and has the names of the current windows at the bottom. Reversing the list before we start looping through it means we do fewer comparisons before finding the match.

1 Like

it does not work, but I finally did find a solution using keyboard maestro.
Thank for very much for your help and appreciate the time you spent testing.
Have a nice weekend !

Please share the what you did. I’m sure most people would prefer a Keyboard Maestro-based solution.

1 Like

The “display window” command is simply a keyboard maestro menu action.
To keep the Scrivener floating window on the screen but hide the main Scrivener window which was the problem I was struggling with, I simply add the action at the end of the macro
thanks again