Skip to content

Instantly share code, notes, and snippets.

@OKsign
Created May 4, 2019 16:31
Show Gist options
  • Save OKsign/72b8e77ba284f172aa37fc69b66e2731 to your computer and use it in GitHub Desktop.
Save OKsign/72b8e77ba284f172aa37fc69b66e2731 to your computer and use it in GitHub Desktop.
# apps: Xclip, Xdotool, Zenity
import time
choose1 = "zenity --entry --title='Input' --text='Mouse = 1, Size and Position of Window = 2, Activate App = 3'"
user_choose1 = system.exec_command(choose1)
if user_choose1 is '2':
time.sleep(1.5)
sizepos = "eval $(xdotool getwindowfocus getwindowgeometry --shell); echo 'os.system(\"xdotool windowsize $(xdotool getwindowfocus)' $WIDTH $HEIGHT'\")''\ntime.sleep(0.7)''\nos.system(\"xdotool windowmove $(xdotool getwindowfocus) Replace_Me\") # Get position of top-left corner of window and paste.' | xclip -selection clipboard"
system.exec_command(sizepos)
time.sleep(0.5)
os.system("notify-send 'Script 12.1 for AutoKey' 'Done!'")
if user_choose1 is '1':
command1 = "zenity --entry --title='Input' --text='xy position = 0, Left Click = 1, Middle Click = 2, Right Click = 3'"
user_input = system.exec_command(command1)
if user_input is '0':
writeclip = "eval $(xdotool getmouselocation --shell); echo $X $Y | xclip -selection clipboard"
system.exec_command(writeclip)
time.sleep(0.5)
os.system("notify-send 'Script 12.1 for AutoKey' 'Done!'")
if user_input is '1':
writeclip = "eval $(xdotool getmouselocation --shell); echo 'os.system(\"xdotool mousemove '$X $Y 'click 1\") # left click' | xclip -selection clipboard"
system.exec_command(writeclip)
time.sleep(0.5)
os.system("notify-send 'Script 12.1 for AutoKey' 'Done!'")
if user_input is '2':
writeclip = "eval $(xdotool getmouselocation --shell); echo 'os.system(\"xdotool mousemove '$X $Y 'click 2\") # middle click' | xclip -selection clipboard"
system.exec_command(writeclip)
time.sleep(0.5)
os.system("notify-send 'Script 12.1 for AutoKey' 'Done!'")
if user_input is '3':
writeclip = "eval $(xdotool getmouselocation --shell); echo 'os.system(\"xdotool mousemove '$X $Y 'click 3\") # right click' | xclip -selection clipboard"
system.exec_command(writeclip)
time.sleep(0.5)
os.system("notify-send 'Script 12.1 for AutoKey' 'Done!'")
if user_choose1 is '3':
time.sleep(1)
winClass = window.get_active_class()
if 'nemo' not in winClass:
splitva = [x.strip() for x in winClass.split('.')]
valueClass = splitva[1]
time.sleep(0.5)
system.exec_command("echo 'os.system(\"xdotool windowactivate $(xdotool search --onlyvisible --class %s)\")''\ntime.sleep(1)' | xclip -sel clip" % valueClass)
time.sleep(0.5)
os.system("notify-send 'Script 12.1 for AutoKey' 'Done!'")
if 'nemo.Nemo' in winClass:
splitva = [x.strip() for x in winClass.split('.')]
valueClass = splitva[1]
time.sleep(0.5)
system.exec_command("echo 'os.system(\"xdotool search --onlyvisible --class %s | xargs -n 1 xdotool windowactivate\")''\ntime.sleep(1)' | xclip -sel clip" % valueClass)
time.sleep(0.5)
os.system("notify-send 'Script 12.1 for AutoKey' 'Done!'")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment