这算是AHK最常用的功能了。
^Up:: ;-- 【Ctrl+Up】增大音量
~RButton & WheelUp:: ;-- 【按住右键+滚轮上滚】增大音量
SoundSet, +5
SoundGet, i
Tip("当前音量:" Round(i))
SetTimer, RButtonUp, 20
return
^Down:: ;-- 【Ctrl+Down】减小音量
~RButton & WheelDown:: ;-- 【按住右键+滚轮下滚】减小音量
SoundSet, -5
SoundGet, i
Tip("当前音量:" Round(i))
SetTimer, RButtonUp, 20
return
Tip(s:="") {
SetTimer, %A_ThisFunc%, % s="" ? "Off" : -2000
ToolTip, %s%
}
RButtonUp(t="") {
static init, f1, f2, x, y
ListLines, Off
if (!init)
{
init:=1
f1:=Func(A_ThisFunc).Bind("On")
f2:=Func(A_ThisFunc).Bind("Off")
}
if (t="")
{
if GetKeyState("RButton", "P")
return
CoordMode, Mouse
MouseGetPos, x, y
SetTimer, % A_ThisFunc, Off
SetTimer, % f1, 20
SetTimer, % f2, 400
%f1%()
}
else if (t="On")
{
DetectHiddenWindows, Off
WinGet, list, List, ahk_class #32768
Loop, % list
{
id:=list%A_Index%
WinGetPos, x1, y1, w, h, ahk_id %id%
x2:=x1+w-1, y2:=y1+h-1
if Abs(x-x1)+Abs(y-y1)<10 or Abs(x-x1)+Abs(y-y2)<10
or Abs(x-x2)+Abs(y-y1)<10 or Abs(x-x2)+Abs(y-y2)<10
{
%f2%()
WinHide, ahk_id %id%
return
}
}
}
else if (t="Off")
{
SetTimer, % f1, Off
SetTimer, % f2, Off
}
}