Hey!
Is it possible to control the VM intern? Like to move the mouse to a certain point?
Thx!
Control the VM intern?
-
- Site Moderator
- Posts: 5229
- Joined: 13. Jan 2012, 11:14
- Primary OS: Debian other
- VBox Version: OSE Debian
- Guest OSses: Debian, Win 2k8, Win 7
- Contact:
Re: Control the VM intern?
Yes!
After locking an IMachine with a Shared lock, you will find that the IConsole object is available from the ISession object used for the lock.
on IConsole, you will find IConsole::mouse[1] which returns an IMouse object on which you can send mouse events to effetivly move the mouse or perform clicks.
[1] You will also find other devices like keyboard, display, etc.
After locking an IMachine with a Shared lock, you will find that the IConsole object is available from the ISession object used for the lock.
on IConsole, you will find IConsole::mouse[1] which returns an IMouse object on which you can send mouse events to effetivly move the mouse or perform clicks.
[1] You will also find other devices like keyboard, display, etc.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Manage your VirtualBox infrastructure the free way!
Re: Control the VM intern?
Ok, do you have an example how to implement it using WebService?
Cause i have the Problem, that i don't really know how to get this ISession object of the VM I'm running this code at.
Have to say, that i have multiple VM's running at the same time this code, so it is not possible to implement just a constant with the name of the VM.
Btw. Thank you for your fast answer, really appreciate it!
Cause i have the Problem, that i don't really know how to get this ISession object of the VM I'm running this code at.
Have to say, that i have multiple VM's running at the same time this code, so it is not possible to implement just a constant with the name of the VM.
Btw. Thank you for your fast answer, really appreciate it!
Re: Control the VM intern?
Hey, posting here because i i thought i was not worth it to create a post just for that.
When using releaseKeys() i feel like it doesn't release the keys.
Here is the code:
Is it a bug or am i doing something wrong ?
When using releaseKeys() i feel like it doesn't release the keys.
Here is the code:
Code: Select all
def hotkey(key1, key2, key3 = None):
if key3 is not None:
codeStored = keyboard.putScanCodes([key1, key2, key3])
keyboard.releaseKeys()
else:
codeStored = keyboard.putScanCodes([key1, key2])
keyboard.releaseKeys()
# Action
hotkey(29, 33) # Ctrl-F
# Both are still getting pressed
# With a single key
pressKey(33) # Enter
keyboard.releaseKeys()
# it keeps getting pressed
-
- Site Moderator
- Posts: 5229
- Joined: 13. Jan 2012, 11:14
- Primary OS: Debian other
- VBox Version: OSE Debian
- Guest OSses: Debian, Win 2k8, Win 7
- Contact:
Re: Control the VM intern?
most likely you need to put some waiting time between the two events. Normal humans don't press and release keys under a millisecond
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Manage your VirtualBox infrastructure the free way!
Re: Control the VM intern?
What if i do ? Just kidding.
I've tried it but keys are still pressed
I've tried it but keys are still pressed
Code: Select all
keyboard.putScanCode(29)
time.sleep(0.5)
keyboard.putScanCode(33)
time.sleep(0.5)
keyboard.releaseKeys()
## OR
keyboard.putScanCodes([29, 33])
time.sleep(0.5)
keyboard.releaseKeys()
-
- Site Moderator
- Posts: 5229
- Joined: 13. Jan 2012, 11:14
- Primary OS: Debian other
- VBox Version: OSE Debian
- Guest OSses: Debian, Win 2k8, Win 7
- Contact:
Re: Control the VM intern?
I think this area of the API is very rarely used by 3rd parties, so I don't know further I'm afraid. I don't even have experience with it.
The best approach in this situation is to go check how vboxmanage does it
The best approach in this situation is to go check how vboxmanage does it
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Manage your VirtualBox infrastructure the free way!