- 最简单的方式-使用ahk API
^XButton2:: Send "{Volume_Up}"
^XButton1:: Send "{Volume_Down}"
- 使用DllCall
^Ins:: SetVolume("Up")
^Del:: SetVolume("Down")
^PrintScreen:: SetVolume("Mute")
SetVolume(LPARAM) {
static WM_APPCOMMAND := 0x319
static APPCOMMAND_VOLUME_MUTE := 0x80000
static APPCOMMAND_VOLUME_UP := 0xA0000
static APPCOMMAND_VOLUME_DOWN := 0x90000
switch LPARAM {
case "Up": APPCOMMAND_VOLUME_TYPE := APPCOMMAND_VOLUME_UP
case "Down": APPCOMMAND_VOLUME_TYPE := APPCOMMAND_VOLUME_DOWN
case "Mute": APPCOMMAND_VOLUME_TYPE := APPCOMMAND_VOLUME_MUTE
}
HWorkerW := WinGetID("ahk_class WorkerW")
DllCall("SendMessage", "UInt", HWorkerW, "UInt", WM_APPCOMMAND, "UInt", 0, "UInt", APPCOMMAND_VOLUME_TYPE)
}
标签:APPCOMMAND,AHK2,VOLUME,static,UInt,TYPE,音量控制,SetVolume
From: https://www.cnblogs.com/refiz/p/17538622.html