问题
I'm logged into a virtual machine using vmware workstation 6.5-7.0.1 or vmware player 3.0.0. I'm working inside the virtual machine. Then I press a key (for example the Delete-Key, but it should work with every key) inside the virtual machine.
I want to recognize the "key-press-event" in my C# application which is running outside of the virtual machine.
Can you think of any way to do this?
回答1:
I am not 100% sure if you can actually hook into the VM unless there's an SDK that you can download to intercept it, remember the VMWare is simulating a separate machine, but a logical one alright...The downloads are available here from VMWare.
I can only guess (I use Virtualbox myself), that a Virtual Machine (VMWare/VirtualBox) seizes control of the hooks for the keyboard I would imagine, the host system would not see them...but it would be interesting to try out... I have provided links to CodeProject for keyboard hooks...
- 'Using Windows Messages to implement global system hooks'
- 'EasyHook - The reinvention of Windows API Hooking'
- 'Global System Hooks in .NET'
- 'Global Mouse and Keyboard Library'
Find the one that would suit you in terms of ease-of-use, and try hook in the keyboard, run the VMWare, with your C# application running and see if it picks up any keys within the virtual machine... I would be interested to know...
And oh yeah, +1 from me for good question and welcome to SO! :)
Hope this helps, Best regards, Tom.
来源:https://stackoverflow.com/questions/2259430/how-to-get-keyboard-input-while-running-in-vmware-virtual-machine