How do I make a hotkey to activate a specific VMware Workstation VM?

1

0

I'm using the latest version of VMware Workstation (11.1.0) on Windows 7 x64 and I want to be able to do a keystroke of "Ctrl + 1" to go to VM #1, "Ctrl + 2" to go to VM #2, and "Ctrl + 3" to go to VM #3.

Sounds simple right? It isn't.

On Mac OS X, achieving this functionality is trivial with VMware Fusion in combination with Spaces / Mission Control - you can simply put each VM on a separate space and then define whatever space hotkeys you want. I'm migrating from OS X and want this same functionality.

For reference, here are some potential solutions that I've tried and can verify that they don't work:

1) AutoHotkey

AutoHotkey can be used to make hotkeys like so:

^1::WinActivate, Win7(1) - VMware Workstation
^2::WinActivate, Win7(2) - VMware Workstation
^3::WinActivate, Win7(3) - VMware Workstation

These work to enter the VMs, but not to exit; Workstation will feed the "Ctrl + 1" to the VM and AutoHotkey does not take precedence, even if AutoHotkey is run as an administrator.

2) Suspend/Unsuspend with AutoHotkey

This promising post from Nick Sturgess suggests that suspending and that unsuspending AutoHotkey while the VMware window is active will fix the problem.

However, even after copying the exact code and making the necessary string modifications, I can't get it to work with Workstation.

3) Remote Desktop and/or VNC

One possible solution, if all 3 of the VMs in question were running Windows, would be to use Microsoft's Remote Desktop feature. However, one or more of the VMs that I intend to use will be running Linux.

On Linux, it is possible to just use VNC. However, VNC has considerable drawbacks when compared to the native VMware Workstation console window: there is no sound, the resolution won't automatically scale, the performance will be bad, and so forth.

Lastly, the VMs will be on 1) networks that won't be connected to the host via a bridged NIC (with the NIC disabled on the host) and 2) using a VPN without any split tunnel. So there will be no connectivity for either remote desktop or VNC in the first place.

4) A Windows Keyboard Hook

Liuk explains how to use a Windows hook to intercept keystrokes using C++ in this informative post.

However, after testing with the demo program, it seems that this method does not intercept keystrokes sent to VMware Workstation.

5) FullScreenSwitch.directKey

It seems that in VMware Workstation used to have this kind of functionality built in, as documented in this SuperUser thread.

However, VMware's documentations states that this is for VMware Workstation 5.0. I tried adding these strings to my VMX file and they had no effect, so it appears that this functionality may have been depreciated somewhere along the lines between Workstation 5 and 11.

6) PSExec

Wade Hatler mentions that he accomplishes this using PSExec to activate the appropriate AutoHotkey script on the host machine in this forum post.

This solution is questionable in that you have to keep the password of your host machine in plaintext in order to pass it to PSExec.

Regardless, this solution will not work for the reasons also described in #3 above: the VMs in question will be on 1) networks that won't be connected to the host via a bridged NIC (with the NIC disabled on the host) and 2) using a VPN without any split tunnel. So there will not be guaranteed connectivity between the host and the guest.

7) Execute a "Host" keystroke between every "Ctrl + #" keystroke

I use "Ctrl" as my VMware Workstation Host hotkey rather than the default of "Ctrl + Alt", because it is much faster to activate. Even with this optimization, I have to press and completely release Ctrl in order for input to be relinquished from a VM. Only then can I utilize my AutoHotkey hotkeys from #1 above.

This becomes problematic in the situation where I need to quickly flip through different VMs and perform a bit of work (keystrokes) on each one. The amount of keyboard input in order to switch to each VM is essentially doubled, so this is not an adequate solution.

8) Use the "Host + Left/Right Arrow" hotkey and/or VMware-KVM.exe for cycling functionality

This is problematic in that when I have 10 or more VMs open at a time, rotating through all of them becomes incredibly cumbersome and inefficient.

9) Programs that emulate OS X Spaces / Mission Control

Windows programs such as Dexpot, Desktops, and Virtual Dimensions all allow Spaces-like functionality on Windows. However, these 3 programs in particular all have the same problem that AutoHotkey has - the hotkeys to activate a particular desktop are preempted by VMware workstation and not passed to the host machine.

James

Posted 2015-04-03T18:35:30.093

Reputation: 281

Can you elaborate on #6? Does that work? In what way is it problematic? – fixer1234 – 2015-04-08T19:13:43.830

It seems like the current VMware keyboard driver does not implement any of the methods used by previous versions to allow some key-combinations to be passed to the host while the guest holds the focus. This driver apparently works in Windows on such a low system level, that even a key-logger that I tried couldn't detect any key event. I don't know if that was indeed done by VMware on purpose, but I'm starting to suspect that this question might not have an answer that is keyboard-based. – harrymc – 2015-04-08T19:28:06.430

Fixer1234 - I have edited my post and made #6 more verbose. – James – 2015-04-08T19:37:12.420

I don't understand why you have ruled-out RDP or VNC (some variants do support audio). From Comparison of remote desktop software it seems that the following support audio and have free versions : rdektop, QVD, FreeRDP (I've no experience with them).

– harrymc – 2015-04-08T19:42:35.490

For RDP to work there has to be some sort of network connectivity between the host and the guest. Please see the third paragraph of #3 above. – James – 2015-04-08T20:18:30.910

I can't understand that statement, since there's always connectivity between the host and guests via virtual adapters. – harrymc – 2015-04-09T10:38:02.683

When certain types of VPN connections are established, all traffic is forced to go through the VPN connection by the VPN software for security reasons. I need to use such VPN connections on a VM. – James – 2015-04-09T12:36:00.643

Answers

0

The answer below, while correct for most products, does not work for VMware or other products that take priority control of the keyboard.

