Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
AutoHotKey Script
; #NoEnv is recommended for performance and compatibility with future AutoHotkey releases.
#NoEnv
; Enable #Warn to assist with detecting common errors.
#Warn
; Recommended for new scripts due to its superior speed and reliability.
SendMode Input
; Ensures a consistent starting directory.
SetWorkingDir %A_ScriptDir%
; Window titles can contain WinTitle anywhere inside it to be a match.
SetTitleMatchMode, 2
;--------------------------------------------------------------------
; Set NumLock to always be enabled
;--------------------------------------------------------------------
SetNumlockState, AlwaysOn
return
;--------------------------------------------------------------------
; Scroll through browser tabs
;--------------------------------------------------------------------
+WheelDown::Send, ^+{TAB}
+WheelUp::Send, ^{TAB}
;--------------------------------------------------------------------
; Close (hit Capslock) / Minimize (hold Capslock & release) active window
;--------------------------------------------------------------------
$Capslock::
; Wait no more than 'n' seconds for key release (also suppress auto-repeat)
KeyWait, Capslock, T0.2
; timeout, so key is still down...
if ErrorLevel
{
KeyWait, Capslock, T1.5
; No timeout, so key was released
if !ErrorLevel
{
WinMinimize, A
return
}
; Wait for button to be released
WinMinimize, A
return
}
else
{
if (WinActive("ahk_exe chrome.exe") || WinActive("ahk_exe code.exe") || WinActive("ahk_exe devenv.exe"))
{
Send ^w
return
}
else
{
WinClose, A
return
}
}
;--------------------------------------------------------------------
; Google the highlighted selection
;--------------------------------------------------------------------
^+q::
{
Send, ^c
Sleep 50
Run, https://www.google.com/search?q=%clipboard%
return
}
return
;--------------------------------------------------------------------
; Input ryanbuening@gmail.com
;--------------------------------------------------------------------
^+e::
{
Text = ryanbuening@gmail.com
Send %Text%
return
}
;--------------------------------------------------------------------
; Application Hotkeys
;--------------------------------------------------------------------
^+NumpadAdd:: LaunchShowOrHide("SpotifyMainWindow", "C:\Users\buenry1\AppData\Roaming\Spotify\Spotify.exe")
^+NumpadEnter::Run calc.exe
^+Space::Run https://www.google.com
;--------------------------------------------------------------------
; Toggle mute for Microsoft Teams
;--------------------------------------------------------------------
Pause::
; Get IDs for all teams windows
WinGet, id, list, ahk_exe Teams.exe
; Loop through IDs of all teams windows
Loop, %id%
{
this_ID := id%A_Index%
; Get the title of the current window
WinGetTitle, Title, ahk_id %this_ID%
; Make sure title is not the notification
if Title <> Microsoft Teams Notification
{
; Screen sharing win uses null title, make sure the win does not have a null title
if Title <>
{
; This should be the correct win, activate it
WinActivate, ahk_id %this_ID%
; Send Ctrl Shift M shortcut
Send, ^M
; There are two teams windows, the main win and the meeting win, break the loop so that the mute commmand doesnt get sent twice
break
}
}
}
return
;--------------------------------------------------------------------
; Media Hotkeys
;--------------------------------------------------------------------
^+NumpadDiv::Send {Media_Play_Pause}
^+NumpadMult::Send {Media_Prev}
^+NumpadSub::Send {Media_Next}
^+PgUp::Send {Volume_Up}
^+PgDn::Send {Volume_Down}
;--------------------------------------------------------------------
; Change volume using mouse scroll wheel over taskbar
;--------------------------------------------------------------------
#if MouseIsOver("ahk_class Shell_TrayWnd") || MouseIsOver("ahk_class Shell_SecondaryTrayWnd")
WheelUp::
Send {Volume_Up}
return
WheelDown::
Send {Volume_Down}
return
MouseIsOver(WinTitle)
{
MouseGetPos,,, Win
return WinExist(WinTitle . " ahk_id " . Win)
}
;--------------------------------------------------------------------
; Run / Activate / Minimize Window
;--------------------------------------------------------------------
LaunchShowOrHide(WindowName, RunName)
{
if WinActive("ahk_class " . WindowName)
{
WinMinimize
}
else if WinExist("ahk_class " . WindowName)
{
WinActivate
}
else
{
Run %RunName%
}
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment