Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dgrebb/4e9f2a860a437391d1feb8c1ebc7cdb7 to your computer and use it in GitHub Desktop.
Save dgrebb/4e9f2a860a437391d1feb8c1ebc7cdb7 to your computer and use it in GitHub Desktop.
AutoHotKey script for they who, being Mac Users with an Apple keyboard, yet still insist on using Windows. Also some arrange-windows-on-a-big-screen keys . Takes a similar approach as Parallels to keyboard mapping: rather than a wholesale swap of Cmd <-> Ctrl, instead duplicate favourite ctrl-key shortcuts to the Cmd key. For the big screen: som…
#InstallKeybdHook
; Language: English
; https://gist.github.com/chrisfcarroll/dddf32fea1f29e75f564
;
; Uses unicode. Save this file as utf-8 with BOM.
; Else it shall not work.
;
#NoEnv ; Recommended
;SendMode Input ; Recommended
SendMode Event
SetWorkingDir %userprofile% ; Ensures a consistent starting directory.
; === autotexts ========================================================
;
::ccuu::chris.carroll@myemailaddress
::ccws::chris.carroll@myotheremailaddress
; === Liquid, Launcher and Widget Hotkeys ========================================================
;
; Put a little [Liquid|Flow][http://www.liquid.info/] core functionality on Cmd-Alt-'
#!'::
clipboard = ;
Send ^c
Clipwait
MsgBox, 0, Launcher, % " websearch: " Clipboard, 0.2
if (clipboard != "") {
url:= "https://google.co.uk/search?q=" . StrReplace(Clipboard, "`%", "`%25")
Run % url
}
return
; Use Cmd-' as my launcher key. http://conemu.github.io/ made me do it.
#'::
SplashTextOn 200, 130
, Launcher
, % " Press 2nd Key: `r`n `r`n ' : Cmder `r`n a : Atom Editor `r`n c : Chrome `r`n e : Windows Explorer "
Input Key, L1 T4
if (Key="'") {
Run, "C:\cmder\cmder.exe"
} else if (Key="a") {
Run, "C:\Users\dgrebb\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\GitHub`, Inc\Atom"
} else if (Key="c") {
Run, "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Google Chrome"
;Run, http://127.0.0.2
} else if (Key="e") {
Run, "explorer", %UserProfile%
} else {
}
SplashTextOff
return
;
; === Unixisms ==========================================================
;
; Because you've come from using a Mac command line
;
^a::Send {Home} ; May drive you crazy because you're used to ^a == select all. Cmd-A get mapped below though so sanity restored.
^e::Send {End}
; === macOSisms ========================================================
#$::Run, C:\WINDOWS\system32\SnippingTool.exe
; === Mac Keyboard for a Mac User on Windows ===================================================
;
; a) Use Command-key for favourite Ctrl-key shortcuts
; b) Where (a) removes a favourite Windows-key shortcut, replace it with Command-Alt-Ctrl-key
; c) Some the function keys e.g. volume control
; d) a subset of the characters available on a Mac keyboard via the alt key
;
; NB some of these may be specific to the Apple UK Extended keyboard layout.
; (Alt-2 & Alt-3 are the only thing that comes to mind but anyway...);
; My keyboard layout is at http://www.cafe-encounter.net/p84/apple-uk-keyboard-layout-for-windows
;
;
; === Function 1 to 12: Use win-F rather than raw F-keys à la MacOS because so many Windows apps use them. =======
; No equivalent to most of the keys but this works for me. I don't have screen brightness controls.
#F1::Run powercfg.cpl
#F2::Run desk.cpl
#F3::#Tab
;"Launch_App2" didn't work for me. See above for F4 key
#F7::Media_Prev
#F8::Media_Play_Pause
#F9::Media_Next
#F10::volume_mute
#F11::volume_down
; === Functions 13 to 19 =======
F13::PrintScreen
; -- Sleep. Maybe. Google it if you want to know about the problems with this line ---
#!F15::DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0)
; "F15::Sleep" did not work on my machine
F16::Send {Pause}
^F16::Send {CtrlBreak}
;Win-F16 on my machine does a quite cool graphical cancelable shutdown
;Win-F17 does something weird to the screen for 2 seconds
; === Basic Cmd <-> Ctrl key swapping with cherry-picking of my favourite exceptions =====
#LButton::^LButton
#RButton::^RButton
#a::^a
#b::^b
#c::^c
#d::^d
#e::^e
#f::^f
#g::^g
#h::WinMinimize, A
#i::^i
#j::^j
#k::^k
;#l is for lockscreen
#m::^m
#n::^n
#o::^o
;Win-P is for projectors and screen
#p::^p
;#^!p::#p
;#q::^q
;Win-R is for the run menu
#+R::Run, "C:\Users\Chris\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
#s::^s
#t::^t
#u::^u
#v::^v
#w::Send ^{F4}
#x::^x
;Win-X is for Windows Tools Menu
#^!x::#x
#y::^y
#z::^z
#1::^1
#2::^2
#3::^3
#4::^4
#5::^5
#6::^6
#7::^7
#8::^8
#9::^9
#0::^0
#-::^-
#=::^=
#+::^+
;;#[:: Safari back and forwards
#[::Send !{Left}
#]::Send !{Right}
#{::^{
#}::^}
#\::^\
#|::^|
#`::^`
#~::^~
#,::^,
#<::^<
#.::^.
#>::^>
#/::^/
#?::^?
;<#LButton::^LButton ; This doesn't seem to work. Is there no such thing as Windows-Click?
;;;;;;;;;;;; dgrebb customizations ;;;;;;;;;;;;
; command tab window switching
<#Tab::AltTab
!Tab::return
; quit application
#q::!F4
; disable left win key
LWin::Ctrl
;
; === Large screen shortcuts ===================================================================
;
ResizeWin(Width = 0,Height = 0, newX = 1, newY = 1)
{
WinGetPos,X,Y,W,H,A
If %Width% = 0
Width := W
If %Height% = 0
Height := H
If %newX% = 1
newX := X
If %newY% = 1
newY := Y
WinMove,A,,%newX%,%newY%,%Width%,%Height%
}
; Change these numbers to match the 3rds on your screen. Or whatever works for you.
#Numpad1::ResizeWin( 600, 1440, 60)
#Numpad2::ResizeWin( 600, 1440, 1390)
#Numpad3::ResizeWin( 600, 1440, 2840)
#Numpad4::ResizeWin(1050, 1440, 60)
#Numpad5::ResizeWin(1295, 1440, 1091)
#Numpad6::ResizeWin(1050, 1440, 2371)
#Numpad7::ResizeWin(2200, 1440, 60)
#Numpad8::ResizeWin(2220, 1440, 640)
#Numpad9::ResizeWin(2200, 1440, 1240)
!#Numpad1::ResizeWin( 600, 720, 60, 720)
!#Numpad2::ResizeWin( 600, 720, 1390, 720)
!#Numpad3::ResizeWin( 600, 720, 2840, 720)
!#Numpad4::ResizeWin(1050, 720, 60, 720)
!#Numpad5::ResizeWin(1295, 720, 1091, 720)
!#Numpad6::ResizeWin(1050, 720, 2371, 720)
!#Numpad7::ResizeWin( 600, 720, 60)
!#Numpad8::ResizeWin( 600, 720, 1390)
!#Numpad9::ResizeWin( 600, 720, 2840)
@mattmcegg
Copy link

would really love to use this, but i get a lot of errors on the lines with # ... maybe my version of autohotkeys? any specific installation instructions?

@dgrebb
Copy link
Author

dgrebb commented Sep 15, 2023

@mattmcegg I haven't used this or autohotkey for ~5 years. The #s are probably comments where I didn't want a specific keymapping.

That being said, it looks like the original gist has been updated as recently as four years ago.

@dgrebb
Copy link
Author

dgrebb commented Sep 15, 2023

@mattmcegg there's also this now: https://github.com/stroebjo/autohotkey-windows-mac-keyboard

Best of luck in your Windows adventures :)

@mattmcegg
Copy link

@dgrebb thanks for the suggestions! doesn't look like that "new" one works either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment