Skip to content

Instantly share code, notes, and snippets.

@zmughal
Last active February 12, 2016 23:03
Show Gist options
  • Save zmughal/6931066 to your computer and use it in GitHub Desktop.
Save zmughal/6931066 to your computer and use it in GitHub Desktop.
#!/bin/sh
if ! which xclip xdotool >/dev/null; then
echo "$0: requires xclip, xdotool"
exit 1
fi
xclip -i -selection primary
TEMP=`xclip -o -selection primary` # store it so it does get lost when clicking
MATLAB_WIN=`xdotool search 'MATLAB R' 2>/dev/null | head -1`
if [ -z "$MATLAB_WIN" ]; then
echo "MATLAB window not found"
exit 1;
fi
xdotool windowactivate "$MATLAB_WIN"
# select center of MATLAB window
xdotool mousemove --window "$MATLAB_WIN" --polar 0 0
xdotool click --window "$MATLAB_WIN" 1
echo $TEMP | xclip -i -selection primary # restore after the clicking
echo $TEMP | xclip -i -selection buffer-cut # restore after the clicking
echo $TEMP | xclip -i -selection clipboard # restore after the clicking
#CODE#xdotool type --window "$MATLAB_WIN" "help"
#CODE#xdotool key --window "$MATLAB_WIN" Ctrl+0 Ctrl+y Return
# don't specify the window --- use the current window because MATLAB behaves
# oddly with focus
xdotool key Ctrl+0 Ctrl+y Return
#CODE#xvkbd -text '\C0\Cy\r'
# select command window = Ctrl+0
# paste = Ctrl+y
# execute = Return
@zmughal
Copy link
Author

zmughal commented Feb 12, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment