用AutoHotkey调整Windows音量
我用了【右Alt】+方向键来调整音量:Alt+上下键,音量调整幅度为5,如果再增加个右Ctrl,音量调整幅度为1。
Alt+左键为静音,Alt+右键为最大音量。
>!Up:: ;音量+5 <!Down:: ;音量-5 ^!Up:: ;音量+1 ^!Down:: ;音量-1 Sound_Add := InStr(A_ThisHotkey, "^") ? 1 : 5 If InStr(A_ThisHotkey, "Up") hyf_SoundSetWaveVolume("+", Sound_Add) Else hyf_SoundSetWaveVolume("-", Sound_Add) Return >!Left:: ;静音 {{{2 >!Right:: ;音量最大 {{{2 hyl_VolumeMinMax: Sound_Add := InStr(A_ThisHotkey, "Left") ? 0 : 100 SoundSet, Sound_Add, , , DeviceNumber hyf_tooltip("音量 " . Sound_Add, 1, 0, A_ScreenWidth, A_ScreenHeight) Return hyf_SoundSetWaveVolume(mode, n) { ;mode为"+"或"-" SoundGet, Sound_Get, , , DeviceNumber Sound_Get := Round(Sound_Get) If (n = 5 && (numMod := Mod(Floor(Sound_Get), 5))) ;调整到5的倍数 Sound_Get -= numMod If (mode = "+") { Sound_Now := Floor(Sound_Get) + n If (Sound_Now > 100) { hyf_tooltip("音量+ 100", 1, 0, A_ScreenWidth, A_ScreenHeight) Return } } Else { Sound_Now := Floor(Sound_Get) - n If (Sound_Now < 0) { hyf_tooltip("音量- 0", 1, 0, A_ScreenWidth, A_ScreenHeight) Return } } SoundSet, Sound_Now, , , DeviceNumber hyf_tooltip("音量" . mode . " " . Sound_Now, 1, 0, A_ScreenWidth, A_ScreenHeight) Return } hyf_tooltip(str, t := 1, ExitScript := 0, x := "", y := "") ;提示t秒并自动消失 {{{3 { t *= 1000 ToolTip, %str%, %x%, %y% SetTimer, hyf_removeToolTip, -%t% If ExitScript { Gui, Destroy Exit } } hyf_removeToolTip() ;清除ToolTip {{{3 { ToolTip }