Skip to content

Instantly share code, notes, and snippets.

@JM-Mendez
Last active June 7, 2021 20:22
Show Gist options
  • Save JM-Mendez/8bdc649e5ce6a38d3286fc402b73fc81 to your computer and use it in GitHub Desktop.
Save JM-Mendez/8bdc649e5ce6a38d3286fc402b73fc81 to your computer and use it in GitHub Desktop.
Autohotkey #vmware
;; based on @babygau's answer here https://stackoverflow.com/a/40559502
#NoEnv ; recommended for performance and compatibility with future autohotkey releases.
; #UseHook
#InstallKeybdHook
#SingleInstance force
#WinActivateForce
SetTitleMatchMode, 2
SendMode Input
GroupAdd, vscode, ahk_exe Code.exe
OpenOrFocus(OpenProcName, FocusProcName, runAsAdmin, params = "") {
if WinExist("ahk_exe " FocusProcName) {
WinActivate, ahk_exe %FocusProcName%
} else {
if(runAsAdmin){
; run as administrator
Run *RunAs %OpenProcName% %params%
} else {
Run, %OpenProcName% %params%
}
}
SetCapsLockState, Off
}
; note: must use tidle prefix to fire hotkey once it is pressed
; not until the hotkey is released
~Capslock::
;; downtemp tells subsequent sends that the key is not permanently down, and may be released whenever a keystroke calls for it.
KeyWait, Capslock
; add a function key to hyper key combo to avoid opening up MS Office on Windows 10un as administrator
Send {Ctrl DownTemp}{Shift DownTemp}{Alt DownTemp}{LWin DownTemp}{F1 DownTemp}
Send {Ctrl Up}{Shift Up}{Alt Up}{LWin Up}{F1 Up}
return
~Capslock & v::
; global focusVscode = "Code.exe"
; global openVscode = "C:\Program Files\Microsoft VS Code\Code.exe"
; OpenOrFocus(openVscode, focusVscode, false)
; WinActivate, ahk_exe focusVscode
GroupActivate, vscode, r
SetCapsLockState, Off
return
; open or focus by current running process
~Capslock & t::
global focusTerminal = "WindowsTerminal.exe"
global openTerminal = "shell:AppsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App"
; https://stackoverflow.com/a/54927424
OpenOrFocus(openTerminal, focusTerminal, true)
return
~Capslock & f::
OpenOrFocus("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", "chrome.exe", false, "--no-default --remote-debugging-port=9222 --user-data-dir=c:\debugChrome https://localhost/Airwatch")
return
~Capslock & r::
OpenOrFocus("C:\Program Files\JetBrains\JetBrains Rider 2020.2.4\bin\rider64.exe", "rider64.exe", false)
return
~Capslock & s::
global focusSlack = "Slack.exe"
global openSlack = "shell:AppsFolder\91750D7E.Slack_8she8kybcnzg4!Slack"
OpenOrFocus(openSlack, focusSlack, false)
return
~Capslock & g::
OpenOrFocus("C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe", "msedge.exe", false)
return
~Capslock & e::
global focusOutlook = "outlook.exe"
global openOutlook = "C:\Program Files\Microsoft Office\root\Office16\outlook.exe"
OpenOrFocus(openOutlook, focusOutlook, false)
return
; simple keys
; minimize windows
!m::Send, #{Down}
; swap brackets cuz kinesis is buggy, but still way too complicated https://superuser.com/a/425881
*$[::
if (GetKeyState("Shift"))
SendInput, {[ Down}
else
SendInput, {{ Down}
return
*$]::
if (GetKeyState("Shift"))
SendInput, {] Down}
else
SendInput, {} Down}
return
*$[ Up::
if (GetKeyState("Shift"))
SendInput, {[ Up}
else
SendInput, {{ Up}
return
*$] Up::
if (GetKeyState("Shift"))
SendInput, {] Up}
else
SendInput, {} Up}
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment