Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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? Thanks, Bill

share|improve this question
add comment

3 Answers

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
share|improve this answer
add comment

Try this in your AHK script:

send ^!{LShift}{RShift} ; send ctrl+alt+left shift+right shift
share|improve this answer
    
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 '11 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 '11 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 '11 at 18:12
add comment

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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.