How to use Hotkeys in Virtual Machine Window

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
ibieel
Posts: 216
Joined: 17 Oct 2021, 23:30

How to use Hotkeys in Virtual Machine Window

Post by ibieel » 12 Sep 2023, 23:03

hey guys, I use several virtual machines simulating environments to be more efficient when testing some features.

However, I have a problem, I would like to create a script in which when I press "1" or "2" or "3" I switch between the virtual machines open on my HOST computer (WinActivate)

I used the script below on my main computer (HOST)

Code: Select all

1::
WinActivate, Virtual Machine 01
RETURN

two::
WinActivate, Virtual Machine 02
RETURN

3::
WinActivate, Virtual Machine 03
RETURN
The following problem is occurring, when a virtual machine is in focus (main/focus window) the script running on the HOST machine cannot identify that the hotkeys are being pressed.

The hotkeys only work again when I remove focus from the virtual machine and select a window on the HOST computer. :oops:

Does anyone have an idea how I can fix this?
thank you for your attention
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: How to use Hotkeys in Virtual Machine Window

Post by mikeyww » 13 Sep 2023, 04:19

Hello,

You might want to search forum for this topic; there are other posts & solutions. Could run the script on the VM?
User avatar
ibieel
Posts: 216
Joined: 17 Oct 2021, 23:30

Re: How to use Hotkeys in Virtual Machine Window

Post by ibieel » 13 Sep 2023, 13:10

mikeyww wrote:
13 Sep 2023, 04:19
Hello,

You might want to search forum for this topic; there are other posts & solutions. Could run the script on the VM?

Thanks for the answer, I searched and didn't find exactly what I wanted.

I don't want to run scripts on a VM, I'm running a script on the HOST computer, however, the "HOTKEYS" part is not working, it only works when I have the focus/main on a window on the HOST computer

If I am using a virtual machine window, the HOST computer cannot recognize which keys on my keyboard are being pressed.

It seems that when a virtual machine window is open, keystroke commands do not go through the HOST computer
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: How to use Hotkeys in Virtual Machine Window

Post by mikeyww » 13 Sep 2023, 13:17

Right, hence my suggestion. That's all I have! Others may know more.
User avatar
ibieel
Posts: 216
Joined: 17 Oct 2021, 23:30

Re: How to use Hotkeys in Virtual Machine Window

Post by ibieel » 13 Sep 2023, 13:32

mikeyww wrote:
13 Sep 2023, 13:17
Right, hence my suggestion. That's all I have! Others may know more.
image.png
image.png (60.55 KiB) Viewed 400 times
maybe with this debugger you can get some idea.
see that the computer understands that a key was pressed, but cannot tell which one it was.
Have you ever seen this before?
User avatar
ibieel
Posts: 216
Joined: 17 Oct 2021, 23:30

Re: How to use Hotkeys in Virtual Machine Window

Post by ibieel » 13 Sep 2023, 13:37

image.png
image.png (67.41 KiB) Viewed 398 times
.


some keys with Shift, Alt, Ctrl, Capslock, NumLock, Scroll Lock are recognized
despite this, if I use the command "P" in GetKeyState, the script does not recognize that Shift was pressed.

Code: Select all

#InstallKeybdHook
#Persistent
KeyHistory

Loop, {
	if (GetKeyState("LShift")) {		;works
		ToolTip, hello
	}
	if (GetKeyState("LShift", "P")) {	;DONT works
		ToolTip, hello
	}
}
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: How to use Hotkeys in Virtual Machine Window

Post by mikeyww » 13 Sep 2023, 13:46

Probably nothing informative here. Others can chime in.
Post Reply

Return to “Ask for Help (v1)”