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

This question is for people with programming experience in creating apps, even simple apps. I'm having trouble figuring out where to start, because (as usual) I'm trying to do something non-standard.

I have a multi-Desktop Workspace workflow that I'm working on streamlining, and from all my research, there are no products that seem to easily support what I'm trying to do: have a text name associated with each Desktop Workspace in Mission Control Spaces.

The best solution I have found is to have some app, it could be any app that supports multiple windows, in which I create a window on each Desktop and each app window has a title that is the name of that Desktop. Then bringing that window to the front, selected by its title, automatically changes the Desktop Workspace to the desired Space.

Some apps, like TextEdit, Terminal, and Notes, work a little better than apps like Stickies because TextEdit, Terminal, and Notes will all, upon a reboot, reopen their windows in the original Desktop, where Stickies will reopen all windows in Desktop 1.

Also, I have other uses for Terminal, TextEdit, and Notes. I would prefer a low-overhead app that I can dedicate for this purpose.

So I'm looking to create a minimalist app, one that consists only of a title bar, with no body. That title will name the Desktop that it's in. I'm getting lost in the doc of various systems for creating apps because they are all about what the app will do, and I don't care for it to do anything. If it has to do something, displaying the text of its title would be enough.

Better would be if the underlying framework supporting this minimalist app were able to automatically provide the reboot robustness such that all open windows would reopen in their original Desktop. But I don't see that addressed in tutorials on "Hello World" or in the feature lists or in the indexes to the reference doc for any simple app-making systems. It's simply ignored as a relevant issue. Desktop Workspaces seem to be a Cinderella in MacOS, a beautiful, forgotten stepchild left behind to do the drudge work. So I'm resigned to having to experiment to find out if it works, if I can get the simple titlebar app working on some framework or another.

AppleScript appears to not be able to create a window of its own, even if a script can be saved as an app for other intents and purposes. It seems to only open windows for other apps.

I don't want to get into Objective-C or Swift, if I can help it, because they are for building complex apps and there appears to be way too much set up and configuration required to get any kind of app started in either of those systems.

How about Node.js? I've never used it, but descriptions sound like it could be in the right direction. Could it make a simple app window that consists of only a titlebar. And do that multiple times so that they could be moved to different Desktop Workspaces?

Are there other simple app frameworks that I should be looking at?

Thanks for ideas.

Could you use a set of Custom HTML Prompt windows?

Ah, I really don't understand much about this, but in my experience KM palettes always stay where you put them. Palettes can open automatically with an app on a particular desktop or screen. They can be minimalistic, and have a title.

Hmm. Could the windows be left open and then moved and resized like any other app window? More importantly, can they be listed?


I'm not sure how you want to list them, but presumably.

I would like to present them in a Prompt With List menu and then, when any particular item is chosen, activate the corresponding window, which would switch to the Desktop Workspace containing that window.

I'd also like to be able to query which window was visible on the current desktop.

Well, presuming there are a fixed number of them, each could have a specific ID associated with them, which you could use in your Prompt With List macro to activate them.

Whether that activates the Desktop, I don't know, that’s an Apple spaces issue.

As for which is visible in the current desktop, I'm not sure about that either. There are no Spaces public APIs, so generally you can't do such things directly, you can only do them indirectly. Probably it is possible.

That is exactly what I'm trying to do here, have an identifying window on each Desktop Workspace so that when that window is activated, the display changes to the appropriate Space that contains the identifying window.

This Forum Q&A seems to address the issue:

In the situation we're considering here, you're suggesting a set of Custom HTML Prompt windows, so I presume those would all be KBM-owned windows, right?

When I use KBM to run an AppleScript and display the results in a window, it gets the title "Keyboard Maestro - AppleScript Results".


But when I leave that window open and run a script like the one from Chris Stone in:

then those KBM-results windows are not listed as being windows active in the current desktop, even though they are "always on top" as well.

I've never used Custom HTML Prompt unless it was part of someone else's shared macro package. I'll experiment, eventually, to see if it might work for what I'm trying to do here. Meanwhile, if anyone else knows that Custom HTML Prompt windows are indeed listable by System Events in an AppleScript, that would help move my question forward.


That's because Chris's script lists windows belonging to application processes whose background only is false -- the KM "Display" windows belong to the Keyboard Maestro Engine, whose background only is true.

A quick test shows that Custom HTML Prompts also belong to KM Engine, and can be listed with eg:

tell application "System Events"
	tell application process "Keyboard Maestro Engine"
		return every window
	end tell
end tell
1 Like

@Nige_S is correct.

