How Can I Create a Series of Minimal App Windows That Only Consist of a Titlebar?

This would be equivalent to:

if the window named winName exists then
        return 1
else
        return 0
end if

which would negate the need to enumerate names of all windows. A more compact version would be:

return (exists the window named winName) as integer
3 Likes

Nice!  :sunglasses:

1 Like

I want a list of windows to use in a Prompt With List menu to pick which window to activate.

BTT can do the following

  • list of all open windows of all apps of the active desktop (and go there)
  • list of all open windows of the front app of the active desktop (and go there)

Problem is that the KM Engine is a background-only app. Can BTT include those windows too?

I do not know. But I just realized that there is another app (AltTab) that can show windows in different contexts, actually better than BTT. And the app is even free. So anyone can try it out. However, it seems to me that KM is not necessary if you just want to go to a specific window. But I probably missed something by not reading everything carefully.

https://alt-tab-macos.netlify.app

KM Engine is scriptable, if i remember rightly, just like KM itself. Have you (or @August) tried to enumerate the windows belonging to KME using an AppleScriptive formulation rather than a GUI scripting one?

Thanks @Frankb, but BTT is not up to the task. The core need here is to list and activate windows in other desktops, to use that activation to change desktops.

Yes @August That's why I pointed to AltTab. With it you can display any window on any desktop or screen - as a list (text) or thumbnail (picture). The selected window then leads to the desktop where the window is. Isn't that exactly what you want or did I completely misunderstand you?

Yes, it sounds like it might be. And free? I will check it out, hopefully soon.

Thanks!

Welcome. This, for example, is the thumbnail view. For each window in the top right corner you can see the desktop where the window is. "Ohne Titel 2" is on desktop 3, "The New York Times" is on desktop 1. You see these windows from each desktop and can switch to each desktop by selecting the window.

Thanks. I installed it. I think it will be a useful tool, but it does not solve my issue, quite. It presents two kinds of lists, that I can see, either all windows or all windows from the current app. What is included in "all windows" can also be limited by blacklising.

Your sample display of the window menu has four windows. The Alt-Tab Introduction doc has an image with three windows. Why would you need a special app for so few windows, unless it's simply to see what's behind. But swiping up on the trackpad or ⌃⇧ will do that with Mission Control, at least for the current desktop.

I have 21 desktops and somewhere over 80 windows. Alt-Tab's default layout showed me thumbnails of my windows in 16 rows, four rows at a time, four to six thumbnails per row. It took a lot of scrolling to get through all those thumbnails. I could just show the titles (which get truncated, not shown in multiple textrows) and leaving out the thumbnails, but the lack of sorting makes that still very awkward. Unfortunately, it's display scrolling the 16 rows is a bit choppy. Maybe I can write up a bug report for the developers.

Worse, there are no options to be able to sort the windows. Sorting by parent app, Desktop Workspace, name, most recently used would all be useful options. Maybe I can write up a feature request.

You are right, it does look like it could be made to do what I want to do. If I limited Alt-Tab to only showing me the windows from some one specific app that I dedicate to use as my Desktop Workspace Identifier (DTWSID) (that's what this thread is about) and instead of just having titles, those windows displayed graphics or at least large fonts and were filled with text big enough to read in the thumbnails, then I could use it to switch between my 21 desktops pretty easily.

But there are two very important drawbacks.

First, I'd have to give up the All Windows mode of Alt-Tab and it looks like it's way too useful a tool to dedicate to that narrow function. I am very glad to learn about it and I expect to use it a lot. Thank you.

Second, to use it I would have to go through the Display-Locate-Point-Click cycle instead of just typing a hotkey. It's hotkey speed, with a menu available if I forget, that I'm after.

Compared. to those two, the lack of sorting is a distant third place as an obstacle.

So I won't be using Alt-Tab to solve my desktop switching hotkey menu problem, but I will be using it. Again, thanks for the referral.

I am also delighted to see that Alt-Tab is open source. Maybe I can find out how they are able to list all the windows along with the Desktop Workspace numbers and work from there.

Ok, I see what you mean and that you need special features for so many desktops. The developer (team) is quite active. He publishes updates continuously. If I were you I would just ask him if he can help you with additional features.

PS: I don't know... but you might want to take a look at "Witch". It seems to be better organized. There it says

"Witch lets you access all of your windows in all Spaces by pressing a shortcut and choosing from a clearly arranged list of window titles. You can also see an optional window preview before switching windows."

I was saving that for after we'd iterated through the original System Events version :wink:

But no time like the present! @August -- you should be able to pull something from this example. It spawns a bunch of HTML prompts (then waits a moment coz the Prompt actions are async -- you shouldn't need to do that in your production version) then collects both window IDs and names so you can "Prompt With List" showing "friendly" items but still reference by window ID in the AppleScript. Final action will close any of the prompts you selected from the list -- multiples are allowed.

(I'm getting an extra, empty, paragraph for the final repeat which I couldn't be bothered to troubleshoot properly -- checking for > 0 is a quick kludge round that.)

HTML Prompt Windows Test.kmmacros (6.8 KB)

Image

2 Likes

That's from the final return character that terminates your output string. Easily fixed:

set my text item delimiters to linefeed

tell app "Keyboard Maestro Engine" to tell the ¬
		the (a reference to every window) to ¬ 
		set [winIDs, winList] to the [id, name]

tell a reference to winList to repeat with x in it
		tell x to set its contents to the contents ¬
				of [integer 1 in winIDs, tab, it]
		set integer 1 in winIDs to null
end repeat

return winList as text

Shoukd produce a list formatted as text like so:

12	All Our Base Are Belong To Us
15	Common sense does not exist
27	(1 – 1 + 1 – 1 + 1 – 1 + 1 – ...)
                     .
                     .
                     .
1 Like

Thanks. I will.

I've never tried Alt-Tab, but I do have Witch and Contexts, and I personally much prefer the latter, so I'd suggest giving that a shot, too.

1 Like

Thanks. I'll take a look.

Which I still haven't had time to explore. I intend to ...

This thread has gotten sidetracked into some very useful discussions of how to list and choose windows, but it started out being about how to create a minimal window, one that consisted of a titlebar only.

I tried try creating a minimal window with Custom HTML Prompt, stripping the HTML down to this:
image

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8" />
	<title>Custom HTML Prompt Example Testing</title>
	<style type="text/css"> 
body {
    max-height: 10px;
    margin: 0;
}
	</style> 
</head>
<body>
</body>
</html>

But that gave me a window 215 px high (approx).
image

I can't seem to get the window any shorter. Even with some JavaScript on a W3C window resize test page, I could not get any window shorter than about 150 px, even if specified 50 px.

What I asked for in the OP (admittedly not very clearly) is a window that consists only of a titlebar, about 20-22 px high.

This would allow me to position the window behind the status bar so that when I type the hotkey for it and it becomes the front window, changing Desktops in the process, it won't matter if it's theoretically in front of other windows because it won't be visible.

Is there an HTML setting that will make the body disappear? If not, then maybe using Custom HTML Prompt is not the answer.

Is this going to take Objective-C, or what? Can AppleScript somehow make a window 22px high? Can JavaScript?