Skip to content

Instantly share code, notes, and snippets.

@sl5net
Created October 11, 2020 05:29
Show Gist options
  • Save sl5net/3b951b1d6c29191be3d7c8c4100b424b to your computer and use it in GitHub Desktop.
Save sl5net/3b951b1d6c29191be3d7c8c4100b424b to your computer and use it in GitHub Desktop.
AutoKey Demo add global Shortcut
import time
from autopilot.input import Mouse
# mouse = Mouse.create()
# x, y = mouse.position()
# mouse.move(x + 100, y + 100)
# quit()
# python3 -m pip install pyautogui
# import pyautogui
# import mouse
# pyautogui.moveTo(100,100,duration=0.5)
# mouse.moveTo(100,100,duration=0.5)
# https://github.com/autokey/autokey/wiki/Scripting
# https://codechacha.com/ko/ubuntu-autokey-gtk/
if not store.has_key("runs"):
# Create the value on the first run of the script
store.set_value("runs", 1)
else:
# Otherwise, get the current value and increment it
cur = store.get_value("runs")
store.set_value("runs", cur + 1)
# keyboard.send_keys("I've been run %d times!\n" % store.get_value("runs"))
# I've been run 2 times!
# time.sleep(0.1) # somtimes to short
time.sleep(0.2) # somtimes to short
if False:
# dont work
keyboard.send_keys("<super>")
keyboard.send_keys("<enter>")
else:
# works
keyboard.press_key("<super>")
# keyboard.send_keys("v")
# time.sleep(0.2)
keyboard.release_key("<super>")
keyboard.send_keys("<enter>")
# keyboard.release_key("<ctrl>")
# keyboard.press_key("<ctrl>")
# window.activate(Title, switchDesktop=False, matchClass=False)
time.sleep(.2) # works is needet
keyboard.send_keys("Global shortcut") # works
# keyboard.send_keys("shortcut") # works
# keyboard.send_keys("Custom Shortcut") # works
time.sleep(.3) # works
keyboard.send_keys("<down>") # works
time.sleep(.4) # works
keyboard.send_keys("<enter>") # works
winTitle = window.get_active_title() # Plasma
winClass = window.get_active_class() # plasmashell.plasmashell
toClip = winTitle # Plasma 'Hello World'
clipboard.fill_clipboard(toClip) # https://github.com/autokey/autokey/wiki/API-Examples#clipboard
time.sleep(0.5)
time.sleep(2)
active_title = window.get_active_title()
windetails = window.get_active_geometry()
newX = windetails[0]
newY = windetails[1]
newH = windetails[3]
# window.resize_move(active_title, newX, newY, width=-1, height=-1, matchClass=False)
# mouse.click_absolute(newX+20, newH-50, 1)
mouseAutopilot = Mouse.create()
# press + Button
mouseAutopilot.move(newX+20, newY+newH-70)
mouse.click_absolute(newX+20, newY+newH-70, 1)
time.sleep(.4) # works
keyboard.send_keys("Konsole") # works
# mouse.moveTo(100,100,duration=0.5)
# pyautogui.moveTo(100,100,duration=0.5)
# system.exec_command("xte 'mousemove " + (newX + 20) + " " + ( newY - 50 ) + "'", False)
# mouse.click_absolute(xOrigin+50, yOrigin+200, 1)
#
# mouse.move(xOrigin+50, yOrigin+200)
# Send Keyboard Input
# This action will send keyboard input to the currently running application, just as if you had typed it in yourself.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment