Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chrisfcarroll/dddf32fea1f29e75f564 to your computer and use it in GitHub Desktop.
Save chrisfcarroll/dddf32fea1f29e75f564 to your computer and use it in GitHub Desktop.
A Pair of AutoHotKey Scripts for they who, being Mac Users, yet still insist on using Windows. One for an Apple keyboard, one for a PC keyboard. 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 t…
; 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 ' : ConsoleEmu `r`n s : Sublime text `r`n e : Edge Browser `r`n w : Windows Explorer "
Input Key, L1 T4
if (Key="'") {
Run, "C:\Program Files\ConEmu\ConEmu64.exe"
} else if (Key="s") {
Run, "C:\Program Files\Sublime Text 3\sublime_text.exe"
} else if (Key="e") {
Run, microsoft-edge:
;Run, http://127.0.0.2
} else if (Key="w") {
Run, "explorer", %UserProfile%
} else {
}
SplashTextOff
return
;
#F4::
SplashTextOn 300,200
, Widgets
, % " 3 : Calendar `r`n 4 : Calculator "
Input Key, L1 T5
if (Key="3") {
Run, outlookcal:
} else if (Key="4") {
Run, calc
} 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}
; === Windowsisms =======================================================
; Because there's no right-click menu key on an apple keyboard
RWin::AppsKey
; === 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
;
;
!-::–
!+-::—
!=::!=
!+=::±
![::“
!+[::”
!]::‘
!+]::’
!;::…
!'::æ
!+'::Æ
!\::«
!+\::»
!,::<=
!+,::¯
!.::>=
;!+.::breve
!/::÷
!+/::¿
!_::—
; Put alt-letters entirely on RightAlt to avoid menu shortcut clashes
>!a::å
>!+a::Å
>!b::∫
;!+b::i
>!c::ç
>!+c::Ç
>!d::∂
!+d::Î
>!e::´
>!+e::‰
>!f::ƒ
>!+f::Ï
>!g::©
>!+g::Ì
;!h::overdot
>!+h::Ó
>!i::^
>!+i::È
>!j::δ
>!+j::Ô
>!k::°
>!+k::⌘
>!l::¬
>!+l::Ò
>!m::µ
>!+m::˜
>!n::~
>!+n::ˆ
>!o::ø
>!+o::Ø
>!p::π
>!+p::Π
>!q::œ
>!+q::Œ
>!r::®
>!+r::Â
>!s::ß
>!+s::Í
>!t::†
>!+t::Ê
>!u::¨
>!+u::Ë
>!v::v
;!+v::lozenge
>!w::ε
>!+w::„
>!x::≅
>!+x::Ù
>!y::¥
>!+y::Á
>!z::ω
>!+z::Ω
; === 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
#!F12::Run, SndVol.exe
#+F12::Run, "C:\Program Files (x86)\TuneBlade\TuneBlade\TuneBlade.exe" ;TuneBlade—airplay on your PC!
#F12::volume_up
; === 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?
; Mac Keyboard has lots of characters available on the alt-keys. Who can live without ellipses and m-dashes? Especially in 140 characters
; However. Windows apps use alt-key combos for menu shortcuts, so
; - You may prefer to remove or comment out most of these.
; - I put many of them on Right-Alt specifically.
;
!1::¡
!+1::/
!2::€
!+2::™
!3::Send {#} ; I use a UK keyboard which has Shift-3 == £
!+3::‹
!4::¢
!+4::›
!5::∞
!6::§
!+6::fl
!7::¶
!+7::‡
!8::•
!+8::°
!9::ª
!+9::·
!0::º
!+0::‚
;
; === 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)
; Language: English
; Uses unicode. Save this file as utf-8 with BOM.
; Else it shall not work.
;
#NoEnv ; 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 (RegExMatch(clipboard , "(^http://)|(^https://)" ) ) {
url:= StrReplace(Clipboard, "`%", "`%25")
Run % url
} else if (RegExMatch(clipboard , "//[A-Za-z0-9-_]+" ) ) {
url:= "http:" . StrReplace(Clipboard, "`%", "`%25")
Run % url
} else if (RegExMatch(clipboard , "^(file:(\\|//)|[A-Za-z]:\\|^\\|).{0,127}" ) ) {
Run % clipboard
} else if (clipboard != "") {
url:= "https://bing.com/?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"
. "' : ConsoleEmu `r`n"
. " t : Sublime text `r`n"
. " w : Web Browser `r`n"
. " e : Windows Explorer `r`n"
. " o : MS Outlook `r`n "
Input Key, L1 T6
if (Key="'") {
Run, "C:\Program Files\ConEmu\ConEmu64.exe"
} else if (Key="t") {
Run, "C:\Program Files\Sublime Text 3\sublime_text.exe"
} else if (Key="w") {
Run, http://
} else if (Key="e") {
Run, "explorer", %UserProfile%
} else if (Key="o") {
WinActivate, Inbox - [email protected] - Microsoft Outlook
} else {
}
SplashTextOff
return
;
; Yes, I still use widgets. Mostly for the calculator.
#F4::Run, calc
#F5::WinActivate, Inbox - [email protected] - Outlook
; === macOSisms ========================================================
#+4::Run, C:\WINDOWS\system32\SnippingTool.exe
; === Mac Keyboard for a Mac User on Windows ===================================================
;
; Mac Keyboard has lots of characters available on the alt-keys. Who can live without ellipses and m-dashes? Especially in 280 characters
; However. Windows apps use alt-key combos for menu shortcuts, so
; - You may prefer to remove or comment out most of these.
; - I put many of them on Right-Alt specifically.
;
!-::Send, –
!+-::Send, —
!=::Send, ≠
!+=::Send, ±
![::Send, “
!+[::Send, ”
!]::Send, ‘
!+]::Send, ’
!;::Send, …
!'::Send, æ
!+'::Send, Æ
!\::Send, «
!+\::Send, »
!.::Send, >=
;!+.::breve
!/::Send, ÷
!+/::Send, ¿
!_::Send, —
; Put most alt-letters entirely on RightAlt to avoid menu shortcut clashes
>!1::¡
>!+1::/
>!2::€
>!+2::™
!3::# ; I use a UK keyboard which has Shift-3 == £
>!+3::‹
>!4::¢
>!+4::›
>!5::∞
>!6::§
>!+6::fl
>!7::¶
>!+7::‡
>!8::•
>!+8::°
>!9::ª
>!+9::·
>!0::º
>!+0::‚
>!a::α
>!+a::å
>!b::β
;!+b::i
>!c::ç
>!+c::Ç
>!d::∂
!+d::Î
>!e::´
>!+e::‰
>!f::ƒ
>!+f::Ï
>!g::γ
>!+g::Γ
;!h::overdot
>!+h::Ó
>!i::^
>!+i::È
>!j::δ
>!+j::Ô
>!k::°
>!+k::⌘
>!l::¬
>!+l::Ò
>!m::µ
>!+m::˜
>!n::~
>!+n::ˆ
>!o::ø
>!+o::Ø
>!p::π
>!+p::Π
>!q::œ
>!+q::Œ
>!r::®
>!+r::Â
>!s::ß
>!+s::Í
>!t::†
>!+t::Ê
>!u::¨
>!+u::Ë
>!v::v
;!+v::lozenge
>!w::ε
>!+w::„
>!x::≅
>!+x::Ù
>!y::¥
>!+y::Á
>!z::ω
>!+z::Ω
; === 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
#!F12::Run, SndVol.exe
#F12::volume_up
; === Basic Cmd <-> Ctrl key swapping with cherry-picking of my favourite exceptions =====
#LButton::^LButton
#RButton::^RButton
#h::WinMinimize, A
#+R::Run, C:\Users\USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\startup
#w::Send ^{F4}
;;#[:: Safari back and forwards
;
; === Large screen and multi-screen windowing shortcuts ===========================================
;
ShowDisplays()
{
SysGet mc, MonitorCount
Loop % mc {
SysGet m, Monitor, %A_Index%
s = %s%`nx %mLeft%:%mRight% y %mTop%:%mBottom%
}
MsgBox Displays: %s%
}
ResizeWin(Width = 0,Height = 0, newX = 0, newY = 0)
{
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.
; Don't forget the width or height of the taskbar.
;
screen1height:=1080
screen1width:=1920
width23:= 1080 ; Screenwidth*2/3
width13:= 700 ; Screenwidth/3
narrow:=500
screen2height:=1080
screen2width:=1920-60 ; 1860
screen2left:=1920+60 ; 1980
widthOfVerticalTaskBar=65
heightOfHorizontalTaskBar=650
^#Numpad7::
WinRestore, A
ResizeWin( 1080, 1080, -1080)
WinMaximize, A
return
#Numpad7::
WinRestore, A
ResizeWin( 1080, 1730, -1080, -200)
return
^#Numpad4::
WinRestore, A
ResizeWin( 1080, 1080, -1080, -280)
return
#Numpad4::
WinRestore, A
ResizeWin( 1080, 1080, -1080, 0)
return
#Numpad1::
WinRestore, A
ResizeWin( 1080, 700, -1080, 840)
return
#Numpad8::
WinRestore, A
ResizeWin( 1420, 1080, 250)
return
#Numpad5::
WinRestore, A
ResizeWin( 920, 1080, 500)
return
#Numpad2::
WinRestore, A
ResizeWin( 660, 1080, 500)
return
#Numpad9::
WinRestore, A
ResizeWin( 1860, 1080, 0)
WinMaximize, A
return
#Numpad6::
WinRestore, A
ResizeWin( 1200, 1080, 840)
return
#Numpad3::
WinRestore, A
ResizeWin( 660, 1080, 1260)
return
#NumpadDiv::
WinRestore, A
ResizeWin( 3840, 1080, -1080)
return
#NumpadMult::
WinRestore, A
ResizeWin( 3840, 1080, -1080)
return
#!Numpad7::
WinRestore, A
ResizeWin( 500, 540, 0)
return
#!Numpad1::
WinRestore, A
ResizeWin( 500, 540, 0, 540)
return
#!Numpad9::
WinRestore, A
ResizeWin( 500, 540, 3300)
return
#!Numpad3::
WinRestore, A
ResizeWin( 500, 540, 3300, 540)
return
#!^w::ShowDisplays()
@chrisfcarroll
Copy link
Author

chrisfcarroll commented Jan 3, 2017

Other stuff I did for Windows-Mac swappers, (UK keyboard driver; BootCamp download help) on www.cafe-encounter.net

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