|
@@ -16,7 +16,7 @@ except ImportError:
|
|
|
exit()
|
|
|
|
|
|
from pyautogui import mouseDown as mouse_down, mouseUp as mouse_up
|
|
|
-from keyboard import press as key_down, release as key_up, on_release as keyboard_hook
|
|
|
+from keyboard import press as key_down, release as key_up, on_release as keyboard_hook, KeyboardEvent
|
|
|
# Not entirely sure why this doesn't work
|
|
|
#from mouse import press as mouse_down, release as mouse_up, click as mouse_press, move as mouse_move
|
|
|
|
|
@@ -143,6 +143,8 @@ class Tyrell():
|
|
|
hold: int
|
|
|
def __init__(self, profile_name: str):
|
|
|
self.profile = {
|
|
|
+ "activator": "`",
|
|
|
+ "helper": "?",
|
|
|
"delay": 50,
|
|
|
"hold": 20,
|
|
|
"tick": 50,
|
|
@@ -160,6 +162,10 @@ class Tyrell():
|
|
|
print(err)
|
|
|
exit()
|
|
|
self.profile = t
|
|
|
+ if "activator" not in self.profile:
|
|
|
+ self.profile["activator"] = "`"
|
|
|
+ if "helper" not in self.profile:
|
|
|
+ self.profile["helper"] = "?"
|
|
|
if "hold" not in self.profile:
|
|
|
self.profile["hold"] = 20
|
|
|
if "delay" not in self.profile:
|
|
@@ -247,22 +253,38 @@ class Tyrell():
|
|
|
if act.tick():
|
|
|
act.do(self.delay, self.hold)
|
|
|
|
|
|
- def callback(self, event):
|
|
|
+ def callback(self, event: KeyboardEvent):
|
|
|
key_name = event.name
|
|
|
- if key_name == "`":
|
|
|
+ if key_name == self.profile["activator"]:
|
|
|
if self.toggle():
|
|
|
print_ok("ON")
|
|
|
else:
|
|
|
print_ok("OFF")
|
|
|
elif self.toggled:
|
|
|
- if key_name in self.keybinds:
|
|
|
+ #print(f"Name: {event.name}")
|
|
|
+ #print(f"Code: {event.scan_code}")
|
|
|
+ #print(f"Modifiers: {event.modifiers}")
|
|
|
+ if self.profile["helper"] == "?" and "shift" in event.modifiers and event.name == "/" or key_name == self.profile["helper"]:
|
|
|
+ print_ok(f"{int(1000 / self.profile['tick'])} ticks per second ({self.profile['tick']} ms per tick)")
|
|
|
+ print_ok(f"Name placeholder: {self.profile['placeholder_name']}")
|
|
|
+ print_warn(f"{self.profile["activator"]} -> Activate/Deactivate")
|
|
|
+ print_warn(f"{self.profile["helper"]} -> Displays Help")
|
|
|
+ for key in self.keybinds:
|
|
|
+ act = self.keybinds[key]
|
|
|
+ if act.max_delay == 0 and act.toggled:
|
|
|
+ print_info(f"{key} -> {act.kind}")
|
|
|
+ else:
|
|
|
+ print_info(f"{key} -> {act.kind} = {act.toggled}")
|
|
|
+ print_ok("Please use " + style("CTRL+C", fg="bright_yellow") + " to stop")
|
|
|
+ elif key_name in self.keybinds:
|
|
|
act = self.keybinds[key_name]
|
|
|
if act.max_delay == 0 and act.toggled:
|
|
|
print_info(f"{key_name} -> {act.kind}")
|
|
|
act.do(self.delay, self.hold)
|
|
|
else:
|
|
|
print_info(f"{key_name} -> {act.kind} = {act.toggle()}")
|
|
|
- self.toggle()
|
|
|
+ self.toggle()
|
|
|
+ print_ok("OFF")
|
|
|
|
|
|
async def background(self):
|
|
|
while True:
|
|
@@ -289,6 +311,10 @@ if __name__ == "__main__":
|
|
|
print_err("Missing 'keys' directory")
|
|
|
print_info("(Might want some keybinds)")
|
|
|
exit()
|
|
|
+ print_ok(f"{int(1000 / ty.profile['tick'])} ticks per second ({ty.profile['tick']} ms per tick)")
|
|
|
+ print_ok(f"Name placeholder: {ty.profile['placeholder_name']}")
|
|
|
+ print_warn(f"{ty.profile["activator"]} -> Activate/Deactivate")
|
|
|
+ print_warn(f"{ty.profile["helper"]} -> Displays Help")
|
|
|
for ent in listdir("keys"):
|
|
|
if ent.startswith(".") or not ent.endswith(".toml") or isdir(ent):
|
|
|
continue
|
|
@@ -298,7 +324,7 @@ if __name__ == "__main__":
|
|
|
ty.add_action(t["keybind"], Action(t["kind"], extra=t, delay=t["duration"]))
|
|
|
else:
|
|
|
ty.add_action(t["keybind"], Action(t["kind"], extra=t))
|
|
|
- print(f"{t['keybind']} -> {t['kind']}")
|
|
|
+ print_info(f"{t['keybind']} -> {t['kind']}")
|
|
|
if len(ty.keybinds) == 0:
|
|
|
print_err("Missing keybinds")
|
|
|
print_info("(Might want some keybinds, place them in a 'keys' directory)")
|
|
@@ -306,6 +332,7 @@ if __name__ == "__main__":
|
|
|
exit()
|
|
|
ty.enable(all_notickers=True)
|
|
|
ty.disable()
|
|
|
+ print_ok("Please use " + style("CTRL+C", fg="bright_yellow") + " to stop")
|
|
|
try:
|
|
|
run(ty.mainloop())
|
|
|
except KeyboardInterrupt:
|