I am trying to write a AppleScript which will move my active app window to second display in full screen mode. In order to do this I am looking for a way to:
-
Target a selected application. Doesn't matter whether it is Firefox, Spotify or Calendar.
-
Move selected app to second display.
-
Display selected app in full-screen view.
I am struggling to find a way how to target selected/active app/app window. Any idea? I am running macOS High Sierra.
Best Answer
The information you need in order to work through your project are in those other threads:
1) Applescript to click green (zoom) button with Option down
---> You can find there (^) how to fullscreen a window (or only maximise it)
2) Retrieve the screen's resolution of a window [which screen is used?]
---> Information on how size and position are defined on (different) screens
If you start this script (or app) from Editor or Apple's -used-items-menu you will need lines 2 & 3.
Otherwise, e.g. called by a shortcut, they must be deleted.
ANYWAY: Better test this script with a new empty window!
Your script might look like this:
I do not use a secondary screen myself, so I can only deduce this code from source 2).
Please take care to use EITHER [1.] OR [2.] … if BOTH are called, funny things may happen …
(Be aware that fullscreen mode temporarily "creates" an additional work space.)
You might want to test behaviour with "AXZoomWindow" instead of "AXPress".
Please post your experience(s) and/or problems with this code here !!!