* 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
This commit is contained in:
Stephen Nilsen
2023-09-09 14:32:34 -05:00
parent cd8d9643a5
commit 410d0a4199
10 changed files with 243 additions and 73 deletions

View File

@@ -1,6 +1,6 @@
# MacOS Keyboard Behavior in Windows # MacOS Keyboard Behavior in Windows
![logo.png](logo.png) ![logo.png](assets/logo.png)
<br><br> <br><br>
This [AutoHotKey script](mac.ahk) seeks to deliver all the **superior** MacOS keyboard behavior you love in Windows! 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 ## Prerequisites
1. A Windows-style keyboard; **this solution is not designed to work with a Mac keyboard** 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 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) 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** > ### **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) > 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! 1. [Prerequisites](#prerequisites) first!
2. Create a new `mac.ahk` file in the location of your choice. I recommend `%userprofile%/Documents/AutoHotKey/mac.ahk`. 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. 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. 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) ☕ ## Buy me a coffee (optional) ☕
[<img src="qr_Ko-fiDonate.png" alt="Donate" width="200"/>](https://ko-fi.com/stephennilsen) [<img src="assets/qr_Ko-fiDonate.png" alt="Donate" width="200"/>](https://ko-fi.com/stephennilsen)
## https://ko-fi.com/stephennilsen ## https://ko-fi.com/stephennilsen
--- ---
## Available shortcuts in this release ## 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** > ### **IMPORTANT NOTE**
> The list of keyboard shortcuts below is formatted Apple-style. Use this keymap to perform these shortcuts in Windows: > The list of keyboard shortcuts below is formatted Apple-style. Use this keymap to perform these shortcuts in Windows:

View File

@@ -2,6 +2,25 @@
Mac keyboard shortcuts Mac keyboard shortcuts
By pressing certain key combinations, you can do things that normally need a mouse, trackpad, or other input device. 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: 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) ⌘ Command (or Cmd) ⌘
@@ -11,7 +30,7 @@ Control (or Ctrl) ⌃
Caps Lock ⇪ Caps Lock ⇪
Fn 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. 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.
@@ -196,27 +215,60 @@ ShiftCommandPlus sign (+): Increase the size of the selected item. Command
ShiftCommandQuestion mark (?): Open the Help menu. ShiftCommandQuestion 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 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
CommandGrave accent (`): Activate the next open window in the front app.
ShiftCommandGrave accent (`): Activate the previous open window in the front app
OptionCommandGrave 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)
ControlArrow 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 Safari shortcuts
Spotlight shortcuts Spotlight shortcuts
Mail shortcuts
Photos shortcuts
Disk Utility shortcuts
Preview shortcuts
Apple Music shortcuts
Startup shortcuts Startup shortcuts
Apple Music shortcuts: Choose Help > Keyboard shortcuts from the menu bar in the Music app. 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.
Other shortcuts: Choose Apple menu > System Preferences, click Keyboard, then click Shortcuts.
Learn more Learn more
Type emoji, accents, and symbols Use emoji and symbols
Create your own shortcuts and resolve conflicts between shortcuts Create your own shortcuts and resolve conflicts between shortcuts
Change the behavior of the function keys or modifier keys Change the behavior of the function keys or modifier keys
Use a spoken command for a keyboard shortcut Use a spoken command for a keyboard shortcut
Published Date: October 24, 2022 Published Date: May 31, 2023
Helpful?YesNo Helpful?YesNo
Start a discussion in Apple Support Communities Start a discussion in Apple Support Communities
Ask other users about this article Ask other users about this article
Ask other users about this article
See all questions on this article See all questions on this article
Apple Footer Apple Footer

View File

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

View File

Before

Width:  |  Height:  |  Size: 116 KiB

After

Width:  |  Height:  |  Size: 116 KiB

View File

Before

Width:  |  Height:  |  Size: 148 KiB

After

Width:  |  Height:  |  Size: 148 KiB

View File

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

View File

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 41 KiB

View File

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 98 KiB

131
mac.ahk
View File

@@ -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. ; ! 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. ; & 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.
; #Warn ; Enable warnings to assist with detecting common errors. SendMode("Input") ; Recommended for new scripts due to its superior speed and reliability.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir(A_ScriptDir) ; Ensures a consistent starting directory.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; Uncomment for key history ; Uncomment for key history
; #InstallKeybdHook ; #InstallKeybdHook
@@ -18,69 +17,93 @@ SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; App and tab switching ; App and tab switching
Ctrl & Tab::AltTab Ctrl & Tab::AltTab
!Tab::Send ^{Tab} !Tab::Send("^{Tab}")
; Quit the active app ; Quit the active app
^q::Send, !{f4} ^q::Send("!{f4}")
; Insertion point movement ; Insertion point movement
^Left:: ^Left::
Suspend, On {
Send, {Home} Suspend(true)
Suspend, Off Send("{Home}")
return Suspend(false)
return
}
^Right:: ^Right::
Suspend, On {
Send, {End} Suspend(true)
Suspend, Off Send("{End}")
return Suspend(false)
return
}
^Up:: ^Up::
Suspend, On {
Send, ^{Home} Suspend(true)
Suspend, Off Send("^{Home}")
return Suspend(false)
return
}
^Down:: ^Down::
Suspend, On {
Send, ^{End} Suspend(true)
Suspend, Off Send("^{End}")
return Suspend(false)
return
}
+^Left:: +^Left::
Suspend, On {
Send, +{Home} Suspend(true)
Suspend, Off Send("+{Home}")
return Suspend(false)
return
}
+^Right:: +^Right::
Suspend, On {
Send, +{End} Suspend(true)
Suspend, Off Send("+{End}")
return Suspend(false)
return
}
+^Up:: +^Up::
Suspend, On {
Send, +^{Home} Suspend(true)
Suspend, Off Send("+^{Home}")
return Suspend(false)
return
}
+^Down:: +^Down::
Suspend, On {
Send, +^{End} Suspend(true)
Suspend, Off Send("+^{End}")
return Suspend(false)
return
}
#Left:: #Left::
Suspend, On {
Send, ^{Left} Suspend(true)
Suspend, Off Send("^{Left}")
return Suspend(false)
return
}
#Right:: #Right::
Suspend, On {
Send, ^{Right} Suspend(true)
Suspend, Off Send("^{Right}")
return Suspend(false)
return
}
+#Left:: +#Left::
Suspend, On {
Send, +^{Left} Suspend(true)
Suspend, Off Send("+^{Left}")
return Suspend(false)
return
}
+#Right:: +#Right::
Suspend, On {
Send, +^{Right} Suspend(true)
Suspend, Off Send("+^{Right}")
return Suspend(false)
return
}

86
mac1.1.ahk Normal file
View File

@@ -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