要退出 XP 系统上的 VMWare 控制台窗口,我需要:
- 按下两个 Shift 键
- 按 Cntrl-Alt
有人知道如何在 Autohotkey 中做到这一点吗?
答案1
Russell 的回答以 RDP 为例,为你提供了很大帮助。检测你是否在 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
答案2
在你的 AHK 脚本中尝试这个:
send ^!{LShift}{RShift} ; send ctrl+alt+left shift+right shift
答案3
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