0

I am trying to write an applescript for macOS Monterey that moves a window to a different workspace via a keyboard shortcut. To move a window I would need to simulate clicking on that window's title bar and then activate the Mission Control shortcut to switch spaces.

I cannot, however, figure out how to simulate the title bar click. Anyone has any ideas?

tell application "System Events"
    -- click on the frontmost window's title bar and hold
    key down {option}
    key code window_number_code
    key up {option}
    -- release hold
end tell
EuxhenH
  • 161
  • 1
  • 4
  • 2
    I gave up on using Spaces, only using 1 space per monitor. You can try https://github.com/BlueM/cliclick to simulate clicks. – user3579815 Feb 11 '22 at 06:56
  • Coming from Linux, I've found the rudimentary multi-workspace support in macOS surprising. Currently using [Keyboard Maestro](https://www.keyboardmaestro.com/main/) to simulate the title bar click and Mission Control shortcut and it works well enough if you would be satisfied with an off-the-shelf solution. – Nel Sep 03 '22 at 12:12

0 Answers0