rsps-scripts

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

empty-first-14.sh (1287B)


      1 #!/usr/bin/env bash
      2 
      3 # include functions
      4 source "$(dirname "${BASH_SOURCE[0]}")/functions.sh"
      5 
      6 
      7 function move_mouse_steps() {
      8 	# Usage: move_mouse_steps target_x target_y [steps] [delay_ms]
      9 	# Walks the cursor from its current position to the target in many
     10 	# small increments instead of one instant warp, so apps/games that
     11 	# only refresh hover/hit-test state on continuous motion actually
     12 	# see the cursor "pass over" everything in between.
     13 	if [[ $# -lt 2 ]]; then
     14 		echo "Usage: move_mouse_steps target_x target_y [steps] [delay_ms]" >&2
     15 		return 1
     16 	fi
     17 
     18 	local target_x="$1"
     19 	local target_y="$2"
     20 	local steps="${3:-20}"
     21 	local delay_ms="${4:-4}"
     22 
     23 	local cur cur_x cur_y
     24 	cur="$(current_mouse | tr -d ' ')"
     25 	cur_x="${cur%%,*}"
     26 	cur_y="${cur##*,}"
     27 
     28 	local i step_x step_y
     29 	for ((i = 1; i <= steps; i++)); do
     30 		step_x=$(( cur_x + (target_x - cur_x) * i / steps ))
     31 		step_y=$(( cur_y + (target_y - cur_y) * i / steps ))
     32 		hctl dispatch "hl.dsp.cursor.move({ x = $step_x, y = $step_y })"
     33 		msleep "$delay_ms"
     34 	done
     35 }
     36 
     37 
     38 
     39 # potion 1
     40 move_mouse_steps 1756 808
     41 msleep 40 75
     42 right_click
     43 msleep 50 100
     44 move_mouse_steps 1756 848
     45 left_click
     46 msleep 100 250
     47 
     48 exit
     49 
     50 # potion 2
     51 move_mouse 1797 802
     52 msleep 40 75
     53 right_click
     54 msleep 50 100
     55 move_mouse 1795 849
     56 msleep 50 100
     57 left_click
     58 msleep 100 250