It turns out that the current version of VMware installs a keyboard handler in Windows, that when VMware has the focus, intercepts with priority all keyboard keys and does not pass practically any to the host, except for Ctrl-Alt-Del if Enhanced Virtual Keyboard is not enabled.

Methods that worked in previous versions, such as the pass-through of all Ctrl+Alt combinations, have for some unknown reason now been omitted in VMware.

Now add to this the usage in the VM of a blocking VPN server, which blocks out the entire local network, leaveing us only the host keyboard and mouse as possible mechanisms, to now have a real big problem.

I can see only two solutions :

  1. Mouse oriented: Use a virtual desktops product such as Dexpot that has a graphical console so desktops are switched with a click,
  2. Keyboard oriented: Requires switching from VMware to VitualBox or Hyper-V who might let the host intercept some more keyboard events (experimenting is required).

A solution under Windows is to create multiple virtual desktops and assigning each VM to its own virtual desktop.

The following free virtual desktop products support global hotkeys :

Dexpot
The most feature-complete. See this how-to article on using mouse gestures and hotkeys.

Desktops
Created by the Microsoft Fellow Mark Russinovich, it should have the best integration with Windows.

Virtual Dimension
I have no personal experience with it.

harrymc

Posted 2015-04-03T18:35:30.093

Reputation: 306 093

I just tried all 3 of these programs, and on my Windows 7 x64, none of them will preempt VMware Workstation from capturing the hotkeys, even after running them administratively. Did you actually test the functionality of these programs with VMware Workstation before posting your answer? – James – 2015-04-07T20:16:26.250

I didn't test specifically with VMware. These products work generally correctly, except apparently with VMware. This means that VMware installs its own preemptive keyboard driver, so one is obliged to work thru/around VMware. Disabling "Grab when cursor enters window" maybe could help somewhat. VMware hotkeys do exist for next- and previous-VM. For more than that, the manual says "combinations that include Ctrl-Alt are not passed to the guest operating system", so you could maybe use Ctrl-Alt-1, 2 etc. – harrymc – 2015-04-08T06:03:54.473

>

  • Yes, in my research I have found articles describing how VMware installs its own keyboard driver. 2) Disabling "Grab when cursor enters window" does not help. I am active within the VM when I need to execute the hotkey, so it will always have focus already; that is the entire point of this question. 3) I already mentioned the next/previous hotkeys in my original post as #7 above.
  • < – James – 2015-04-08T06:16:59.543

    That leaves the Ctrl-Alt option, if it works for you. – harrymc – 2015-04-08T08:06:29.110

    Hotkeys created in AutoHotkey with Ctrl+Alt+whatever are preempted as well. Can you confirm that it works for you? – James – 2015-04-08T12:55:30.543

    Verified that nothing works with the keyboard driver of Workstation 11: Tried ctrl-alt-del in the VM, and to my great surprise BOTH guest and host went into that screen. So the driver both intercepts it and lets it thru. My opinion now iş, since this behavior contradicts the manual, that you should file a bug-report with VMware Support. – harrymc – 2015-04-08T13:46:50.150

    Can you link the part of the Workstation 11 manual that describes this particular Ctrl+Alt functionality? – James – 2015-04-08T14:37:42.817

    I take my words back: These VMware guys are too smart for me - they changed the latest manual to include all these strange behaviors, so these have become "features". The double ctrl-alt-del was because the Enhanced Virtual Keyboard wasn't enabled. Otherwise, there doesn't seem to be any documented way to escape hotkeys from the VM, and I haven't found any undocumented one, except maybe one, detailed below. – harrymc – 2015-04-08T15:28:00.723

    As a hack, one could maybe for example use the VM -> Power menu shortcuts of VMware to control 4 desktops. The assumption is that these shortcuts, Ctrl-B/E/J/R, are being let thru to Windows. In that case, one can use a resource hacker to disable them in the VMware menu, so it will let them thru to Windows so the virtual desktop product can then grab them. Apart from this, the only idea I have left is to contact VMware Support (but don't hope for too much). VMware has defeated me in every turn. Unfortunately, nobody else on this forum seems to have a better idea. – harrymc – 2015-04-08T15:40:59.893

    The hotkeys for the menu shortcuts that you speak of are not actually let through to the host, so a hack to disable or remap them would be pointless. – James – 2015-04-08T16:32:09.317

    If that's the case then I'm out of ideas. Sorry. I will delete this answer if you don't mind. – harrymc – 2015-04-08T16:39:15.883

    I dont mind, thank you very much for the help though! – James – 2015-04-08T16:39:44.717

    I just tried out Dexpot with VirtualBox and the hotkeys are being preempted just like they do in VMware. Did you verify that these 3 programs actually work with VirtualBox before posting your answer? – James – 2015-04-11T06:03:22.607

    I can test only what exists in my personal environment. However, In my tests I have managed to escape the VMware keyboard driver. Here's how: I have a programmable Cherry keyboard that comes with configuration program called KeyMan (which I don't use since I prefer AutoHotKey). I have verified that this program's driver has the priority and intercepts its defined hotkeys before VMware does. If you have a similar programmable keyboard with its utility, this could be a solution. – harrymc – 2015-04-11T13:03:49.697

    Otherwise, have a look at the products listed in the article Best Free Hotkey or Macro Recorder Utility (also the comments). Some of them are said to intercept hotkeys well before Windows, so maybe also before VMware.

    – harrymc – 2015-04-11T13:05:14.817

    Please edit/delete your answer, as it is inaccurate: "while correct for any other product" - is not actually correct for any product. – James – 2015-04-14T20:12:51.940

    Yes, of course. That sentence just expressed my frustration with that not very forward-thinking keyboard driver of VMware. – harrymc – 2015-04-14T21:58:36.370