I need to write the simplest script - one that switches to the next/previous space exactly the same way as the “Change space” keyboard shortcuts do it.
The API does have a method main_display(), but this is the main monitor, not the monitor where the mouse currently is. Is there a way to get the display number under the cursor?
It would be even better if move_to_space_on_right(), move_to_space_on_left(), etc. APIs were available that directly map to the app functions.
You could just send the hotkeys I guess
%x{osascript -e ‘tell application “System Events” to key code 123 using (control down, shift down)’}
or maybe, depending on how you set your hotkeys
%x{osascript -e ‘tell application “System Events” to key code 123 using (option down, shift down)’}
(123 is left arrow, 124 = right, 125 = down, 126 = up).
Thanks a lot, that was very useful!
I used that to set up “USB Overdrive” to enable desktop switching with the extra mouse buttons on my Logitech mouse. It works a bit more reliably with that Apple script instead of sending a key, especially when dealing with mouse-grabbing apps like NoMachine.
Switching spaces with a mouse button is very convenient for the ones who prefer muggle (non-magic) mice, it would be a nice feature to add to TotalSpaces.
Yes, thanks, we could consider that as a feature.