From 410d0a41993402c8d2c5309842696de1c2526176 Mon Sep 17 00:00:00 2001 From: Stephen Nilsen Date: Sat, 9 Sep 2023 14:32:34 -0500 Subject: [PATCH] * Support for AHK 2.0 * Reorganized files * Updated official MacOS shortcut page text * No additional shortcuts were added except Accessability shortcuts which are not intended to be supported * Removed stale note about admin rights being required * Added note about persisting script --- README.md | 27 ++-- FullMacPage.txt => assets/FullMacPage.txt | 72 ++++++++-- .../PowerToys_KeyboardManager.png | Bin PowerToys_Run.png => assets/PowerToys_Run.png | Bin .../PowerToys_User_Download.png | Bin logo.png => assets/logo.png | Bin logo.svg => assets/logo.svg | 0 .../qr_Ko-fiDonate.png | Bin mac.ahk | 131 ++++++++++-------- mac1.1.ahk | 86 ++++++++++++ 10 files changed, 243 insertions(+), 73 deletions(-) rename FullMacPage.txt => assets/FullMacPage.txt (84%) rename PowerToys_KeyboardManager.png => assets/PowerToys_KeyboardManager.png (100%) rename PowerToys_Run.png => assets/PowerToys_Run.png (100%) rename PowerToys_User_Download.png => assets/PowerToys_User_Download.png (100%) rename logo.png => assets/logo.png (100%) rename logo.svg => assets/logo.svg (100%) rename qr_Ko-fiDonate.png => assets/qr_Ko-fiDonate.png (100%) create mode 100644 mac1.1.ahk diff --git a/README.md b/README.md index aad36c4..1bb43d4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MacOS Keyboard Behavior in Windows -![logo.png](logo.png) +![logo.png](assets/logo.png)

