Skip to content

Instantly share code, notes, and snippets.

@OKsign
Created January 3, 2020 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OKsign/f905773523ab9c1c5d8809d2dd74d13f to your computer and use it in GitHub Desktop.
Save OKsign/f905773523ab9c1c5d8809d2dd74d13f to your computer and use it in GitHub Desktop.
# Script 6.3 for AutoKey
# apps: xclip,xdotool
import time
def categ_other_2():
keyboard.send_keys("other")
time.sleep(1.00)
keyboard.send_keys("<tab>")
time.sleep(0.1)
keyboard.send_keys("<tab>")
time.sleep(0.1)
keyboard.send_keys("<tab>")
time.sleep(0.30)
keyboard.send_keys("<down>")
time.sleep(0.30)
keyboard.send_keys("<enter>")
time.sleep(1.3)
keyboard.send_keys("<ctrl>+v")
time.sleep(0.50)
keyboard.send_keys("<tab>")
time.sleep(0.50)
keyboard.send_keys("<ctrl>+v")
time.sleep(0.50)
keyboard.send_keys("<tab>")
time.sleep(0.1)
keyboard.send_keys("<tab>")
time.sleep(0.1)
keyboard.send_keys("<tab>")
time.sleep(0.1)
keyboard.send_keys("<tab>")
time.sleep(0.1)
keyboard.send_keys("<tab>")
time.sleep(0.30)
keyboard.send_keys("<enter>")
time.sleep(1.2)
keyboard.send_keys("<escape>")
def categ_other():
keyboard.send_keys("other")
time.sleep(1.00)
keyboard.send_keys("<tab>")
time.sleep(0.1)
keyboard.send_keys("<tab>")
time.sleep(0.1)
keyboard.send_keys("<tab>")
time.sleep(0.30)
keyboard.send_keys("<down>")
time.sleep(0.30)
keyboard.send_keys("<enter>")
time.sleep(1.3)
keyboard.send_keys(outcopt1)
time.sleep(0.50)
keyboard.send_keys("<tab>")
time.sleep(0.50)
keyboard.send_keys("<ctrl>+v")
time.sleep(0.50)
keyboard.send_keys("/")
os.system("sleep 0.3; xdotool key Alt_L+Return")
time.sleep(1)
keyboard.send_keys("<ctrl>+c")
time.sleep(0.80)
copt1 = "x=$(xclip -o);sleep 0.50;echo $x"
outcopt1 = system.exec_command(copt1)
time.sleep(0.50)
keyboard.send_keys("<tab>")
time.sleep(0.1)
keyboard.send_keys("<tab>")
time.sleep(0.1)
keyboard.send_keys("<tab>")
time.sleep(0.30)
keyboard.send_keys("<ctrl>+c")
time.sleep(0.80)
keyboard.send_keys("<escape>")
time.sleep(0.20)
os.system("cinnamon-menu-editor &")
time.sleep(1.50)
## categ_other
activeWindow = window.get_active_title()
if 'Main Menu' in activeWindow:
categ_other()
go_other = 1
else:
go_other = 0
if go_other == 0:
time.sleep(1.50)
activeWindow = window.get_active_title()
if 'Main Menu' in activeWindow:
categ_other()
go_other = 1
else:
go_other = 0
if go_other == 0:
time.sleep(1.50)
activeWindow = window.get_active_title()
if 'Main Menu' in activeWindow:
categ_other()
go_other = 1
else:
dialog.info_dialog("Script 6.3 for AutoKey", "Main Menu (Active Window) Not Found, Run Script Again." , width = '320')
quit()
if go_other == 1:
time.sleep(0.30)
keyboard.send_keys(outcopt1)
time.sleep(0.50)
keyboard.send_keys("<tab>")
time.sleep(0.1)
keyboard.send_keys("<tab>")
time.sleep(0.1)
keyboard.send_keys("<tab>")
time.sleep(0.1)
keyboard.send_keys("<tab>")
time.sleep(0.1)
keyboard.send_keys("<tab>")
time.sleep(0.30)
keyboard.send_keys("<enter>")
time.sleep(1.2)
activeWindow = window.get_active_title()
if 'Main Menu' in activeWindow: # 'allow executing file as program' checked
keyboard.send_keys("<escape>")
time.sleep(0.30)
os.system("notify-send 'Add New Item to App Menu' 'Done!'")
quit()
else:
keyboard.send_keys("<escape>")
time.sleep(0.7)
keyboard.send_keys("<tab>")
time.sleep(0.1)
keyboard.send_keys("<tab>")
time.sleep(0.30)
keyboard.send_keys("xdg-open '")
time.sleep(0.50)
keyboard.send_keys("<ctrl>+v")
time.sleep(0.50)
keyboard.send_keys("/")
time.sleep(0.30)
keyboard.send_keys(outcopt1)
time.sleep(0.50)
keyboard.send_keys("'")
time.sleep(0.30)
keyboard.send_keys("<tab>")
time.sleep(0.1)
keyboard.send_keys("<tab>")
time.sleep(0.1)
keyboard.send_keys("<tab>")
time.sleep(0.1)
keyboard.send_keys("<tab>")
time.sleep(0.1)
keyboard.send_keys("<tab>")
time.sleep(0.30)
keyboard.send_keys("<enter>")
time.sleep(1.2)
activeWindow = window.get_active_title()
if 'Main Menu' in activeWindow:
keyboard.send_keys("<escape>")
time.sleep(0.30)
os.system("notify-send 'Add New Item to App Menu' 'Done!'")
quit()
else: # file not supported - without box to edit name in 'properties' window
time.sleep(0.2)
keyboard.send_keys("<escape>")
time.sleep(0.3)
keyboard.send_keys("<escape>")
time.sleep(0.3)
keyboard.send_keys("<escape>")
time.sleep(0.9)
os.system("sleep 0.3; xdotool key Alt_L+Return")
time.sleep(1.6)
keyboard.send_keys("<ctrl>+c")
time.sleep(0.5)
keyboard.send_keys("<tab>")
time.sleep(0.2)
keyboard.send_keys("<tab>")
time.sleep(0.2)
keyboard.send_keys("<ctrl>+c")
time.sleep(0.80)
keyboard.send_keys("<escape>")
time.sleep(0.20)
os.system("cinnamon-menu-editor &")
time.sleep(1.50)
## categ_other
activeWindow = window.get_active_title()
if 'Main Menu' in activeWindow:
categ_other_2()
go_other = 1
else:
go_other = 0
if go_other == 0:
time.sleep(1.50)
activeWindow = window.get_active_title()
if 'Main Menu' in activeWindow:
categ_other_2()
go_other = 1
time.sleep(2)
activeWindow = window.get_active_title()
time.sleep(1)
if 'Main Menu' in activeWindow:
os.system("notify-send 'Add New Item to App Menu' 'Done!'")
else:
go_other = 0
if go_other == 0:
time.sleep(1.50)
activeWindow = window.get_active_title()
if 'Main Menu' in activeWindow:
categ_other_2()
go_other = 1
time.sleep(2)
activeWindow = window.get_active_title()
time.sleep(1)
if 'Main Menu' in activeWindow:
os.system("notify-send 'Add New Item to App Menu' 'Done!'")
else:
dialog.info_dialog("Script 6.3 for AutoKey", "File Is Not Supported." , width = '250')
else:
dialog.info_dialog("Script 6.3 for AutoKey", "Main Menu (Active Window) Not Found, Run Script Again." , width = '320')
quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment