fix(tui): correct input.ps1 argument parsing
This commit is contained in:
@@ -1,13 +1,9 @@
|
|||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
OpenQode Input Bridge - Basic Computer Use
|
|
||||||
.DESCRIPTION
|
|
||||||
Provides mouse, keyboard, and screen capabilities for the AI Agent.
|
|
||||||
Usage: input.ps1 <command> [args...]
|
|
||||||
#>
|
|
||||||
param(
|
param(
|
||||||
[string]$Action,
|
[Parameter(Position=0, Mandatory=$true)]
|
||||||
[string[]]$Args
|
[string]$Command,
|
||||||
|
|
||||||
|
[Parameter(Position=1, ValueFromRemainingArguments=$true)]
|
||||||
|
[string[]]$Params
|
||||||
)
|
)
|
||||||
|
|
||||||
# Load required assemblies
|
# Load required assemblies
|
||||||
@@ -35,11 +31,11 @@ public class Win32 {
|
|||||||
"@
|
"@
|
||||||
Add-Type -TypeDefinition $code -Language CSharp
|
Add-Type -TypeDefinition $code -Language CSharp
|
||||||
|
|
||||||
switch ($Action.ToLower()) {
|
switch ($Command.ToLower()) {
|
||||||
"mouse" {
|
"mouse" {
|
||||||
if ($Args.Count -lt 2) { Write-Error "Usage: mouse x y"; exit 1 }
|
if ($Params.Count -lt 2) { Write-Error "Usage: mouse x y"; exit 1 }
|
||||||
[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point([int]$Args[0], [int]$Args[1])
|
[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point([int]$Params[0], [int]$Params[1])
|
||||||
Write-Host "Moved mouse to $($Args[0]), $($Args[1])"
|
Write-Host "Moved mouse to $($Params[0]), $($Params[1])"
|
||||||
}
|
}
|
||||||
|
|
||||||
"click" {
|
"click" {
|
||||||
@@ -56,16 +52,16 @@ switch ($Action.ToLower()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
"type" {
|
"type" {
|
||||||
if ($Args.Count -lt 1) { Write-Error "Usage: type 'text'"; exit 1 }
|
if ($Params.Count -lt 1) { Write-Error "Usage: type 'text'"; exit 1 }
|
||||||
$text = $Args -join " "
|
$text = $Params -join " "
|
||||||
[System.Windows.Forms.SendKeys]::SendWait($text)
|
[System.Windows.Forms.SendKeys]::SendWait($text)
|
||||||
Write-Host "Typed: $text"
|
Write-Host "Typed: $text"
|
||||||
}
|
}
|
||||||
|
|
||||||
"key" {
|
"key" {
|
||||||
# Usage: key ENTER, key LWIN, key TAB
|
# Usage: key ENTER, key LWIN, key TAB
|
||||||
if ($Args.Count -lt 1) { Write-Error "Usage: key KEYNAME"; exit 1 }
|
if ($Params.Count -lt 1) { Write-Error "Usage: key KEYNAME"; exit 1 }
|
||||||
$k = $Args[0].ToUpper()
|
$k = $Params[0].ToUpper()
|
||||||
|
|
||||||
# Handle Windows Key specifically (common request)
|
# Handle Windows Key specifically (common request)
|
||||||
if ($k -eq "LWIN" -or $k -eq "WIN") {
|
if ($k -eq "LWIN" -or $k -eq "WIN") {
|
||||||
@@ -89,7 +85,7 @@ switch ($Action.ToLower()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
"screenshot" {
|
"screenshot" {
|
||||||
if ($Args.Count -lt 1) { $file = "screenshot.png" } else { $file = $Args[0] }
|
if ($Params.Count -lt 1) { $file = "screenshot.png" } else { $file = $Params[0] }
|
||||||
$fullPath = [System.IO.Path]::GetFullPath($file)
|
$fullPath = [System.IO.Path]::GetFullPath($file)
|
||||||
|
|
||||||
$bmp = New-Object System.Drawing.Bitmap ([System.Windows.Forms.SystemInformation]::VirtualScreen.Width, [System.Windows.Forms.SystemInformation]::VirtualScreen.Height)
|
$bmp = New-Object System.Drawing.Bitmap ([System.Windows.Forms.SystemInformation]::VirtualScreen.Width, [System.Windows.Forms.SystemInformation]::VirtualScreen.Height)
|
||||||
|
|||||||
Reference in New Issue
Block a user