This [AutoHotKey script](mac.ahk) seeks to deliver all the **superior** MacOS keyboard behavior you love in Windows! @@ -8,19 +8,23 @@ This [AutoHotKey script](mac.ahk) seeks to deliver all the **superior** MacOS ke ## Prerequisites 1. A Windows-style keyboard; **this solution is not designed to work with a Mac keyboard** 2. [AutoHotKey](https://www.autohotkey.com/) installed on your PC + +> #### **NOTE** +> This project provides scripts for both AHK 2.0+ and AHK 1.1, but the 1.1 script is no longer being updated or tested as of **09/09/2023** + 3. Swap your Ctrl and Alt keys using [Microsoft Power Toys](https://apps.microsoft.com/store/detail/microsoft-powertoys/XP89DCGQ3K6VLD?hl=en-us&gl=us) -![PowerToys_KeyboardManager.png](PowerToys_KeyboardManager.png) +![PowerToys_KeyboardManager.png](assets/PowerToys_KeyboardManager.png) > ### **NOTE** > If your machine is restricted by an admin and you are unable to install Power Toys from the Microsoft store link above, you can try installing the per-user scope version of Power Toys from the [Power Toys GitHub](https://github.com/microsoft/PowerToys/releases) -> ![PowerToys_User_Download.png](PowerToys_User_Download.png) +> ![PowerToys_User_Download.png](assets/PowerToys_User_Download.png) -3. Optional (but highly recommended): Turn on PowerToys Run and assign it to Ctrl+Space (Since you swapped your Ctrl and Alt keys in the previous step) +4. Optional (but highly recommended): Turn on PowerToys Run and assign it to Ctrl+Space (Since you swapped your Ctrl and Alt keys in the previous step) -![PowerToys_Run](PowerToys_Run.png) +![PowerToys_Run](assets/PowerToys_Run.png) -4. Optional: Install [Monosnap](https://monosnap.com/) for screenshots. +5. Optional: Install [Monosnap](https://monosnap.com/) for screenshots. --- @@ -28,18 +32,23 @@ This [AutoHotKey script](mac.ahk) seeks to deliver all the **superior** MacOS ke 1. [Prerequisites](#prerequisites) first! 2. Create a new `mac.ahk` file in the location of your choice. I recommend `%userprofile%/Documents/AutoHotKey/mac.ahk`. 3. Open your newly created file in a text editor such as Notepad. -4. Copy the contents of this [mac.ahk](mac.ahk) into the file you created and save changes. +4. Copy the contents of [mac.ahk](mac.ahk) into the file you created and save changes. + +> #### **NOTE** +> [mac1.1.ahk](./mac1.1.ahk) is available if you still want to run AHK 1.1, but this script is no longer being updated or tested as of **09/09/2023** + 5. Run the file by double-clicking it in Windows Explorer. +6. Optionally, learn how to use the Windows Startup folder or Task Scheduler to automatically start your script whenever you log in. --- ## Buy me a coffee (optional) ☕ -[Donate](https://ko-fi.com/stephennilsen) +[Donate](https://ko-fi.com/stephennilsen) ## https://ko-fi.com/stephennilsen --- ## Available shortcuts in this release -This script seeks to implement all shortcuts listed on the official [MacOS keyboard shortcuts page](https://support.apple.com/en-us/HT201236). The list below is current with that page as of **01/26/2023**. Items that are checked off have been implemented in the latest release. +This script seeks to implement all shortcuts listed on the official [MacOS keyboard shortcuts page](https://support.apple.com/en-us/HT201236), with the exception of the Accessibility Shortcuts section added in May 2023. The list below is current with that page as of **09/09/2023**. Items that are checked off have been implemented in the latest release. > ### **IMPORTANT NOTE** > The list of keyboard shortcuts below is formatted Apple-style. Use this keymap to perform these shortcuts in Windows: diff --git a/FullMacPage.txt b/assets/FullMacPage.txt similarity index 84% rename from FullMacPage.txt rename to assets/FullMacPage.txt index 1e5a2a3..40017b7 100644 --- a/FullMacPage.txt +++ b/assets/FullMacPage.txt @@ -2,6 +2,25 @@ Mac keyboard shortcuts By pressing certain key combinations, you can do things that normally need a mouse, trackpad, or other input device. +Using keyboard shortcuts + +Common shorcuts like cut, copy, paste + +Sleep, log out, and shut down shortcuts + +Finder and system shortcuts + +Document shortcuts + +Accessibility shortcuts + +Other shortcuts + +Learn more + + + +Using keyboard shortcuts To use a keyboard shortcut, press and hold one or more modifier keys and then press the last key of the shortcut. For example, to use Command-C (copy), press and hold the Command key, then the C key, then release both keys. Mac menus and keyboards often use symbols for certain keys, including modifier keys: Command (or Cmd) ⌘ @@ -11,11 +30,11 @@ Control (or Ctrl) ⌃ Caps Lock ⇪ Fn -On keyboards made for Windows PCs, use the Alt key instead of Option, and the Windows logo key instead of Command. +On keyboards made for Windows PCs, use the Alt key instead of Option, and the Ctrl key or Windows logo key instead of Command. Some keys on some Apple keyboards have special symbols and functions, such as for display brightness , keyboard brightness , and more. If these functions aren't available on your keyboard, you might be able to reproduce some of them by creating your own keyboard shortcuts. To use these keys as F1, F2, F3, or other standard function keys, combine them with the Fn key. - + Cut, copy, paste, and other common shortcuts Command-X: Cut the selected item and copy it to the Clipboard. @@ -196,27 +215,60 @@ Shift–Command–Plus sign (+): Increase the size of the selected item. Command Shift–Command–Question mark (?): Open the Help menu. -Other shortcuts -For more shortcuts, check the shortcut abbreviations shown in the menus of your apps. Every app can have its own shortcuts, and shortcuts that work in one app might not work in another. - Accessibility shortcuts +To use these vision shortcuts, first choose Apple menu  > System Settings (or System Preferences), then click Keyboard. Click Keyboard Shortcuts, select Accessibility on the left, then select “Invert colors” and "Contrast" on the right. + +Control-Option-Command-8: Invert colors. +Control-Option-Command-Comma (,) and Control-Option-Command-Period (.): Reduce contrast and increase contrast. +Use these shortcuts to change keyboard focus. To use some of these shortcuts, first choose Apple menu  > System Settings (or System Preferences), then click Keyboard. Click Keyboard Shortcuts, select Keyboard on the left, then select the shortcut's setting on the right. + +Control-F2 or Fn-Control-F2: Move focus to the menu bar. You can then use the arrow keys to navigate the menu, press Return to open a selected menu or choose a selected menu item, or type the menu item's name to jump to that item in the selected menu. +Control-F3 or Fn-Control-F3: Move focus to the Dock. +Control-F4 or Fn-Control-F4: Move focus to the active window or next window. +Control-F5 or Fn-Control-F5: Move focus to the window toolbar. +Control-F6 or Fn-Control-F6: Move focus to the floating window. +Control-Shift-F6: Move focus to the previous panel. +Control-F7 or Fn-Control-F7: Change the way Tab moves focus—between navigation of all controls on the screen, or only text boxes and lists. +Control-F8 or Fn-Control-F8: Move focus to the status menu in the menu bar +Command–Grave accent (`): Activate the next open window in the front app. +Shift–Command–Grave accent (`): Activate the previous open window in the front app +Option–Command–Grave accent (`): Move the focus to the window drawer. +Tab and Shift-Tab: Move to next control, move to previous control. +Control-Tab: Move to the next control when a text field is selected. +Control-Shift-Tab: Move to the previous grouping of controls. +Arrow keys: Move to the adjacent item in a list, tab group, or menu, or move sliders and adjusters (Up Arrow to increase values, Down Arrow to decrease values) +Control–Arrow keys: Move to a control adjacent to the text field. +Other accessibility shortcuts: + +Option-Command-F5 or triple-press Touch ID: Show the Accessibility Shortcuts panel. +VoiceOver commands +Zoom in or out +Use Mouse Keys to control the pointer with your keyboard +If you're using VoiceOver, you might need to make VoiceOver ignore the next key press before you can use some of the shortcuts in this article. + + + +Other shortcuts Safari shortcuts Spotlight shortcuts +Mail shortcuts +Photos shortcuts +Disk Utility shortcuts +Preview shortcuts +Apple Music shortcuts Startup shortcuts -Apple Music shortcuts: Choose Help > Keyboard shortcuts from the menu bar in the Music app. -Other shortcuts: Choose Apple menu > System Preferences, click Keyboard, then click Shortcuts. +For more shortcuts, check the shortcut abbreviations shown in the menus of your apps. Every app can have its own shortcuts, and shortcuts that work in one app might not work in another. Learn more -Type emoji, accents, and symbols +Use emoji and symbols Create your own shortcuts and resolve conflicts between shortcuts Change the behavior of the function keys or modifier keys Use a spoken command for a keyboard shortcut -Published Date: October 24, 2022 +Published Date: May 31, 2023 Helpful?YesNo Start a discussion in Apple Support Communities Ask other users about this article -Ask other users about this article See all questions on this article Apple Footer  diff --git a/PowerToys_KeyboardManager.png b/assets/PowerToys_KeyboardManager.png similarity index 100% rename from PowerToys_KeyboardManager.png rename to assets/PowerToys_KeyboardManager.png diff --git a/PowerToys_Run.png b/assets/PowerToys_Run.png similarity index 100% rename from PowerToys_Run.png rename to assets/PowerToys_Run.png diff --git a/PowerToys_User_Download.png b/assets/PowerToys_User_Download.png similarity index 100% rename from PowerToys_User_Download.png rename to assets/PowerToys_User_Download.png diff --git a/logo.png b/assets/logo.png similarity index 100% rename from logo.png rename to assets/logo.png diff --git a/logo.svg b/assets/logo.svg similarity index 100% rename from logo.svg rename to assets/logo.svg diff --git a/qr_Ko-fiDonate.png b/assets/qr_Ko-fiDonate.png similarity index 100% rename from qr_Ko-fiDonate.png rename to assets/qr_Ko-fiDonate.png diff --git a/mac.ahk b/mac.ahk index ed6b401..4afad6f 100644 --- a/mac.ahk +++ b/mac.ahk @@ -7,10 +7,9 @@ ; ! Ctrl (because of remapkey). For example, `Send, ^!a` would press Ctrl+Alt+A, and Send, ^{Home} would send Ctrl+Home. Note: ^A produces a different effect in some programs than ^a. This is because ^A presses Ctrl+Shift+A and ^a presses Ctrl+A. If in doubt, use lowercase.Sends Ctrl. For example, Send, ^!a would press Ctrl+Alt+A, and Send, ^{Home} would send Ctrl+Home. Note: ^A produces a different effect in some programs than ^a. This is because ^A presses Ctrl+Shift+A and ^a presses Ctrl+A. If in doubt, use lowercase. ; & An ampersand may be used between any two keys or mouse buttons to combine them into a custom hotkey. -#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. -; #Warn ; Enable warnings to assist with detecting common errors. -SendMode Input ; Recommended for new scripts due to its superior speed and reliability. -SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. +; #Warn ; Uncomment to enable warnings to assist with detecting common errors. +SendMode("Input") ; Recommended for new scripts due to its superior speed and reliability. +SetWorkingDir(A_ScriptDir) ; Ensures a consistent starting directory. ; Uncomment for key history ; #InstallKeybdHook @@ -18,69 +17,93 @@ SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. ; App and tab switching Ctrl & Tab::AltTab -!Tab::Send ^{Tab} +!Tab::Send("^{Tab}") ; Quit the active app -^q::Send, !{f4} +^q::Send("!{f4}") ; Insertion point movement ^Left:: - Suspend, On - Send, {Home} - Suspend, Off -return +{ + Suspend(true) + Send("{Home}") + Suspend(false) + return +} ^Right:: - Suspend, On - Send, {End} - Suspend, Off -return +{ + Suspend(true) + Send("{End}") + Suspend(false) + return +} ^Up:: - Suspend, On - Send, ^{Home} - Suspend, Off -return +{ + Suspend(true) + Send("^{Home}") + Suspend(false) + return +} ^Down:: - Suspend, On - Send, ^{End} - Suspend, Off -return +{ + Suspend(true) + Send("^{End}") + Suspend(false) + return +} +^Left:: - Suspend, On - Send, +{Home} - Suspend, Off -return +{ + Suspend(true) + Send("+{Home}") + Suspend(false) + return +} +^Right:: - Suspend, On - Send, +{End} - Suspend, Off -return +{ + Suspend(true) + Send("+{End}") + Suspend(false) + return +} +^Up:: - Suspend, On - Send, +^{Home} - Suspend, Off -return +{ + Suspend(true) + Send("+^{Home}") + Suspend(false) + return +} +^Down:: - Suspend, On - Send, +^{End} - Suspend, Off -return +{ + Suspend(true) + Send("+^{End}") + Suspend(false) + return +} #Left:: - Suspend, On - Send, ^{Left} - Suspend, Off -return +{ + Suspend(true) + Send("^{Left}") + Suspend(false) + return +} #Right:: - Suspend, On - Send, ^{Right} - Suspend, Off -return +{ + Suspend(true) + Send("^{Right}") + Suspend(false) + return +} +#Left:: - Suspend, On - Send, +^{Left} - Suspend, Off -return +{ + Suspend(true) + Send("+^{Left}") + Suspend(false) + return +} +#Right:: - Suspend, On - Send, +^{Right} - Suspend, Off -return \ No newline at end of file +{ + Suspend(true) + Send("+^{Right}") + Suspend(false) + return +} diff --git a/mac1.1.ahk b/mac1.1.ahk new file mode 100644 index 0000000..e0eadeb --- /dev/null +++ b/mac1.1.ahk @@ -0,0 +1,86 @@ +; This script assumes that Alt and Ctrl characters have been swapped using a third-party tool + +; -----KEY GUIDE----- +; # Win. (the key with the Windows logo) therefore `Send #e` would hold down Win and then press E. +; + Shift. For example, `Send, +abC` would send the text "AbC", and `Send, !+a` would press Alt+Shift+A. +; ^ Alt (because of remapkey). For example, `Send, This is text!a` would send the keys "This is text" and then press Alt+A. Note: !A produces a different effect in some programs than !a. This is because !A presses Alt+Shift+A and !a presses Alt+A. If in doubt, use lowercase. +; ! Ctrl (because of remapkey). For example, `Send, ^!a` would press Ctrl+Alt+A, and Send, ^{Home} would send Ctrl+Home. Note: ^A produces a different effect in some programs than ^a. This is because ^A presses Ctrl+Shift+A and ^a presses Ctrl+A. If in doubt, use lowercase.Sends Ctrl. For example, Send, ^!a would press Ctrl+Alt+A, and Send, ^{Home} would send Ctrl+Home. Note: ^A produces a different effect in some programs than ^a. This is because ^A presses Ctrl+Shift+A and ^a presses Ctrl+A. If in doubt, use lowercase. +; & An ampersand may be used between any two keys or mouse buttons to combine them into a custom hotkey. + +#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. +; #Warn ; Uncomment to enable warnings to assist with detecting common errors. +SendMode Input ; Recommended for new scripts due to its superior speed and reliability. +SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. + +; Uncomment for key history +; #InstallKeybdHook +; KeyHistory + +; App and tab switching +Ctrl & Tab::AltTab +!Tab::Send ^{Tab} + +; Quit the active app +^q::Send, !{f4} + +; Insertion point movement +^Left:: + Suspend, On + Send, {Home} + Suspend, Off +return +^Right:: + Suspend, On + Send, {End} + Suspend, Off +return +^Up:: + Suspend, On + Send, ^{Home} + Suspend, Off +return +^Down:: + Suspend, On + Send, ^{End} + Suspend, Off +return ++^Left:: + Suspend, On + Send, +{Home} + Suspend, Off +return ++^Right:: + Suspend, On + Send, +{End} + Suspend, Off +return ++^Up:: + Suspend, On + Send, +^{Home} + Suspend, Off +return ++^Down:: + Suspend, On + Send, +^{End} + Suspend, Off +return +#Left:: + Suspend, On + Send, ^{Left} + Suspend, Off +return +#Right:: + Suspend, On + Send, ^{Right} + Suspend, Off +return ++#Left:: + Suspend, On + Send, +^{Left} + Suspend, Off +return ++#Right:: + Suspend, On + Send, +^{Right} + Suspend, Off +return \ No newline at end of file