Mingo
Mingo

Reputation: 1613

how to use autohotkey to send a key to virtualbox

I installed virtualbox in my Windows 7 and installed the Ubuntu as guest os.

I want to press a key(Alt+F1) to activate the Ubuntu and send continue send the same key to Ubuntu and then Ubuntu will active the problem inside Ibuntu.

That means I want to press one key to activate the program in Ubuntu. I think autohotkey script can do it. But I do not know how.

Upvotes: 2

Views: 3955

Answers (3)

As of writing I've updated to Version 6.1.38 r153438 (Qt5.6.2), but I don't think this is new except for me.

As per 1.8.2. Capturing and Releasing Keyboard and Mouse In the lower right corner of the guest window, there is a button with a downward arrow. This indicates if the keyboard is being captured or not. If you hover your cursor over it, a tool tip will tell you the meaning. The keyboard shortcut to toggle this is Host+k.

The default behavior is to capture, to prevent this and send keys from your AHK script, right click it, choose "Keyboard settings...", in the dialogue un-tick "Auto capture keyboard" check box. The problem with this is that every time you want to send keys like Win, it opens the host menu instead of the guest one, so you need to toggle manually every time to send the key to the guest OS.

Alternatively, Virtaualbox may be allowed to capture the keyboard and use a guest side automation solution. I suggest alternativeto.net/software/autohotkey/?platform=linux this last may be replaced by your guest OS.

Upvotes: 2

nobody
nobody

Reputation: 1

Since Gnome can capture ctrl+click and alt+click, I use:

+RButton:: SendInput {Click, middle} return

to send middle-click from trackpad to vbox linux in win7.

Use on your own risk.

Upvotes: 0

Brigand
Brigand

Reputation: 86240

You can try WinActivate on the VirtualBox window, and follow that with SendInput commands. Since VirtualBox uses all sorts of low level hooks, I don't know how well it will respond to key sending.

Since it is a Windows application, there's a chance it will accept other Windows messages. The ControlSend command may be useful, but I don't know if VBox will pass on the keys to the guest OS.

AutoHotkey struggles with low-level applications. Some software, such as games, deliberately prevent artificial input. Others just do it naturally, for example, VirtualBox.

Upvotes: 2

Related Questions