Answers:
以RDP为例,Russell的答案为您提供了很多帮助。很难确定您是否处于vSphere / vmware控制台中,但是可以通过以下操作来完成。我已评论了更改/添加
#UseHook
#SingleInstance force
; A window's title can contain WinTitle anywhere inside it to be a match
SetTitleMatchMode, 2
setTimer, windowWatch, 500
windowWatch:
; if rdp OR (partial title matching vsphere AND you are in the console captured section)
if WinActive("ahk_class TscShellContainerClass") or (WinActive(" - vSphere Client") and Control("MKSEmbedded1")) {
if (!active) {
active := true
Sleep 50
suspend off
}
} else {
active := false
suspend on
}
return
; return ClassNN of mouse position
Control(ClassNN) {
MouseGetPos,,,,control
return (ClassNN = control)
}
我用它来允许播放/暂停媒体键在rdp / vsphere中都可以使用
Media_Play_Pause::
Sleep 50
Run "C:\Foobar2000\foobar2000.exe" /playpause
return
在您的AHK脚本中尝试以下操作:
send ^!{LShift}{RShift} ; send ctrl+alt+left shift+right shift
SendPlay
代替Send
。如果这不起作用,请尝试SendInput
。AHK有多种发送模式,哪种模式有时取决于应用程序。
VMWare最有可能安装自己的键盘挂钩,该键盘挂钩优先于AHK的键盘挂钩。运行远程桌面客户端时,会发生相同的问题。解决方法是经常检查目标窗口是否处于活动状态,然后重新安装AHK的挂钩。可以通过挂起然后再挂起AHK来重新安装该挂钩。
这是我的远程桌面脚本,应该可以轻松地为VMWare进行自定义:
; Script by Russell Davis, http://russelldavis.blogspot.com/
; with inspiration from http://www.autohotkey.com/forum/topic5702.html
; and http://www.autohotkey.com/forum/topic1662.html
#UseHook
#SingleInstance force
setTimer, windowWatch, 500
windowWatch:
if WinActive("ahk_class TscShellContainerClass") {
if (!active) {
active := true
; Short sleep to make sure remote desktop's hook is in place first
Sleep 50
; Coming out of suspend mode recreates the keyboard hook, giving
; our hook priority over the remote desktop client's.
suspend off
}
} else {
active := false
suspend on
}
return
; Be careful if using a hotkey with an Alt or Win modifier. The modifier's
; keyup event may trigger a system action. AHK is supposed to work around this,
; but it doesn't seem to work in this case.
; See http://www.autohotkey.com/forum/topic22378.html for a related discussion.
^+CapsLock::
; Need a short sleep here for focus to restore properly.
Sleep 50
WinMinimize ahk_class TscShellContainerClass
return