vamp-mcp 0.2.0 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of vamp-mcp might be problematic. Click here for more details.
- package/LICENSE +21 -21
- package/README.md +144 -107
- package/THIRD_PARTY_NOTICES.md +32 -27
- package/bin/vamp-mcp.mjs +37 -37
- package/notices/mcp-virtualbox-LICENSE +21 -21
- package/notices/mcp-virtualbox-PROVENANCE.json +37 -37
- package/package.json +51 -17
- package/runtime/backends/common/Test-Environment.ps1 +7 -6
- package/runtime/backends/common/guest-install.json +58 -0
- package/runtime/backends/common/guest_install.py +57 -0
- package/runtime/backends/common/host-support.cjs +16 -0
- package/runtime/backends/common/packer.cjs +16 -0
- package/runtime/backends/hyperv/scripts/Manage-Desktop.ps1 +40 -67
- package/runtime/backends/hyperv/scripts/Send-InstallerBoot.ps1 +25 -0
- package/runtime/backends/kvm/debian-preseed.cfg +35 -35
- package/runtime/backends/library/registry.py +77 -77
- package/runtime/backends/library/replay.py +154 -154
- package/runtime/backends/packer/answer_media.py +16 -0
- package/runtime/backends/packer/deploy-hyperv.ps1 +10 -0
- package/runtime/backends/packer/drivers.py +49 -0
- package/runtime/backends/packer/hyperv-network.ps1 +10 -0
- package/runtime/backends/packer/images.py +75 -0
- package/runtime/backends/packer/osinfo.py +113 -0
- package/runtime/backends/packer/policy.json +15 -0
- package/runtime/backends/packer/runner.py +224 -0
- package/runtime/backends/packer/templates.py +118 -0
- package/runtime/backends/packer/toolchain.py +80 -0
- package/runtime/backends/remote_ssh/server.mjs +310 -93
- package/runtime/backends/virtualbox/desktop.cjs +37 -0
- package/runtime/backends/virtualbox/display.py +101 -101
- package/runtime/backends/virtualbox/history.py +139 -139
- package/runtime/backends/virtualbox/mouse_click.py +15 -15
- package/runtime/backends/virtualbox/mouse_move.py +18 -18
- package/runtime/backends/virtualbox/profiles.json +46 -46
- package/runtime/backends/virtualbox/provision.py +238 -197
- package/runtime/backends/virtualbox/recording_listener.py +29 -29
- package/runtime/backends/virtualbox/recordings.py +39 -39
- package/runtime/backends/virtualbox/requirements.txt +7 -7
- package/runtime/backends/virtualbox/rpas/debian_first_boot/manifest.json +1 -1
- package/runtime/backends/virtualbox/rpas/debian_first_boot/run.robot +13 -13
- package/runtime/backends/virtualbox/rpas/debian_first_boot/workflow.py +75 -75
- package/runtime/backends/virtualbox/rpas/observe/manifest.json +7 -7
- package/runtime/backends/virtualbox/rpas/observe/run.robot +13 -13
- package/runtime/backends/virtualbox/rpas/observe/workflow.py +14 -14
- package/runtime/backends/virtualbox/server.mjs +288 -237
- package/runtime/backends/virtualbox/setup_windows_sdk.py +58 -58
- package/runtime/backends/virtualbox/shares.py +68 -68
- package/runtime/backends/virtualbox/snapshots.py +53 -53
- package/runtime/backends/virtualbox/transfers.py +89 -89
- package/runtime/backends/virtualbox/vnc.py +61 -61
- package/runtime/guest_keys.py +13 -13
- package/runtime/guest_setup/http/debian-preseed.cfg +39 -0
- package/runtime/guest_setup/http/postdeb.sh +50 -3
- package/runtime/guest_setup/http/postwin.ps1 +53 -28
- package/runtime/guest_setup/http/setup-all.ps1 +25 -25
- package/runtime/guest_setup/http/setup-win.cmd +7 -7
- package/runtime/guest_setup/http/setup.ps1 +44 -29
- package/runtime/guest_setup/kvm/setup-windows.ps1 +52 -52
- package/runtime/guest_setup/recorder/README.txt +12 -12
- package/runtime/guest_setup/recorder/RECORDER-LICENSE +674 -674
- package/runtime/guest_setup/recorder/RECORDING-GUIDE.txt +31 -31
- package/runtime/guest_setup/recorder/apply-display.py +41 -41
- package/runtime/guest_setup/recorder/configure-debian-mirrors.py +62 -62
- package/runtime/guest_setup/recorder/configure-gdm.py +23 -0
- package/runtime/guest_setup/recorder/configure-session.ps1 +14 -0
- package/runtime/guest_setup/recorder/gnome-display.py +60 -60
- package/runtime/guest_setup/recorder/install-display-startup.py +67 -39
- package/runtime/guest_setup/recorder/install-hypervisor-drivers.ps1 +34 -0
- package/runtime/guest_setup/recorder/install-resolution-shortcut.ps1 +36 -0
- package/runtime/guest_setup/recorder/postwin.cmd +10 -10
- package/runtime/guest_setup/recorder/prepare-recording.py +30 -30
- package/runtime/guest_setup/recorder/requirements-recorder.txt +2 -2
- package/runtime/guest_setup/recorder/session-policy.py +22 -0
- package/runtime/guest_setup/recorder/set-resolution-registry.ps1 +40 -0
- package/runtime/guest_setup/recorder/setup-user.py +53 -53
- package/runtime/guest_setup/recorder/setup-win.cmd +4 -60
- package/runtime/guest_setup/recorder/setup.ps1 +112 -81
- package/runtime/guest_setup/recorder/setup.sh +1 -0
- package/runtime/guest_setup/recorder/vamp-recorder.py +148 -148
- package/runtime/guest_setup/recorder/verify-recorder.py +4 -4
- package/runtime/guest_setup/recorder/windows-display.py +76 -76
- package/runtime/guest_setup/requirements.txt +2 -2
- package/runtime/guest_setup/setup-all.ps1 +35 -35
- package/runtime/guest_setup/vault/Install-VCRuntime.ps1 +26 -26
- package/runtime/guest_setup/vault/setup-guest-vault.ps1 +148 -148
- package/runtime/recording_converter.py +230 -230
- package/runtime/requirements-mcp.txt +11 -11
- package/runtime/rpas/README.md +161 -161
- package/runtime/rpas/captcha_handoff/manifest.json +27 -27
- package/runtime/rpas/captcha_handoff/run.robot +16 -16
- package/runtime/rpas/captcha_handoff/workflow.py +11 -11
- package/runtime/rpas/common.resource +26 -26
- package/runtime/rpas/debian_update/manifest.json +27 -27
- package/runtime/rpas/debian_update/run.robot +17 -17
- package/runtime/rpas/debian_update/workflow.py +13 -13
- package/runtime/rpas/desktop_control/manifest.json +26 -26
- package/runtime/rpas/desktop_control/run.robot +27 -27
- package/runtime/rpas/desktop_control/workflow.py +51 -51
- package/runtime/rpas/firefox_launch/manifest.json +27 -27
- package/runtime/rpas/firefox_launch/run.robot +15 -15
- package/runtime/rpas/firefox_launch/workflow.py +25 -25
- package/runtime/rpas/firefox_naver/manifest.json +27 -27
- package/runtime/rpas/firefox_naver/run.robot +21 -21
- package/runtime/rpas/firefox_naver/workflow.py +28 -28
- package/runtime/rpas/kvm_validation/README.md +11 -11
- package/runtime/rpas/kvm_validation/manifest.json +28 -28
- package/runtime/rpas/kvm_validation/run.robot +30 -30
- package/runtime/rpas/kvm_validation/workflow.py +91 -91
- package/runtime/rpas/manifest.schema.json +105 -105
- package/runtime/rpas/naver_login/login.robot +25 -25
- package/runtime/rpas/naver_login/manifest.json +33 -33
- package/runtime/rpas/naver_login/run.robot +20 -20
- package/runtime/rpas/naver_login/workflow.py +32 -32
- package/runtime/rpas/windows_naver_recorded/README.md +24 -24
- package/runtime/rpas/windows_naver_recorded/conversion.json +25 -25
- package/runtime/rpas/windows_naver_recorded/manifest.json +28 -28
- package/runtime/rpas/windows_naver_recorded/run.robot +37 -37
- package/runtime/rpas/windows_naver_recorded/workflow.py +32 -32
- package/runtime/scripts/build_recorder_media.py +39 -39
- package/runtime/scripts/macos/setup-host.sh +0 -0
- package/runtime/scripts/script_server.py +571 -517
- package/runtime/skills/vamp-rpa-ui-checks/SKILL.md +26 -0
- package/runtime/skills/vamp-rpa-ui-checks/agents/openai.yaml +4 -0
- package/runtime/skills/vamp-rpa-ui-checks/references/display.md +12 -0
- package/runtime/skills/vamp-rpa-ui-checks/references/user-guide.md +51 -0
- package/runtime/skills/vamp-ui-cleanup/SKILL.md +15 -0
- package/runtime/skills/vamp-ui-cleanup/agents/openai.yaml +4 -0
- package/runtime/skills/vamp-ui-validation/SKILL.md +27 -0
- package/runtime/skills/vamp-ui-validation/agents/openai.yaml +4 -0
- package/runtime/third_party/mcp-virtualbox/scripts/mouse_click.py +65 -65
- package/runtime/third_party/pyautogui-recorder/LICENSE +674 -674
- package/runtime/third_party/pyautogui-recorder/PROVENANCE.json +16 -16
- package/runtime/third_party/pyautogui-recorder/PyAutoGuiRecorder.py +169 -169
- package/runtime/third_party/pyautogui-recorder/README.md +53 -53
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: vamp-rpa-ui-checks
|
|
3
|
+
description: Define reusable UI locators and outcome checks for VAMP Robot/Python RPAs. Use for screen automation reliability, host versus guest coordinates and compact validation evidence.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# VAMP RPA UI checks
|
|
7
|
+
|
|
8
|
+
Read rpa-reuse and the relevant virtualbox-rpa, hyperv-rpa or spice-vm-rpa skill before driving a guest. Reuse a reviewed package that matches the VM, input contract and expected application state.
|
|
9
|
+
|
|
10
|
+
## Define the contract
|
|
11
|
+
|
|
12
|
+
Read [display preflight](references/display.md). Verify 1920×1080 and 100% guest scaling before coordinate-based work; if different, adjust the guest and verify fresh evidence before continuing, subject to the user's current authorization and pause state.
|
|
13
|
+
|
|
14
|
+
Record the VM UUID, host platform, hypervisor, application, expected starting state, guest resolution and display scaling. State whether coordinates belong to the host window, viewport or guest framebuffer. Recalibrate when resolution, scaling, crop or window placement changes; never silently mix coordinate spaces.
|
|
15
|
+
|
|
16
|
+
Prefer semantic locators for host webviews and native accessibility controls. For guest screenshots, use the existing backend's OCR/YOLO pipeline and localized anchors. Limit searches to the relevant region and require an unambiguous match before clicking. Keep language recognition multilingual even when product explanations are English.
|
|
17
|
+
|
|
18
|
+
## Execute and verify
|
|
19
|
+
|
|
20
|
+
Use bounded waits for observable state changes. After each consequential action, check an independent outcome such as a dialog closing, expected page appearing, file existing or completion marker being written. A click, typed command or successful tool return proves delivery only.
|
|
21
|
+
|
|
22
|
+
When installation must run automatically, observe its result without manually starting the installer. Separate diagnostics from setup. On ambiguous state, capture targeted evidence and stop dependent input; use the repair skill for a failed saved RPA. Respect user pauses immediately and do not create snapshots unless requested.
|
|
23
|
+
|
|
24
|
+
## Save reusable evidence
|
|
25
|
+
|
|
26
|
+
Store locator intent, timing bounds, coordinate mapping, expected outcome and failure condition with the RPA. Return compact status and artifact paths. Export only targeted failure crops or OCR excerpts when needed. Exclude passwords, tokens and private session data from recordings and shared skills. Report completed_unverified distinctly from verified success.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# AI display preflight
|
|
2
|
+
|
|
3
|
+
Before recording, replaying or calculating guest coordinates, inspect the target VM's actual framebuffer. Require **1920×1080** with guest scaling **100%** for VAMP's standard recordings. A scaled screenshot or resized viewer does not verify the framebuffer.
|
|
4
|
+
|
|
5
|
+
If the resolution differs, adjust the guest to 1920×1080 using the authorized backend and guest display settings, then capture fresh evidence and verify the result before continuing. This requirement does not override a user's pause or authorize unrelated VM changes. If a driver installation, UAC approval or restart is required, identify the blocker and use the existing authorization rules.
|
|
6
|
+
|
|
7
|
+
- Linux GNOME: Settings → Displays → 1920×1080, Scale 100%, Apply. For Xorg only, inspect `xrandr --query` and select an available 1920x1080 mode. Use GNOME Settings on Wayland. Do not blindly force a missing mode.
|
|
8
|
+
- Windows: Settings → System → Display → Display resolution 1920×1080, Scale 100%. If unavailable, finish guest display driver/VirtualBox Guest Additions setup; verify again after any required reboot.
|
|
9
|
+
- VirtualBox: `vm_configure_display` can request the mode; require `observed_resolution: [1920,1080]` and `resolution_verified: true`. Independently verify guest scaling. Turn off guest auto-resize; scaled viewing does not change the target pixels.
|
|
10
|
+
- Other backends: inspect the native guest screenshot and session display configuration. Do not assume a VirtualBox tool works on Hyper-V or KVM.
|
|
11
|
+
|
|
12
|
+
Never reuse stale coordinates after a display change. If the target cannot be met, report the actual dimensions and block dependent coordinate replay rather than claiming success. Use the VSIX's **1920×1080 guide** for user-facing Linux and Windows instructions.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Guest display: 1920×1080
|
|
2
|
+
|
|
3
|
+
**Before recording or replaying an RPA, set the VM's display to 1920×1080 at 100% scaling.** Change the guest display, not your host monitor. Resizing or zooming the viewer does not establish the guest resolution. Finish guest setup first and keep the VM awake and unlocked during setup and automation.
|
|
4
|
+
|
|
5
|
+
## Reset shortcuts installed by guest setup
|
|
6
|
+
|
|
7
|
+
- **Windows Desktop:** double-click `Set-Resolution-1920x1080.cmd`. It opens the companion PowerShell script and applies Full HD. Press any key to close its result window.
|
|
8
|
+
- **Debian home folder:** open a terminal in the logged-in guest and run `~/set-resolution-1920x1080.sh`.
|
|
9
|
+
|
|
10
|
+
Run these inside the VM when the display drifts. They reuse the same display helper as the per-login hook, apply 1920x1080 and report the observed result. They do not resize the host screen. If the guest driver rejects Full HD, the script reports that failure; finish the guest display driver setup first. All shortcut instructions and messages are in English.
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## Linux VM — Debian / Ubuntu GNOME
|
|
14
|
+
|
|
15
|
+
1. Inside the guest, open **Settings → Displays**.
|
|
16
|
+
2. Select the guest display, choose **1920 × 1080**, and set **Scale** to **100%**.
|
|
17
|
+
3. Apply the settings and keep the changes. Recheck after login or reconnecting the viewer.
|
|
18
|
+
|
|
19
|
+
If you use **GNOME on Xorg**, you can list available modes and select an existing Full HD mode in the guest terminal:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
xrandr --query
|
|
23
|
+
display=$(xrandr --query | awk '/ connected/{print $1; exit}')
|
|
24
|
+
xrandr --output "$display" --mode 1920x1080
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Run this as the logged-in desktop user, not on the host. `xrandr` is an Xorg tool; in a Wayland session use Settings → Displays. If 1920×1080 is missing, finish the display driver/Guest Additions setup and reboot when installation is complete. Do not force an unavailable mode. In GNOME, the login screen's session menu may offer **GNOME on Xorg** if installed.
|
|
28
|
+
|
|
29
|
+
For VirtualBox, keep **Auto-resize Guest Display** off after setting the target resolution. Use **View → Scaled Mode** to fit the viewer without changing guest pixels. On KVM, check the guest display driver and configured virtual video device if the mode is unavailable.
|
|
30
|
+
|
|
31
|
+
## Windows VM — Windows 11
|
|
32
|
+
|
|
33
|
+
1. Inside the guest, open **Start → Settings → System → Display**.
|
|
34
|
+
2. Under **Scale & layout**, choose **Display resolution: 1920 × 1080** and **Scale: 100%**.
|
|
35
|
+
3. Keep the changes. If Windows requests a sign-out, finish setup before signing out, then verify the settings again.
|
|
36
|
+
|
|
37
|
+
If the resolution is missing or disabled in VirtualBox, finish guest setup, choose **Devices → Insert Guest Additions CD image**, open the CD inside Windows and run **VBoxWindowsAdditions.exe**. Approve the guest UAC prompt and reboot after installation. Then select 1920×1080 and 100% again. Leave **Auto-resize Guest Display** off; **Scaled Mode** changes only the viewer presentation.
|
|
38
|
+
|
|
39
|
+
Hyper-V basic sessions can expose fewer display modes. Use supported guest display drivers or an Enhanced Session when available, set the session display to 1920×1080, and recheck the effective guest resolution after reconnecting. The VAMP Hyper-V embedded viewer is not implemented.
|
|
40
|
+
|
|
41
|
+
## Verify before automation
|
|
42
|
+
|
|
43
|
+
Check the actual guest screen dimensions, not a resized preview. For VirtualBox, `vm_screen_info` / a native screenshot can report the framebuffer size. `vm_configure_display` requests Full HD and returns `observed_resolution` and `resolution_verified`; a sent hint is not proof of a changed resolution. Verify 100% scaling separately inside the guest.
|
|
44
|
+
|
|
45
|
+
An RPA recorded at another resolution needs recalibration or a matching recording. If the guest cannot reach 1920×1080, report the observed resolution and resolve the display driver/session issue before coordinate-based replay.
|
|
46
|
+
|
|
47
|
+
References: [GNOME display settings](https://teams.pages.gitlab.gnome.org/websites/help.gnome.org/gnome-help/look-resolution.html), [Microsoft display resolution and layout](https://support.microsoft.com/en-us/windows/hardware/display-graphics/change-your-screen-resolution-and-layout-in-windows).
|
|
48
|
+
|
|
49
|
+
Windows guest setup and display-reset scripts request administrator PowerShell when needed. Approve the UAC prompt. The elevated process runs `Set-ExecutionPolicy -Scope Process -ExecutionPolicy Unrestricted -Force` before the script. MCP and VSIX share the same Ctrl+Shift+Enter / UAC Left+Enter bootstrap. Script execution policy changes apply to that process.
|
|
50
|
+
|
|
51
|
+
Windows setup finishes with an elevated direct registry update to 1920x1080 (`PrimSurfSize.cx/cy` and `ActiveSize.cx/cy`) for the guest display configurations, on VirtualBox, KVM and Hyper-V. The Desktop reset script performs the same update before applying the display mode. Previous registry values are backed up under `%ProgramData%\VAMP\display-registry\backups`. A compatible guest display driver is still required.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: vamp-ui-cleanup
|
|
3
|
+
description: Simplify VAMP VS Code webviews and user-facing MCP copy while preserving automation controls, accessibility and installation warnings. Use for UI text translation, redundant controls and layout cleanup.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# VAMP UI cleanup
|
|
7
|
+
|
|
8
|
+
1. Locate the webview generator, message handlers and existing UI tests. List the element IDs consumed by scripts before removing markup.
|
|
9
|
+
2. Use concise English product text. Keep status, errors, permission requirements and recovery actions visible. Preserve language-recognition patterns; they are not product copy.
|
|
10
|
+
3. Keep one primary action for each task. Move manual recovery, environment reset and diagnostics into a labeled disclosure. Remove duplicate guide links and implementation prose from the main flow.
|
|
11
|
+
4. Preserve VS Code theme variables, keyboard focus, accessible labels, narrow layouts and live status announcements. Hide unsupported host/backend options; do not advertise unimplemented features.
|
|
12
|
+
5. Preserve the guest setup warning: wait for setup completion before locking or suspending the guest. Describe display settings as best effort unless verified. Do not present input delivery as successful installation.
|
|
13
|
+
6. Test the generated HTML with mocked webview messages. Cover loading, ready, busy, missing dependency and failure states. Verify stable IDs, event wiring and disabled controls, especially shared HTTP server Start/Stop.
|
|
14
|
+
|
|
15
|
+
Use static fixtures for layout checks. UI editing does not authorize creating or controlling a VM. Honor an existing automation pause. Report changed controls and actual validation separately from untested guest behavior.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: vamp-ui-validation
|
|
3
|
+
description: Validate VAMP VS Code webviews and packaged VSIX installations with isolated profiles and deterministic UI evidence. Use for release UI checks, native file pickers and installed-extension regressions.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# VAMP UI validation
|
|
7
|
+
|
|
8
|
+
## Choose the test boundary
|
|
9
|
+
|
|
10
|
+
For copy, layout and message handling, render generated HTML with a mocked acquireVsCodeApi. Record outgoing messages without dispatching them to a real extension. Exercise loading, ready, busy, error and unsupported backend states at wide and narrow sizes.
|
|
11
|
+
|
|
12
|
+
For installed-extension bugs, build the VSIX and install it into an isolated user-data directory and extensions directory. Record extension ID, version and resolved installation path. A development host or source override is not evidence that the packaged extension works. Updating an isolated profile does not update the user's normal profile.
|
|
13
|
+
|
|
14
|
+
## Target the correct window
|
|
15
|
+
|
|
16
|
+
- Identify the isolated VS Code process and its exact webview frame before using locators. Prefer IDs, roles and labels over coordinates.
|
|
17
|
+
- Native file pickers are outside the webview. On Windows, locate the dialog by process and window handle, then locate its filename Edit and Open button through UI Automation. Validate the owning process before targeted window messages. Control IDs vary across dialogs; inspect them instead of assuming them.
|
|
18
|
+
- Bringing a browser page forward does not prove native focus. Avoid global SendKeys. Never type into an unverified foreground window.
|
|
19
|
+
- Use the matching backend skill for authorized guest input. Do not resume paused VM automation merely to validate UI changes.
|
|
20
|
+
|
|
21
|
+
## Check outcomes
|
|
22
|
+
|
|
23
|
+
Wait for settled UI state rather than fixed delays. For server buttons, check busy/disabled states and final Running/Stopped status; check HTTP health only when server lifecycle changes are authorized. Use an isolated fixture otherwise.
|
|
24
|
+
|
|
25
|
+
For creation flows, distinguish accepted request, VM creation, OS installation and completed guest setup. Verify recorder installation and session policy inside the guest only when that test is authorized. A manually invoked installer cannot prove automatic setup.
|
|
26
|
+
|
|
27
|
+
Return a compact record: artifact version/path, host/backend, action, expected state, observed state and evidence path. Mark unrun or incomplete stages explicitly. Keep credentials and development VM names out of release artifacts.
|
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
Absolute mouse click helper for VirtualBox VMs.
|
|
4
|
-
Uses the VirtualBox Python API (vboxapi) for absolute mouse positioning,
|
|
5
|
-
which requires USB tablet mouse mode on the VM.
|
|
6
|
-
|
|
7
|
-
Usage: python mouse_click.py <vm_name> <x> <y> [left|right|middle] [--double]
|
|
8
|
-
"""
|
|
9
|
-
|
|
10
|
-
import sys
|
|
11
|
-
import time
|
|
12
|
-
|
|
13
|
-
def main():
|
|
14
|
-
if len(sys.argv) < 4:
|
|
15
|
-
print("Usage: mouse_click.py <vm_name> <x> <y> [left|right|middle] [--double]", file=sys.stderr)
|
|
16
|
-
sys.exit(1)
|
|
17
|
-
|
|
18
|
-
vm_name = sys.argv[1]
|
|
19
|
-
x = int(sys.argv[2])
|
|
20
|
-
y = int(sys.argv[3])
|
|
21
|
-
button = sys.argv[4] if len(sys.argv) > 4 and sys.argv[4] != "--double" else "left"
|
|
22
|
-
double = "--double" in sys.argv
|
|
23
|
-
|
|
24
|
-
button_map = {"left": 0x01, "right": 0x02, "middle": 0x04}
|
|
25
|
-
button_flag = button_map.get(button, 0x01)
|
|
26
|
-
|
|
27
|
-
try:
|
|
28
|
-
import vboxapi
|
|
29
|
-
except ImportError:
|
|
30
|
-
# Fallback: try importing from VirtualBox SDK location
|
|
31
|
-
import os
|
|
32
|
-
vbox_path = os.environ.get("VBOX_SDK_PATH", r"C:\Program Files\Oracle\VirtualBox\sdk\install")
|
|
33
|
-
sys.path.insert(0, vbox_path)
|
|
34
|
-
import vboxapi
|
|
35
|
-
|
|
36
|
-
mgr = vboxapi.VirtualBoxManager(None, None)
|
|
37
|
-
vbox = mgr.getVirtualBox()
|
|
38
|
-
machine = vbox.findMachine(vm_name)
|
|
39
|
-
session = mgr.getSessionObject()
|
|
40
|
-
|
|
41
|
-
machine.lockMachine(session, 1) # LockType_Shared = 1
|
|
42
|
-
try:
|
|
43
|
-
console = session.console
|
|
44
|
-
mouse = console.mouse
|
|
45
|
-
|
|
46
|
-
if not mouse.absoluteSupported:
|
|
47
|
-
print("Warning: Absolute mouse not supported. Enable USB tablet mode.", file=sys.stderr)
|
|
48
|
-
|
|
49
|
-
# Move to position and click
|
|
50
|
-
mouse.putMouseEventAbsolute(x, y, 0, 0, button_flag)
|
|
51
|
-
time.sleep(0.05)
|
|
52
|
-
mouse.putMouseEventAbsolute(x, y, 0, 0, 0) # Release
|
|
53
|
-
|
|
54
|
-
if double:
|
|
55
|
-
time.sleep(0.1)
|
|
56
|
-
mouse.putMouseEventAbsolute(x, y, 0, 0, button_flag)
|
|
57
|
-
time.sleep(0.05)
|
|
58
|
-
mouse.putMouseEventAbsolute(x, y, 0, 0, 0)
|
|
59
|
-
|
|
60
|
-
print(f"Clicked {button} at ({x}, {y})" + (" (double)" if double else ""))
|
|
61
|
-
finally:
|
|
62
|
-
session.unlockMachine()
|
|
63
|
-
|
|
64
|
-
if __name__ == "__main__":
|
|
65
|
-
main()
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Absolute mouse click helper for VirtualBox VMs.
|
|
4
|
+
Uses the VirtualBox Python API (vboxapi) for absolute mouse positioning,
|
|
5
|
+
which requires USB tablet mouse mode on the VM.
|
|
6
|
+
|
|
7
|
+
Usage: python mouse_click.py <vm_name> <x> <y> [left|right|middle] [--double]
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import sys
|
|
11
|
+
import time
|
|
12
|
+
|
|
13
|
+
def main():
|
|
14
|
+
if len(sys.argv) < 4:
|
|
15
|
+
print("Usage: mouse_click.py <vm_name> <x> <y> [left|right|middle] [--double]", file=sys.stderr)
|
|
16
|
+
sys.exit(1)
|
|
17
|
+
|
|
18
|
+
vm_name = sys.argv[1]
|
|
19
|
+
x = int(sys.argv[2])
|
|
20
|
+
y = int(sys.argv[3])
|
|
21
|
+
button = sys.argv[4] if len(sys.argv) > 4 and sys.argv[4] != "--double" else "left"
|
|
22
|
+
double = "--double" in sys.argv
|
|
23
|
+
|
|
24
|
+
button_map = {"left": 0x01, "right": 0x02, "middle": 0x04}
|
|
25
|
+
button_flag = button_map.get(button, 0x01)
|
|
26
|
+
|
|
27
|
+
try:
|
|
28
|
+
import vboxapi
|
|
29
|
+
except ImportError:
|
|
30
|
+
# Fallback: try importing from VirtualBox SDK location
|
|
31
|
+
import os
|
|
32
|
+
vbox_path = os.environ.get("VBOX_SDK_PATH", r"C:\Program Files\Oracle\VirtualBox\sdk\install")
|
|
33
|
+
sys.path.insert(0, vbox_path)
|
|
34
|
+
import vboxapi
|
|
35
|
+
|
|
36
|
+
mgr = vboxapi.VirtualBoxManager(None, None)
|
|
37
|
+
vbox = mgr.getVirtualBox()
|
|
38
|
+
machine = vbox.findMachine(vm_name)
|
|
39
|
+
session = mgr.getSessionObject()
|
|
40
|
+
|
|
41
|
+
machine.lockMachine(session, 1) # LockType_Shared = 1
|
|
42
|
+
try:
|
|
43
|
+
console = session.console
|
|
44
|
+
mouse = console.mouse
|
|
45
|
+
|
|
46
|
+
if not mouse.absoluteSupported:
|
|
47
|
+
print("Warning: Absolute mouse not supported. Enable USB tablet mode.", file=sys.stderr)
|
|
48
|
+
|
|
49
|
+
# Move to position and click
|
|
50
|
+
mouse.putMouseEventAbsolute(x, y, 0, 0, button_flag)
|
|
51
|
+
time.sleep(0.05)
|
|
52
|
+
mouse.putMouseEventAbsolute(x, y, 0, 0, 0) # Release
|
|
53
|
+
|
|
54
|
+
if double:
|
|
55
|
+
time.sleep(0.1)
|
|
56
|
+
mouse.putMouseEventAbsolute(x, y, 0, 0, button_flag)
|
|
57
|
+
time.sleep(0.05)
|
|
58
|
+
mouse.putMouseEventAbsolute(x, y, 0, 0, 0)
|
|
59
|
+
|
|
60
|
+
print(f"Clicked {button} at ({x}, {y})" + (" (double)" if double else ""))
|
|
61
|
+
finally:
|
|
62
|
+
session.unlockMachine()
|
|
63
|
+
|
|
64
|
+
if __name__ == "__main__":
|
|
65
|
+
main()
|