support for mouse up and down functions

This commit is contained in:
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;
}
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
*

View file

@ -194,6 +194,18 @@ class Control
{
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
*
@ -217,6 +229,17 @@ class Control
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
*