I have amended the post @August cites above to make this clear.

How to List All Open Windows on a Desktop - #2 by ccstone

1 Like

Thanks @Nige_S and @ccstone,

That's very helpful. With your help I'm learning a lot of AppleScript subtleties that the tutorials that I've seen don't touch.

A quick test of @Nige_S's script above shows that an AppleScript results window is displayed with the title bar saying, "Keyboard Maestro - AppleScript Results" while the script to list KBM windows produces the line:

window Keyboard Maestro - AppleScript Results of application process Keyboard Maestro Engine

Keep in mind that @Nige_S' script in post #11 returns window objects to AppleScript.

It is not intended to create a proper report but is a demonstration of how to get the window objects from which a report would be generated.

That explains the mismatch between the window title and what is displayed by the script. Printing the script results prints what is printable of the window data. The Title needs to be explicitly extracted from that data to be printed properly.


It's AppleScript, (in)famous for being "write what you'd say" -- if you can get a list of window objects with every window and each window object has a name property, IRL you'd say "tell me the name of every window". Sure enough:

tell application "System Events"
	tell application process "Keyboard Maestro Engine"
		return name of every window
	end tell
end tell

(OK, so that doesn't work all the time! But it does work often enough that it's worth a try before digging into the documentation.)

Again, that'll get you a list object. You'll need to process further in AS to get text that KM can easily use. I daren't suggest how because I've lost track of what you're aiming for!

Well, you opened the can of worms with that comment.

The overall point is to create minimalist windows that have titles that can be listed.

I'm exploring this subthread because Peter suggested that the Custom HTML Prompt action could be used, but I had initial trouble listing those windows because, being owned by the KBM Engine, they were overlooked because the Engine was "background only". Your help in this subthread seems to have handled that.

To complete that idea, I still need to try creating Custom HTML Prompt windows, giving them custom titles, and listing them as you just described, to fully test this option.

The larger context of why I want the minimalist windows is to use them as Desktop Workspace Identifiers (DTWSID) to put one on every Desktop Workspace so there is a text name that stays with the Desktop even if I rearrange their order in Mission Control, or even if Mission Control gets set to rearrange them automatically. I have multiple threads I am exploring to see how I might be able to make useful DTWSIDs.

Listing all those app windows' titles gives me a list of Desktop Workspace names so that, simply by activating that named window, I switch to that desired Desktop as the active Desktop Workspace.

This minimalist window approach is one route I am exploring. I am also looking at having a floating Notes window on each Desktop, a TextEdit window, and a couple of other free apps that have been around for years, Text Do and Folding Text, or maybe a flexible combination of all of them at once.

The key is that Text Do and Folding Text also behave like Notes and TextEdit when rebooting (if I don't close the app first), they reopen all their previous windows in their original desktops. (I had previously tried Stickies, but Stickies reopen all in the first desktop and having to move 20 Stickies to their respective Desktops repeatedly, quickly became annoying.) I don't know yet if KBM's Custom HTML Prompt can be made to work like this.

All this is because I have become addicted to named Desktops and I see repeatedly in various Stack Exchange and Apple forums that many people are as chronically dissatisfied as I am with Apple's lack of support for Desktops. I would love to be able to recommend my solution. But I can't.

I have been able to name my desktops by using CurrentKey, which I have learned uses this same approach as I have outlined above, he hides a thin app window behind the Menu Bar with a window title that is the name of the desktop and then activates that window to change desktops. But CurrentKey has been withdrawn for various reasons. So I can't offer it as a solution.

I've been exploring the question of whether I could imitate the named desktop switching of CurrentKey by using KBM and AppleScript, etc. So far, the answer is that it is not impossible.

That's a handy cut-out-and-keep reminder of what you're trying to do, but I was actually being more specific -- what's your aim with the AppleScript? That will determine what (if anything) you need to return to KM, which will determine how you process the list object.

Two obvious examples -- you want to know if a particular window is present, or you want a list of windows to iterate through.

For the first:

set inst to system attribute "KMINSTANCE"
tell application "Keyboard Maestro Engine"
    set winName to getvariable "Local_winName" instance inst
end tell

tell application "System Events"
    tell application process "Keyboard Maestro Engine"
        if name of every window contains winName then
            return 1
            return 0
        end if
    end tell
end tell

And for the second:

tell application "System Events"
    tell application process "Keyboard Maestro Engine"
        set AppleScript's text item delimiters to return
        return (name of every window) as text
    end tell
end tell

Thanks for being an interested listener. It gets clearer and simpler every time I tell it.