AppleScript to open new window for any app

Hi everyone, I’m trying to write an generic AppleScript that opens a new window for a specified app (passed in as an argument via Alfred/Raycast/KM). Can someone please guide me on this.

I could only figure out specific scripts as I don’t use AppleScript that much.

tell application "System Events"
	tell process "Things3"
		click menu item "New Things Window" of menu "File" of menu bar 1
	end tell
end tell

Is Cmd+N good enough for you?

FYI, Things uses Ctrl+Cmd+N, not just Cmd+N. As apparently there is no “standard” way to do this, I doubt there is a way to write a generic Apple Script, but I’ve no thought hard about this.

1 Like

Are you determined to us AppleScript? Since you have KM, it might be easier to skip AS and use KM directly with the “Select or Show a Menu Item” action set to the Frontmost App:

You could get fancy and allow for apps whose menu items are slightly different, like Things (I don’t have it to test). For example, KM itself has “New Editor Window” so you could use an If action to check that menu item exists, or even what its state is. You could even use regex to select an item that starts with “New” and ends with “Window”

You get the idea.

If you have KM, this is the way.


I understand Cmd+N is not totally standard - but there can’t be many variants. You could well build switches based on the app names.

Further to that - and perhaps to make it more attractive - you could make your Keyboard Maestro macro or Applescript script add value when opening - such as positioning or running an initial macro.

Quite attractive to me - though i don’t really have a need for it.

1 Like