Skip to content

Instantly share code, notes, and snippets.

@maciekish
Last active September 24, 2022 14:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maciekish/d41c7375e6ee495e4e841768f2f9b849 to your computer and use it in GitHub Desktop.
Save maciekish/d41c7375e6ee495e4e841768f2f9b849 to your computer and use it in GitHub Desktop.
AutoHotkey Scripts
#SingleInstance, Force
#NoTrayIcon
;-----------------------------ABOUT-------------------------------
; This script switches audio devices and launches Big Picture Mode
;-----------------------------HOW TO------------------------------
;- 1) Download NirCmd and run as admin to install to Win dir. -
;- http://nircmd.nirsoft.net/setdefaultsounddevice.html -
;- 2) Change Device names below to match your playback devices. -
;- 3) Change Steam path below to match where Steam is installed. -
;-----------------------------------------------------------------
; https://gist.github.com/maciekish/d41c7375e6ee495e4e841768f2f9b849#file-bigpicture-ahk
;-----------------------Variables & AUTORUN-----------------------
CoordMode, ToolTip, Screen
;------------------------Snippets of Code-------------------------
DesktopSound()
#B::
Toggle := !Toggle
If Toggle {
DesktopMode()
return
}
Else {
TVMode()
return
}
#S::
ToggleSound := !ToggleSound
If ToggleSound {
DesktopSound()
return
}
Else {
TVSound()
return
}
DesktopSound() {
run %ComSpec% /c nircmd.exe SetDefaultSoundDevice "Realtek Digital Output(Optical)" 0
run %ComSpec% /c nircmd.exe SetDefaultSoundDevice "Realtek Digital Output(Optical)" 1
run %ComSpec% /c nircmd.exe SetDefaultSoundDevice "Digital Audio (S/PDIF) (High Definition Audio Device)" 0
run %ComSpec% /c nircmd.exe SetDefaultSoundDevice "Digital Audio (S/PDIF) (High Definition Audio Device)" 1
run %ComSpec% /c nircmd.exe SetDefaultSoundDevice "Digital Audio" 0
run %ComSpec% /c nircmd.exe SetDefaultSoundDevice "Digital Audio" 1
run %ComSpec% /c nircmd.exe SetDefaultSoundDevice "Digital Audio (S/PDIF)" 0
run %ComSpec% /c nircmd.exe SetDefaultSoundDevice "Digital Audio (S/PDIF)" 1
run %ComSpec% /c nircmd.exe SetDefaultSoundDevice "HIFI DSD" 0
run %ComSpec% /c nircmd.exe SetDefaultSoundDevice "HIFI DSD" 1
run %ComSpec% /c nircmd.exe SetDefaultSoundDevice "Headset Earphone" 2
run %ComSpec% /c nircmd.exe SetDefaultSoundDevice "Speakers (Arctis Pro Wireless)" 2
}
TVSound() {
run %ComSpec% /c nircmd.exe SetDefaultSoundDevice "LG TV-8" 0
run %ComSpec% /c nircmd.exe SetDefaultSoundDevice "LG TV-8" 1
run %ComSpec% /c nircmd.exe SetDefaultSoundDevice "LG TV-8" 2
run %ComSpec% /c nircmd.exe SetDefaultSoundDevice "LG TV" 0
run %ComSpec% /c nircmd.exe SetDefaultSoundDevice "LG TV" 1
run %ComSpec% /c nircmd.exe SetDefaultSoundDevice "LG TV" 2
run %ComSpec% /c nircmd.exe SetDefaultSoundDevice "LG TV (NVIDIA High Definition Audio)" 0
run %ComSpec% /c nircmd.exe SetDefaultSoundDevice "LG TV (NVIDIA High Definition Audio)" 1
run %ComSpec% /c nircmd.exe SetDefaultSoundDevice "LG TV (NVIDIA High Definition Audio)" 2
run %ComSpec% /c nircmd.exe SetDefaultSoundDevice "LG TV (2- NVIDIA High Definition Audio)" 0
run %ComSpec% /c nircmd.exe SetDefaultSoundDevice "LG TV (2- NVIDIA High Definition Audio)" 1
run %ComSpec% /c nircmd.exe SetDefaultSoundDevice "LG TV (2- NVIDIA High Definition Audio)" 2
}
DesktopMode() {
ToolTip, Desktop Mode, 1280, 720
SetTimer, RemoveToolTip, 4000
run, "C:\Program Files (x86)\Steam\Steam.exe" -shutdown
run, C:\Windows\System32\DisplaySwitch.exe /internal
Send {Esc}
DesktopSound()
LivingRoomPowerOff()
ToggleHDR()
return
}
TVMode() {
ToolTip, TV Mode, 1280, 720
SetTimer, RemoveToolTip, 4000
LivingRoomPC()
Sleep, 2000
run, C:\Windows\System32\DisplaySwitch.exe /extend
Send {Esc}
Sleep, 5000
run, C:\Windows\System32\DisplaySwitch.exe /external
Send {Esc}
Sleep, 5000
ToggleHDR()
TVSound()
Sleep, 3000
TVSound()
Sleep, 1000
Run, "steam://open/bigpicture"
return
}
LivingRoomPC() {
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.Open("GET", "http://10.0.1.37:1880/livingroom/pc", true)
whr.Send()
;whr.WaitForResponse()
Sleep, 3000
}
LivingRoomPowerOff() {
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.Open("GET", "http://10.0.1.37:1880/livingroom/off", true)
whr.Send()
;whr.WaitForResponse()
Sleep, 3000
}
ToggleHDR() {
;Run, ms-settings:display
;SetTitleMatchMode, 2
;Sleep 1000
;WinActivate, Settings
;Send, `t
;Send, `t
;Send, " "
;Sleep 500
;Send !{f4}
;Sleep 100
}
RemoveToolTip:
SetTimer, RemoveToolTip, Off
ToolTip
return
#SingleInstance force
#NoTrayIcon
^b::
; https://gist.github.com/maciekish/d41c7375e6ee495e4e841768f2f9b849#file-manamana-ahk
IfWinNotExist Heroes of the Storm
return
WinActivate
Send, +b
Send {Enter}
Sleep, 100
Send, Mana, mana
Send {Enter}
Sleep, 3000
IfWinNotExist Heroes of the Storm
return
WinActivate
Send {Enter}
Sleep, 100
Send, Tu-tu tururu
Send {Enter}
return
#SingleInstance force
#NoTrayIcon
#F::
; https://gist.github.com/maciekish/d41c7375e6ee495e4e841768f2f9b849#file-misc-ahk
RunWait,sc stop "CLink4Service"
run %ComSpec% /c "taskkill /IM CorsairLink4.exe"
Sleep 1000
RunWait,sc start "CLink4Service"
run,"C:\Program Files (x86)\CorsairLink4\CorsairLink4.exe"
Sleep 3000
run %ComSpec% /c "taskkill /IM CorsairLink4.exe"
#SingleInstance, Force
#NoTrayIcon
; https://gist.github.com/maciekish/d41c7375e6ee495e4e841768f2f9b849#file-wake_monitor-ahk
#M::
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.Open("GET", "http://10.0.1.37:1880/gamingroom/monitor", false)
whr.Send()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment