From 4ea99cd4f8e043677673e681496ffbda3397c97f Mon Sep 17 00:00:00 2001 From: Sascha Nitsch Date: Wed, 4 Sep 2024 18:58:35 +0200 Subject: [PATCH] fixed mouse movent, now takes scroll position into account --- scriptedbrowser/commands/base.php | 3 +++ scriptedbrowser/control.php | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/scriptedbrowser/commands/base.php b/scriptedbrowser/commands/base.php index f6a7295..c19a1e7 100644 --- a/scriptedbrowser/commands/base.php +++ b/scriptedbrowser/commands/base.php @@ -57,6 +57,9 @@ function mousemove($main, $control, $options) : bool $targetPos = $control->getElementRect($element); $targetX = $targetPos['x'] + $targetPos['width'] / 2; $targetY = $targetPos['y'] + $targetPos['height'] / 2; + $scroll = $control->getScrollPosition(); + $targetX -= $scroll[0]; + $targetY -= $scroll[1]; // echo "move $element - $tokens[1] $targetX $targetY\n"; $mouseX = $main->getMouseX(); $mouseY = $main->getMouseY(); diff --git a/scriptedbrowser/control.php b/scriptedbrowser/control.php index 295064d..1a6a43e 100644 --- a/scriptedbrowser/control.php +++ b/scriptedbrowser/control.php @@ -174,6 +174,16 @@ class Control return (!is_array($url)) ? $url : ''; } + /** + * get scroll position + * + * @return [int,int] current scroll position + */ + public function getScrollPosition() + { + return $this->executeScript('return [window.pageXOffset, window.pageYOffset];'); + } + /** * move mouse to absolute position *