###How to Move & Resize Script Editor Window on App Startup?
Script Editor always open a new blank window the same size and same location when the app starts. It’s a small window located in the left side of monitor 1 (I have two 27-in monitors).
How can I move this window to the active monitor (as defined by which one is showing the Apple menu enabled), and resize it, when the app starts? If you need more details, I’d be happy with just centering the window, after resize, in the active screen.
I haven’t done any KM windows marcos, but I’ve noticed several of you that seem to have developed a real expertise in this. I’m hoping to get your help.
You don’t have to build the macro for me, just point me in the right direction.
Search the forum for “position window” – there’re a bunch of related threads.
I just have 1 monitor these days, so I can’t test.
I believe you can refer to the menued monitor as SCREEN MAIN or 1, so this shouldn’t be too hard to manage with Keyboard Maestro.
On the other hand I would just use AppleScript and intercept ⌘N:
tell application "Script Editor"
set newDoc to make new document
tell newDoc's window to set its bounds to {0, 23, 1040, 1196}
end tell
In general this method is a little faster and smoother than Keyboard Maestro’s move & resize.
AppleScript does not treat screens separately. It considers all screens to be one big desktop area, so you’ll need to position your script document where you want it and get bounds to produce the proper coordinates.
It’s kind of shameful that you cannot set the JavaScript/AppleScript property of the document with AppleScript or a menu action.
You can do this using the System Keyboard Preferences, and the pop-up menu items will see the added keyboard shortcuts.
Pause Until – the front window name contains “untitled” then run AppleScript:
tell application "Script Editor"
tell front window
if its bounds ≠ {0, 23, 1040, 1196} then
set its bounds to {0, 23, 1040, 1196}
end if
end tell
end tell