function to move mouse to defined coordinates
parent
184b3e8848
commit
c47142ea5c
|
@ -76,7 +76,6 @@ function leftrelease($main, $control, $options) : bool
|
||||||
function mousemove($main, $control, $options) : bool
|
function mousemove($main, $control, $options) : bool
|
||||||
{
|
{
|
||||||
$element = $control->selectCSS($main->vars($options['parameter']));
|
$element = $control->selectCSS($main->vars($options['parameter']));
|
||||||
$mouseOffset = $main->getMouseOffset();
|
|
||||||
if ($element === [] || array_key_exists('error', $element)) {
|
if ($element === [] || array_key_exists('error', $element)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -88,6 +87,39 @@ function mousemove($main, $control, $options) : bool
|
||||||
$targetX -= $scroll[0];
|
$targetX -= $scroll[0];
|
||||||
$targetY -= $scroll[1];
|
$targetY -= $scroll[1];
|
||||||
// echo "move $element - $tokens[1] $targetX $targetY\n";
|
// echo "move $element - $tokens[1] $targetX $targetY\n";
|
||||||
|
_mousemoveaction($main, $control, $options, $targetX, $targetY);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* move mouse to given target position from variables
|
||||||
|
*
|
||||||
|
* @param \ScriptedBrowser\Main $main main instance
|
||||||
|
* @param \ScriptedBrowser\Control $control control interface
|
||||||
|
* @param array<string,mixed> $options options
|
||||||
|
* @return bool true if mouse move, false on error
|
||||||
|
*/
|
||||||
|
function mousemovetarget($main, $control, $options) : bool
|
||||||
|
{
|
||||||
|
$targetX = $main->vars($options['x']);
|
||||||
|
$targetY = $main->vars($options['y']);
|
||||||
|
$scroll = $control->getScrollPosition();
|
||||||
|
$targetX -= $scroll[0];
|
||||||
|
$targetY -= $scroll[1];
|
||||||
|
_mousemoveaction($main, $control, $options, $targetX, $targetY);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* move mouse to given target position
|
||||||
|
*
|
||||||
|
* @param \ScriptedBrowser\Main $main main instance
|
||||||
|
* @param \ScriptedBrowser\Control $control control interface
|
||||||
|
* @param array<string,mixed> $options options
|
||||||
|
*/
|
||||||
|
function _mousemoveaction($main, $control, $options, $targetX, $targetY)
|
||||||
|
{
|
||||||
|
$mouseOffset = $main->getMouseOffset();
|
||||||
$mouseX = $main->getMouseX();
|
$mouseX = $main->getMouseX();
|
||||||
$mouseY = $main->getMouseY();
|
$mouseY = $main->getMouseY();
|
||||||
$delta = [$targetX - $mouseX, $targetY - $mouseY];
|
$delta = [$targetX - $mouseX, $targetY - $mouseY];
|
||||||
|
@ -109,7 +141,6 @@ function mousemove($main, $control, $options) : bool
|
||||||
$main->setMouseX($targetX);
|
$main->setMouseX($targetX);
|
||||||
$main->setMouseY($targetY);
|
$main->setMouseY($targetY);
|
||||||
$control->mousemove($targetX + $mouseOffset[0], $targetY + $mouseOffset[1]);
|
$control->mousemove($targetX + $mouseOffset[0], $targetY + $mouseOffset[1]);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue