Advertisement
Guest User

restrain mouse

a guest
Apr 2nd, 2010
1,850
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.03 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. borderxl=$1
  4. borderyu=$2
  5.  
  6. borderxr=$3
  7. borderyd=$4
  8.  
  9. check=0
  10.  
  11. if [ $borderxl -gt $borderxr ]
  12. then
  13.     check=1
  14. fi
  15.  
  16. if [ $borderyu -gt $borderyd ]
  17. then
  18.     check=1
  19. fi
  20. if [ $check -ge "1" ]
  21. then
  22.     echo "Make sure the first coordinate pair refers to the upper left corner"
  23.     echo "and the second pair refers to the lower right one."
  24. fi
  25.  
  26. if [ $check -lt "1" ]
  27. then
  28.     while [ true ]
  29.     do
  30.         check=0
  31.         xpos=`xdotool getmouselocation | awk '{ print $1}'`
  32.         xpos=${xpos:2}
  33.         #xpos=`getcurpos | awk '{ print $1}'`
  34.         ypos=`xdotool getmouselocation | awk '{ print $2}'`
  35.         ypos=${ypos:2}
  36.         #ypos=`getcurpos | awk '{ print $2}'`
  37.        
  38.         if [ $xpos -gt $borderxr ]
  39.         then
  40.             check=1
  41.             xpos=$borderxr
  42.         fi
  43.    
  44.         if [ $ypos -gt $borderyd ]
  45.         then
  46.             check=1
  47.             ypos=$borderyd
  48.         fi
  49.    
  50.         if [ $xpos -lt $borderxl ]
  51.         then
  52.             check=1
  53.             xpos=$borderxl
  54.         fi
  55.    
  56.         if [ $ypos -lt $borderyu ]
  57.         then
  58.             check=1
  59.             ypos=$borderyu
  60.         fi
  61.    
  62.    
  63.         if [ $check -ge "1" ]
  64.         then
  65.             xdotool mousemove $xpos $ypos
  66.         fi
  67.     done   
  68. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement