This thread concerns developing a tool to control mouse cursor movement using only single key/switch.
It was a part of another thread initially, but it has been split.
Original idea came from Will (standard7452) in this thread: Need on-screen keyboard with mouse functions
The latest OneSwitch package is attached to this post.
________________
Update, version-1.2:
Added "Scan" button to Radar/NavBar GUIs (thanks to Greengeek for the idea), what makes possible to automatically configure proper input device and a switch keycode.
The 'keyhunter' script will be also launched right after installing the .pet.
Update, version 1.3:
- a small correction in keyhunter script (sometimes Radar/NavBar wasn't restarted properly, hope it'll be ok now);
- added circular mode of scanning in XVKBD mode (only in Radar).
This feature has been done some time ago as a separate Radar version for use with Mike's custom Xvkbd layouts.
So now it's been merged into the main OneSwitch package.
________________________________
(original/previous content)
I saw that thread.greengeek wrote:BTW - My reason for wanting these scripts to help with mouse movement is to allow an inexperienced or physically challenged user to easily select between a limited number of mousepointer_position_choices. That way they can have some degree of functionality by having a "mouseclick" button, but no actual ability to move the mouse anywhere I don't want it to go.
Been thinking a while about that and about how you want to employ xdotool and came up with this; perhaps it will help you a bit with the task, somehow..?
First, using xbindkeys (it's OOTB in Slacko) bind, for example, "pause/break" key (OP has mentioned about this key) with echo true > /tmp/button_press_signal command (see screenshot, I also use xbindkeys-config GUI).
And the script works this way:
1. It moves cursor right until pause/break key is pressed.
2. Then stops for a while (0.5s) and starts moving cursor down until pause/break key is pressed.
3. Then "left-click" signal is sent and cursor stays in place until pause/break key is pressed again - and the loop continues.
Maybe this description is a bit fuzzy, but when you see how it works everything will be clear.
BTW, launch this script from a terminal window to have fast and easy way to terminate it (CTRL+C).
Code: Select all
#!/bin/bash
# Req.: xdotool and xbindkeys
# Note: bind a dead key, for exmample 'pause/break' with the following command:
# echo true > /tmp/button_press_signal
# -----------------------------------------------------------------------------
STEP=5 # X/Y leap
SPEED=0.1 # speed (0.1s)
# -----------------------------------------------------------------------------
# Temporary file for inter-communication
PRESS=/tmp/button_press_signal
# Make this file empty initially
: > $PRESS
# Read current screen resolution
read MAXX MAXY <<< `xwininfo -root | awk 'NR>=8&&NR<=9 {print $2}'`
# Infinite loop
while :; do
X=0
Y=10
# Loop: If tempfile is empty - move cursor right
until [ -s $PRESS ]; do
X=$(($X+$STEP)); [ "$X" -ge "$MAXX" ] && X=0 # increase X coordinate
xdotool mousemove $X $Y
sleep $SPEED
done
: > $PRESS # reset tempfile
sleep 0.5
# Loop: If tempfile is empty - move cursor down
until [ -s $PRESS ]; do
Y=$(($Y+$STEP)); [ "$Y" -ge "$MAXY" ] && Y=10 # increase Y coordinate
xdotool mousemove $X $Y
sleep $SPEED
done
: > $PRESS # reset tempfile
Y=$(($Y-$STEP)) # needed to refine coordinates
xdotool click 1 # left-click
# If tempfile is empty - do nothing
until [ -s $PRESS ]; do
sleep $SPEED
done
: > $PRESS # reset tempfile
done
Greetings![/img]