Skip to content

Instantly share code, notes, and snippets.

@qzane
Created September 16, 2016 05:52
Show Gist options
  • Save qzane/3b0ad0a477902673eacfb3bf8ea56f7d to your computer and use it in GitHub Desktop.
Save qzane/3b0ad0a477902673eacfb3bf8ea56f7d to your computer and use it in GitHub Desktop.
helper for GoldenDict on windows
import pyautogui
import pyhooked
from pyhooked import Hook, MouseEvent
import sys,os
import time
import subprocess
OLD_LEFT = 0.0
from tkinter import Tk
TK = Tk()
def get_clipboard():
return TK.clipboard_get()
def handler(event):
global OLD_LEFT, OLD_WHEEL
if isinstance(event, MouseEvent):
if(False and event.current_key=='WheelButton' and event.event_type=='key up'):
#pyautogui.click(button='right')
#print('a')
sys.stdout.flush()
pyautogui.hotkey('ctrl', 'c')
if(True and event.current_key=='LButton' and event.event_type=='key up'):
#print('b1')
sys.stdout.flush()
now = time.time()
if abs(now-OLD_LEFT) < 0.3:
#print('b2')
sys.stdout.flush()
pyautogui.hotkey('ctrl', 'c')
#print('python speaker.py ')
#sys.stdout.flush()
#os.system('python speaker.py '+get_clipboard())
subprocess.Popen(['python','speaker.py',get_clipboard()])
OLD_LEFT = now
if(False and event.current_key=='WheelButton' and event.event_type=='key up'):
pyautogui.click(clicks=2)
pyautogui.hotkey('ctrl', 'c')
def main():
hk = Hook()
hk.handler = handler
hk.hook(False, True)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment