keyboard - 如何从 Apple 键盘发送 Windows Media 键

标签 keyboard autohotkey keyboard-events key-bindings

我在 Windows 7 上使用苹果键盘。我希望标有“媒体”功能的功能键(上一个、暂停/播放、下一个、静音、音量-、音量+)像键盘上的等效键一样工作Windows 键盘。

我试过这个自动热键脚本:

F7::Media_Prev
F8::Media_Play_Pause
F9::Media_Next
F10::Volume_Mute
F11::Volume_Down
F12::Volume_Up

查看 key 历史, key 似乎按预期重新映射,但它们没有任何效果。

一个工作的(即所有键都按预期工作并触发适当的媒体功能)Windows 媒体键盘看起来像这样:

VK  SC  Type    Up/Dn   Elapsed Key     Window
------------------------------------------------------------------------------------
B3  122 a   d   32.79   Media_Play_Pause    
B3  122 a   u   0.14    Media_Play_Pause    
B2  124 a   d   0.61    Media_Stop      
B2  124 a   u   0.17    Media_Stop      
AF  130 a   d   0.58    Volume_Up       
AF  130 a   u   0.17    Volume_Up       
AE  12E a   d   0.42    Volume_Down     
AE  12E a   u   0.16    Volume_Down     
B1  110 a   d   0.87    Media_Prev      
B1  110 a   u   0.14    Media_Prev      
B0  119 a   d   0.30    Media_Next      
B0  119 a   u   0.11    Media_Next      
AD  120 a   d   1.56    Volume_Mute     
AD  120 a   u   0.13    Volume_Mute     

使用上面引用的脚本,我从苹果键盘上看到了这个:

VK  SC  Type    Up/Dn   Elapsed Key     Window
------------------------------------------------------------------------------------
B1  010 i   d   0.00    Media_Prev      
76  041 h   u   0.09    F7              
B1  010 i   u   0.00    Media_Prev      
77  042 h   d   0.20    F8              
B3  022 i   d   0.00    Media_Play_Pause    
77  042 h   u   0.08    F8              
B3  022 i   u   0.00    Media_Play_Pause    
78  043 h   d   0.20    F9              
B0  019 i   d   0.00    Media_Next      
78  043 h   u   0.09    F9              
B0  019 i   u   0.00    Media_Next      
79  044 h   d   0.22    F10             
AD  020 i   d   0.00    Volume_Mute     
79  044 h   u   0.09    F10             
AD  020 i   u   0.00    Volume_Mute     
7A  057 h   d   0.19    F11             
AE  02E i   d   0.00    Volume_Down     
7A  057 h   u   0.09    F11             
AE  02E i   u   0.00    Volume_Down     
7B  058 h   d   0.65    F12             
AF  030 i   d   0.00    Volume_Up       
7B  058 h   u   0.08    F12             
AF  030 i   u   0.00    Volume_Up    

知道为什么这不起作用吗?

最佳答案

检查这个脚本是否有效:

它基本上将您选择的键映射到下一个、上一个、播放和暂停。

因此,您可以映射那些标有媒体功能的功能键。

关于音量控制,我去找找。

;
;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Windows 7
; Author:         Brian Kamrany
;
; Script Function: Control iTunes, Windows Media Player, and Winamp easily.

;Numpad Subtraction = next
;Numpad Multiplication = previous
;Numpad Division = pause/unpause

;Note: if you want to change the hotkeys to numpad numbers, you must add
;both the numpad number and it's alternate key.
;For example
;Numpad6::
;NumpadRight::
;(written like that) are both needed if you want to use 6 on the numpad as your hotkey

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
DetectHiddenWindows, on


NumpadSub::

if WinExist("ahk_class ITWindow") or WinExist("ahk_class iTunes")
{
   ControlSend, ahk_parent, ^{RIGHT}
}

IfWinExist, ahk_class WMPlayerApp
{
SetKeyDelay, 0, 1 ;otherwise doesn't work if currently in WMP window
ControlSend, ahk_parent, ^{f}
}

IfWinExist, ahk_class Winamp v1.x
ControlSend, ahk_parent, b

return


NumpadMult::

if WinExist("ahk_class ITWindow") or WinExist("ahk_class iTunes")
{
   ControlSend, ahk_parent, ^{LEFT}
}

IfWinExist, ahk_class WMPlayerApp
{
SetKeyDelay, 0, 1
ControlSend, ahk_parent, ^{b}
}

IfWinExist, ahk_class Winamp v1.x
ControlSend, ahk_parent, z

return


NumpadDiv::

if WinExist("ahk_class ITWindow") or WinExist("ahk_class iTunes")
{
   ControlSend, ahk_parent, ^{SPACE} ;control for better grip, otherwise doesn't work if were filtering songs
}

IfWinExist, ahk_class WMPlayerApp
{
SetKeyDelay, 0, 1
ControlSend, ahk_parent, ^{p}
}

IfWinExist, ahk_class Winamp v1.x
ControlSend, ahk_parent, c

return

感谢 Autohotkey 社区的 BrianKamrany

原帖here .

关于keyboard - 如何从 Apple 键盘发送 Windows Media 键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9775299/

相关文章:

c# - 不在焦点时将键盘输入发送到 Spotify

javascript - document.onkeydown 在 Firefox 中不起作用

java - Mac 上的 JButton 点击​​效果

android-emulator - 具有自定义构建的 Android 模拟器不接受键盘输入

objective-c - iOS - UITableView 底部单元格中带有文本字段

keyboard - 如何使用 Applescript 控制背光键盘?

winapi - 如何通过程序发送硬件级键盘输入?

Android 键盘处理入门?

autohotkey - 如何停止事件的AutoHotkey脚本?

autohotkey - 使用 AutoHotkey 控制操纵杆 Axis