2

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?

3 Answers 3

3

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
1

Try this in your AHK script:

send ^!{LShift}{RShift} ; send ctrl+alt+left shift+right shift
3
  • No luck. When I'm inside the VMWare console window and do my Hotkey for the code above, just the Hotkey character "v" gets displayed.
    – Bill
    Jan 13, 2011 at 16:16
  • Try using SendPlay instead of Send. If that doesn't work try SendInput. AHK has a variety of send modes and which one works sometimes depends on the application.
    – martineau
    Jan 13, 2011 at 16:32
  • Still no luck. Something must be grabbing the keyboard when inside the VMWare console window. I notice that another hotkey I have (simple character expansion ) also isn't able to function when it's inside the VMWare console window.
    – Bill
    Jan 13, 2011 at 18:12
1

VMWare is most likely installing its own keyboard hook which takes precedence over AHK's. The same problem occurs when running a Remote Desktop client. The solution is to check whether the target window is active every so often and reinstall AHK's hook if it is. The hook can be reinstalled by suspending and then unsuspending AHK.

Here's my script for Remote Desktop that should be easily customizable for 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .