forked from mikethrussell/EyeXMouse
-
Notifications
You must be signed in to change notification settings - Fork 3
/
simple_launcher.py
52 lines (40 loc) · 1.18 KB
/
simple_launcher.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!python
# -*- coding: utf-8 -*-
from dragonfly import (Grammar, MappingRule, Function)
import subprocess
eyemouse_handle = None
def create_hidden_window(arguments):
si = subprocess.STARTUPINFO()
si.dwFlags = subprocess.STARTF_USESHOWWINDOW
si.wShowWindow = subprocess.SW_HIDE
return subprocess.Popen(
arguments,
close_fds=True,
startupinfo=si,
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
def eyemouse_launcher(kill=False):
global eyemouse_handle
if kill:
if eyemouse_handle:
eyemouse_handle.terminate()
eyemouse_handle = None
else:
create_hidden_window(["taskkill", "/im", "eyexmouse.exe", "/f"])
elif not eyemouse_handle:
eyemouse_handle = create_hidden_window(
r"EyeXMouse.exe")
grammar = Grammar("mouse_launcher")
class MouseRule(MappingRule):
mapping = {
"Eye Mouse":
Function(eyemouse_launcher, kill=False),
"pop eye":
Function(eyemouse_launcher, kill=True),
}
grammar.add_rule(MouseRule())
grammar.load()
def unload():
global grammar
if grammar:
grammar.unload()
grammar = None