最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

remote desktop - Nextprevious Space (or Destkop) in macOS programatically avoid using send keys (with Mission Control shortkcut

programmeradmin4浏览0评论

I would like to know if it is possible (with XCode or any other development tool) to make an application that can change to the right or left Space without sending the keyboard shortcut (Ctrl+Left arrow or Ctrl+Right arrow).

The original reason is that I have a Logitech MX Vertical mouse that allows you to assign actions to the buttons, but if I disable the Mission Control keyboard shortcut the options brought by the Logi Options+ application do not work and that's why I wanted to make an application that I could link it to those keyboard shortcuts.

I have deactivated the keyboard shortcuts because from macOS I connect by remote desktop using WindowsApp and it is very good for me to be able to move between the Mac desktop and the remote desktop that I have in full screen. However, if I do not disable the Mission Control keyboard shortcuts (Ctrl + Left arrow, Ctrl + Right arrow and F11), working with Windows is tedious because it changes my desktop instead of moving cursor by words or when I trying to debugging and I press F11 key of Visual Studio).

I would like to know if it is possible (with XCode or any other development tool) to make an application that can change to the right or left Space without sending the keyboard shortcut (Ctrl+Left arrow or Ctrl+Right arrow).

The original reason is that I have a Logitech MX Vertical mouse that allows you to assign actions to the buttons, but if I disable the Mission Control keyboard shortcut the options brought by the Logi Options+ application do not work and that's why I wanted to make an application that I could link it to those keyboard shortcuts.

I have deactivated the keyboard shortcuts because from macOS I connect by remote desktop using WindowsApp and it is very good for me to be able to move between the Mac desktop and the remote desktop that I have in full screen. However, if I do not disable the Mission Control keyboard shortcuts (Ctrl + Left arrow, Ctrl + Right arrow and F11), working with Windows is tedious because it changes my desktop instead of moving cursor by words or when I trying to debugging and I press F11 key of Visual Studio).

Share Improve this question edited 2 days ago HangarRash 15.1k5 gold badges19 silver badges55 bronze badges asked 2 days ago Asier Cayón FranciscoAsier Cayón Francisco 16311 bronze badges 6
  • 1 Can you assign another key like Ctrl-Shift-<= to move to left space? – Philippe Commented 2 days ago
  • I would prefer not to do it, because when I am not using the remote desktop, I do like to have keyboard shortcuts activated to change desktops, since I am used to it. – Asier Cayón Francisco Commented yesterday
  • Another possibility that has occurred to me is that you could try to do one the keyboard shortcuts and another to deactivate them so that, when I press the mouse button, I do three actions: 1. Run the application that activates keyboard access 2. Execute the previous or subsequent 3. Disable keyboard accesses (or leave them as they were at the time they tried to activate). It could even be better a single application that did the three things. – Asier Cayón Francisco Commented yesterday
  • 1 How about modifying the shortcut and using an app that catches Ctrl-<- and sends the modified shortcut so you don't have to get used to the modified shortcut? You can then switch off the app and use the modified shortcut with remote desktop. – Willeke Commented yesterday
  • It's a good idea, but how could you make an application that was always alive in the background? I would like to explore both alternatives, because I also see advantages to keep the original keyboard shortcuts (so I would only have to modify the mouse application without touching the operating system) – Asier Cayón Francisco Commented yesterday
 |  Show 1 more comment

1 Answer 1

Reset to default 0

I found a solution.

First I create next scripts:

LeftSpace.sh

#!/bin/sh

# Enable Keyboard -> Shortcuts -> Mission Control -> Move left/right a space.
/usr/libexec/PlistBuddy -c "Set :AppleSymbolicHotKeys:79:enabled true" ~/Library/Preferences/com.apple.symbolichotkeys.plist
/usr/libexec/PlistBuddy -c "Set :AppleSymbolicHotKeys:81:enabled true" ~/Library/Preferences/com.apple.symbolichotkeys.plist

# Ask the system to read the hotkey plist file and ignore the output. Likely updates an in-memory cache with the new plist values.
defaults read com.apple.symbolichotkeys.plist > /dev/null

# Run reactivateSettings to apply the updated settings.
/System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u

# Move to right Space
osascript -e 'tell application "System Events" to key code 123 using control down'

# Disable Keyboard -> Shortcuts -> Mission Control -> Move left/right a space.
/usr/libexec/PlistBuddy -c "Set :AppleSymbolicHotKeys:79:enabled false" ~/Library/Preferences/com.apple.symbolichotkeys.plist
/usr/libexec/PlistBuddy -c "Set :AppleSymbolicHotKeys:81:enabled false" ~/Library/Preferences/com.apple.symbolichotkeys.plist

# Ask the system to read the hotkey plist file and ignore the output. Likely updates an in-memory cache with the new plist values.
defaults read com.apple.symbolichotkeys.plist > /dev/null

# Run reactivateSettings to apply the updated settings.
/System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u

and RightSpace.sh (same code changing key code 123 by key code 124.

Then I tested, being sure that the Apple Script Editor utility has Accessibility permissions. Then I disabled the Key shortcuts of Mission Control and I tested. One it works, I created and App:

  1. Create de folder structure LeftSpace.app/Contents/MacOS
  2. Move the LeftSpace.sh to this folder
  3. Remove the extension of LeftSpace.sh to be LeftSpace
  4. Do the same with RightSpace

And at the end, I add these two applications to Accessibility permissions like I do before with Apple Script Editor.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论