'Using xdotool to ctrl-click-drag in scrcpy window

This is for Debian 11:

I am trying to script a ctrl+click+drag motion within a scrcpy window. This is what I have so far:

#!/bin/bash

xdotool search --desktop 0 --class "scrcpy" windowactivate

unset x y w h
  eval $(xwininfo -id $(xdotool getactivewindow) |
    sed -n -e "s/^ \+Absolute upper-left X: \+\([0-9]\+\).*/x=\1/p" \
           -e "s/^ \+Absolute upper-left Y: \+\([0-9]\+\).*/y=\1/p" \
           -e "s/^ \+Width: \+\([0-9]\+\).*/w=\1/p" \
           -e "s/^ \+Height: \+\([0-9]\+\).*/h=\1/p" )

let "zosx = ( x + ( w / 4 ))"
let "zosy = ( y + ( h / 4 * 3 ))"
let "zoex = ( x + ( w / 2 ))"
let "zoey = ( y + ( h / 2 ))"

xdotool mousemove --sync $zosx $zosy
xdotool keydown Control_L
xdotool mousedown 1
xdotool mousemove --sync $zoex $zoey
xdotool mouseup 1
xdotool keyup Control_L

Alas, it does not work. The mouse should start 75% from top and 25% from left in the window, then hold down ctrl, hold down the mouse 1 button, drag to 50% / 50% of window and release both the mouse button and the control key.

As you may guess, this is to achieve a "zoom out" type of function inside of the scrcpy window.

The coordinate DO calculate correctly, so it seems to be an issue with the keydown / mousedown / mousemove

Advice?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source