• 最简单的方式-使用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)
}
posted on 2023-07-09 13:08  落寞的雪  阅读(115)  评论(0编辑  收藏  举报