Skip to content

Instantly share code, notes, and snippets.

@shrayasr
Last active September 6, 2021 06:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shrayasr/683a6e6e812445c624bcbdcaef7f2f1d to your computer and use it in GitHub Desktop.
Save shrayasr/683a6e6e812445c624bcbdcaef7f2f1d to your computer and use it in GitHub Desktop.
AutoHotKey shortcuts
if not A_IsAdmin
{
Run *RunAs "%A_ScriptFullPath%" ; Requires v1.0.92.01+
ExitApp
}
#SingleInstance Force
#NoEnv
#Warn
SendMode, Input
SetWorkingDir, "D:\bin"
SetTitleMatchMode, 2
ActivateIfExists(name)
{
exist := WinExist(name)
if %exist%
WinActivate, %name%
}
; Function that either activates the window, if it exists or
; launches the exe given
ActivateOrLaunch(name, exeName, windowType:="max")
{
WinGet, currProcessPath, ProcessPath, A
if (currProcessPath = exeName)
WinMinimize, A
else
{
exist := WinExist(name)
if %exist%
WinActivate, %name%
else
if (windowType = "-")
Run %exeName%
else
Run, %exeName%,, max
}
}
ActivateAndCycle(exe)
{
IfWinExist, ahk_exe %exe%
IfWinActive, ahk_exe %exe%
WinActivateBottom, ahk_exe %exe%
else
WinActivate, ahk_exe %exe%
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; RAlt slash
;; Check if AHK is working
<^>!/::
MsgBox, , Keys, It Works
return
;; Win E
;; Replace windows explorer wtih FreeCommander
#e::
ActivateOrLaunch("FreeCommander XE", "C:\Program Files (x86)\FreeCommander XE\FreeCommander.exe")
return
;; RAlt M
;; Spotify Music
<^>!m::
ActivateOrLaunch("Spotify","C:\Users\Shrayas\AppData\Roaming\Spotify\Spotify.exe")
return
;; RAlt L
;; Linqpad
<^>!l::
ActivateOrLaunch("LINQPad", "C:\Program Files\LINQPad6\LINQPad6.exe")
return
;; RAlt N
;; Notion
<^>!n::
ActivateOrLaunch("Notion", "C:\Users\Shrayas\AppData\Local\Programs\Notion\Notion.exe")
return
;; RAlt K
;; KeePass
<^>!k::
ActivateOrLaunch("KeePassXC", "C:\Program Files\KeePassXC\KeePassXC.exe")
return
;; RAlt S
;; Sublime Merge
<^>!s::
ActivateOrLaunch("Sublime Merge", "C:\Program Files\Sublime Merge\sublime_merge.exe")
return
;; RAlt T
;; Thunderbird
<^>!t::
ActivateOrLaunch("Thunderbird", "C:\Program Files\Mozilla Thunderbird\thunderbird.exe")
return
;; RAlt D
;; DBEaver
<^>!d::
ActivateOrLaunch("DBeaver", "C:\Program Files\DBeaver\dbeaver.exe")
return
;; RAlt C
;; Brave
<^>!c::
ActivateOrLaunch("Brave", "C:\Users\Shrayas\AppData\Local\BraveSoftware\Brave-Browser\Application\brave.exe")
return
;; RAlt F
;; Firefox -- My profile
<^>!f::
ActivateOrLaunch("Firefox", "C:\Program Files\Mozilla Firefox\firefox.exe -p Shrayas")
return
;; RAlt Shift F
;; Firefox -- Sundarakala Profile
<^>!+f::
ActivateOrLaunch("Firefox", "C:\Program Files\Mozilla Firefox\firefox.exe -p sundarakala")
return
;; RAlt W
;; WhatsApp
<^>!w::
ActivateOrLaunch("WhatsApp", "C:\Users\Shrayas\AppData\Local\WhatsApp\WhatsApp.exe", "-")
return
;; RAlt G
;; Telegram
<^>!g::
ActivateOrLaunch("Telegram", "C:\Users\Shrayas\AppData\Roaming\Telegram Desktop\Telegram.exe", "-")
return
;; RAlt P
;; Cycle open putty windows
<^>!p::
ActivateAndCycle("PUTTY.exe")
return
;; RAlt V
;; Cycle open Visual Studio windows
<^>!v::
ActivateAndCycle("devenv.exe")
return
;; RAlt F12
;; Open a bunch of default apps
<^>!F12::
MsgBox, 4,, Launch defaults?
IfMsgBox Yes
{
ActivateOrLaunch("DBeaver", "C:\Program Files\DBeaver\dbeaver.exe -nl en")
ActivateOrLaunch("Thunderbird", "C:\Program Files\Mozilla Thunderbird\thunderbird.exe")
ActivateOrLaunch("Sublime Merge", "C:\Program Files\Sublime Merge\sublime_merge.exe")
ActivateOrLaunch("Cmder", "C:\tools\cmder\Cmder.exe")
ActivateOrLaunch("FreeCommander XE", "C:\Program Files (x86)\FreeCommander XE\FreeCommander.exe")
}
return
;; RAlt F5
;; Reload Script
<^>!F5::
Reload
return
;; RAlt F2
;; Edit Script
<^>!F2::
Run, "C:\tools\neovim\Neovim\bin\nvim-qt.exe" "D:\bin\keys.ahk",,max
return
;; RAlt -
;; Minimize current window
<^>!-::
WinMinimize, A
return
;; RAlt Esc
;; Close current window
<^>!Esc::
WinClose, A
return
;; RAlt ]
;; Send winow to other monitor
<^>!]::
Send #+{Right}
return
;; RAlt Shift V
;; Open VIM with admin privileges
<^>!+v::
Run *RunAs "C:\tools\neovim\Neovim\bin\nvim-qt.exe"
return
;; RAlt Shift P
;; Open putty
<^>!+p::
Run, "C:\ProgramData\chocolatey\bin\PUTTY.EXE"
Return
;; RAlt F8
;; Connect LSPL VPN
<^>!F8::
Run, "C:\Program Files\SoftEther VPN Client\vpncmd_x64.exe" /client localhost /cmd accountconnect lspl
Return
;; RAlt Shift F8
;; Disconnect LSPL VPN
<^>!+F8::
Run, "C:\Program Files\SoftEther VPN Client\vpncmd_x64.exe" /client localhost /cmd accountdisconnect lspl
Return
;; RAlt A
;; Android studio
<^>!a::
ActivateOrLaunch("Android Studio", "C:\Program Files\Android\Android Studio\bin\studio64.exe")
return
;; RAlt J
;; Open Jitsi
<^>!j::
InputBox, slug, Open Jitsi, Enter jitsi slug,,180,150,,,,,lsplshrayasr
if ErrorLevel
return
url:="https://meet.jit.si/" . slug
Run, %url%
return
;; RAlt Shift J
;; Open Jitsi for standup meeting
<^>!+j::
MsgBox, 4,, Connect to LSPL Standup Meeting?
IfMsgBox Yes
{
Run, "https://meet.jit.si/lspl-standup-meeting"
}
return
;; RAlt F3
;; Start Guby VM
<^>!F3::
Run, "C:\Program Files\Oracle\VirtualBox\vboxmanage.exe" startvm "Guby" --type headless
Return
;; RAlt Shift F3
;; Save Guby VM state
<^>!+F3::
Run, "C:\Program Files\Oracle\VirtualBox\vboxmanage.exe" controlvm "Guby" savestate
Return
;; RAlt X
;; Copy contents of the current selection and open it in typora
<^>!x::
originalClipboard := ClipboardAll
Send, ^c
ClipWait, 3
FileDelete, D:\dump\typora.md
Sleep, 100
FileAppend, %Clipboard%, D:\dump\typora.md
Run, "C:\Program Files\Typora\Typora.exe" "D:\dump\typora.md"
Clipboard := originalClipboard
Return
;; RAlt + Shift + X
;; Open typora, copy contents of typora to clipboard
;; Save typora
;; Close typora
<^>!+x::
ActivateIfExists("Typora")
Send, ^a
Send, ^c
ClipWait, 3
Sleep, 100
WinMinimize, A
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment