Autohotkey script to exit VMWare window

autohotkey

To exit from a VMWare console window on my XP system, I need to:

  • Press both Shift keys
  • Press Cntrl-Alt

Does anyone know how I can do this in Autohotkey?

Best Answer

Russell's answer gets you a large chunk of the way there using RDP as an example. It's a little harder to detect that you're in vsphere/vmware console but can be done with the below. I've commented the changes/additions

#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) 
}

I use this to allow play/pause media keys to work in both rdp/vsphere

Media_Play_Pause::
  Sleep 50
  Run "C:\Foobar2000\foobar2000.exe" /playpause
return