support for mouse up and down functions

develop
Sascha Nitsch 2024-09-09 17:17:06 +02:00
parent d8b2f05767
commit 7ac8a2f7c2
2 changed files with 35 additions and 0 deletions

View File

@ -53,6 +53,18 @@ function leftclick($main, $control, $options) : bool
return true; return true;
} }
function leftpress($main, $control, $options) : bool
{
$control->mouseDown(\ScriptedBrowser\MouseButton::Left);
return true;
}
function leftrelease($main, $control, $options) : bool
{
$control->mouseUp(\ScriptedBrowser\MouseButton::Left);
return true;
}
/** /**
* move mouse to given element * move mouse to given element
* *

View File

@ -194,6 +194,18 @@ class Control
{ {
fwrite($this->xdotool, "key $key\n"); fwrite($this->xdotool, "key $key\n");
} }
/**
* press mouse button
*
* @param MouseButton $button button to press
* @return void
*/
public function mouseDown($button)
{
fwrite($this->xdotool, 'mousedown ' . $button->value . "\n");
}
/** /**
* move mouse to absolute position * move mouse to absolute position
* *
@ -217,6 +229,17 @@ class Control
fwrite($this->xdotool, "mousemove_relative $x $y\n"); fwrite($this->xdotool, "mousemove_relative $x $y\n");
} }
/**
* release mouse button
*
* @param MouseButton $button button to press
* @return void
*/
public function mouseUp($button)
{
fwrite($this->xdotool, 'mouseup ' . $button->value . "\n");
}
/** /**
* open geckodriver if not already running * open geckodriver if not already running
* *