Virtualbox questions.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
LAPIII
Posts: 668
Joined: 01 Aug 2021, 06:01

Virtualbox questions.

Post by LAPIII » 16 Mar 2022, 19:07

  1. Can I use Virtualbox in a virtual machine without installing mouse or keyboard hooks? I read that AutoHotkey can't send clicks or keystrokes.
  2. Can I set up using WinMenuSelectItem?
  3. Does anyone have any scripts for this app?

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Virtualbox questions.

Post by mikeyww » 17 Mar 2022, 08:38

Although I do not use Virtualbox, this AHK forum has a search form in the top right corner. When I tried it, there were 82 matches. Some of these might have scripts or answer the question, "Can I use Virtualbox in a virtual machine?"-- or you could always test it! :think:

LAPIII
Posts: 668
Joined: 01 Aug 2021, 06:01

Re: Virtualbox questions.

Post by LAPIII » 17 Mar 2022, 17:01

Am I missing something:

Code: Select all

#IfWinExist, ahk_exe VirtualBox.exe
#v::
WinMenuSelectItem, Oracle VM VirtualBox Manager,, Machine, New

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Virtualbox questions.

Post by mikeyww » 17 Mar 2022, 17:17

During your testing, I recommend removing the #If directive. I also suggest that Return should end a hotkey routine.

WinMenuSelect... works only in some programs. If not already mentioned elsewhere in the forum, others here can comment on whether it works in some way for Virtualbox.

LAPIII
Posts: 668
Joined: 01 Aug 2021, 06:01

Re: Virtualbox questions.

Post by LAPIII » 17 Mar 2022, 18:41

Oh I forgot the return, and still not working:

Code: Select all

IfWinExist, ahk_exe VirtualBox.exe
^+v::
WinMenuSelectItem, Oracle VM VirtualBox Manager,, Machine, New
return

Ctrl+N works as well as selecting menus with Alt with the first letter of the menu name and the arrow keys. Is there a way to tell this is a Win32 window?

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Virtualbox questions.

Post by mikeyww » 17 Mar 2022, 19:11

When I suggested removing #If, I did not suggest using If instead. Further, your new command will not work there, so I would remove it. During your testing, there is no need for the #If directive, because you are simply trying to see whether your menu selection command will work.

I do not know about your Win32 question, but perhaps running Window Spy will help you to confirm the WinTitle.

That's about all the help that I know how to offer on this one. Best wishes for success!

LAPIII
Posts: 668
Joined: 01 Aug 2021, 06:01

Re: Virtualbox questions.

Post by LAPIII » 11 Jun 2022, 21:14

Could you correct me? What I want to do is if Virtualbox isn't open then it will open and in either case it presses ^s.

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Virtualbox questions.

Post by mikeyww » 12 Jun 2022, 03:57

An example of how to run a program is below.

Code: Select all

proc     = C:\Windows\System32\notepad.exe ; Replace with your program's path
winTitle = ahk_exe %proc%
^+v::
Run, % WinExist(winTitle) ? "" : proc
WinWait, %winTitle%,, 5
If !ErrorLevel {
 WinActivate
 Send ^s
} Else MsgBox, 48, Error, Window not found.`n`n%winTitle%
Return

LAPIII
Posts: 668
Joined: 01 Aug 2021, 06:01

Re: Virtualbox questions.

Post by LAPIII » 12 Jun 2022, 09:27

Thanks, my I add this other script in front of it:

Code: Select all

FileSelectFile, OutputVar, Options, ::{374DE290-123F-4565-9164-39C4925E467B}
Clipboard := OutputVar
MsgBox, The path(s) of selected file(s): `n`n%ClipBoard% 
Return

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Virtualbox questions.

Post by mikeyww » 12 Jun 2022, 09:29

You have full permission to give it a go & see what happens! Experimentation is a human quality! :)

LAPIII
Posts: 668
Joined: 01 Aug 2021, 06:01

Re: Virtualbox questions.

Post by LAPIII » 12 Jun 2022, 09:31

Sorry, I meant to ask how do I do this. I use speech recognition software and have a habit of not checking bro.

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Virtualbox questions.

Post by mikeyww » 12 Jun 2022, 09:38

You would insert the lines into your script in the place where you would like them to execute.

LAPIII
Posts: 668
Joined: 01 Aug 2021, 06:01

Re: Virtualbox questions.

Post by LAPIII » 12 Jun 2022, 09:42

I see, I just needed to get rid of a Return.

LAPIII
Posts: 668
Joined: 01 Aug 2021, 06:01

Re: Virtualbox questions.

Post by LAPIII » 13 Jun 2022, 21:23

What I want to do is
  1. Copy to the clipboard input from InputBox, UserInput, Enter Name, Please enter the virtual machine name:, , 300, 150, or a GUI, using ClipbordAll to store it.
  2. *The copy text from this is it is as well:
    FileSelectFile, OutputVar, Options, ::{374DE290-123F-4565-9164-39C4925E467B}
    Clipboard := OutputVar
    MsgBox, The path(s) of selected file(s): `n`n%ClipBoard%
  3. Be able to paste those 2 text items into the text fields in Virtualbox.

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Virtualbox questions.

Post by mikeyww » 14 Jun 2022, 04:54

Code: Select all

InputBox, str, VM, Please enter the virtual machine name.,, 300, 125
If !ErrorLevel {  ; User did not press Cancel or ESC
 Clipboard := "", Clipboard := str
 ClipWait, 0
 If !ErrorLevel { ; Clip succeeded
  Send ^v
  FileSelectFile, str,, % StrReplace(A_AppData, "AppData\Roaming", "Downloads")
  If !ErrorLevel { ; User did not press Cancel or ESC
   Clipboard := "", Clipboard := str
   ClipWait, 0
   If ErrorLevel
    MsgBox, 48, Error, An error occurred while waiting for the clipboard.
   Else Send ^v
  }
 } Else MsgBox, 48, Error, An error occurred while waiting for the clipboard.
}

LAPIII
Posts: 668
Joined: 01 Aug 2021, 06:01

Re: Virtualbox questions.

Post by LAPIII » 14 Jun 2022, 11:08

How can I store the text items as two variables?
Last edited by LAPIII on 14 Jun 2022, 11:21, edited 2 times in total.

User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Virtualbox questions.

Post by mikeyww » 14 Jun 2022, 11:13

Time to learn. The script already shows examples of variable assignments.

LAPIII
Posts: 668
Joined: 01 Aug 2021, 06:01

Re: Virtualbox questions.

Post by LAPIII » 14 Jun 2022, 12:02

Can you help me with missing }:

Code: Select all

InputBox, str1, VM, Please enter the virtual machine name.,, 300, 125
If !ErrorLevel {  ; User did not press Cancel or ESC
Clipboard := "", Clipboard := str1
 
FileSelectFile, str2,, % StrReplace(A_AppData, "AppData\Roaming", "Downloads")
If !ErrorLevel { ; User did not press Cancel or ESC
Clipboard := "", Clipboard := str2

gregster
Posts: 9002
Joined: 30 Sep 2013, 06:48

Re: Virtualbox questions.

Post by gregster » 14 Jun 2022, 12:05

Altogether, the number of open { should match the number of closing }. See blocks.
Current count: 2 open { , 0 closing }

LAPIII
Posts: 668
Joined: 01 Aug 2021, 06:01

Re: Virtualbox questions.

Post by LAPIII » 14 Jun 2022, 12:43

It looks like I need to grab the Settings window in Virtualbox. How can I go about that? The process is the same and the title contains - Settings.

Post Reply

Return to “Ask for Help (v1)”