自动热键脚本退出VMWare窗口


1

要从XP系统上的VMWare控制台窗口退出,我需要:

  • 同时按下两个Shift键
  • 按Cntrl-Alt

有谁知道我该怎么做?

Answers:


2

以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

1

在您的AHK脚本中尝试以下操作:

send ^!{LShift}{RShift} ; send ctrl+alt+left shift+right shift

没运气。当我进入VMWare控制台窗口并为上面的代码做我的热键时,仅显示热键字符“ v”。
比尔

尝试使用SendPlay代替Send。如果这不起作用,请尝试SendInput。AHK有多种发送模式,哪种模式有时取决于应用程序。
martineau 2011年

仍然没有运气。在VMWare控制台窗口中时,某些东西必须抓住键盘。我注意到,我拥有的另一个热键(简单字符扩展)在VMWare控制台窗口中时也无法起作用。
比尔

1

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
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.