From fe624a71281198774ba35b2b15ee597307072ded Mon Sep 17 00:00:00 2001 From: WhiteMagic Date: Sun, 6 May 2018 22:11:51 +1000 Subject: [PATCH] Only hook mouse events when they are needed --- action_plugins/macro/__init__.py | 6 ++++++ gremlin/event_handler.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/action_plugins/macro/__init__.py b/action_plugins/macro/__init__.py index f5f602f8..b521ab58 100644 --- a/action_plugins/macro/__init__.py +++ b/action_plugins/macro/__init__.py @@ -1368,6 +1368,9 @@ def _create_mouse_action(self, event): def _record_cb(self): """Starts the recording of key presses.""" if self.button_record.isChecked(): + # Enable mouse event hooking + gremlin.windows_event_hook.MouseHook().start() + # Record keystrokes gremlin.shared_state.set_suspend_input_highlighting(True) self._recording = True @@ -1384,6 +1387,9 @@ def _record_cb(self): el.keyboard_event.disconnect(self._create_key_action) el.mouse_event.disconnect(self._create_mouse_action) + # Disable mouse event hooking + gremlin.windows_event_hook.MouseHook().stop() + def _pause_cb(self): """Adds a pause macro action to the list.""" self._insert_entry_at_current_index(gremlin.macro.PauseAction(0.01)) diff --git a/gremlin/event_handler.py b/gremlin/event_handler.py index 5da6d0bb..95359840 100644 --- a/gremlin/event_handler.py +++ b/gremlin/event_handler.py @@ -180,14 +180,14 @@ def __init__(self): self._init_joysticks() self.keyboard_hook.start() - self.mouse_hook.start() + # self.mouse_hook.start() Thread(target=self._run).start() def terminate(self): """Stops the loop from running.""" self._running = False self.keyboard_hook.stop() - self.mouse_hook.stop() + # self.mouse_hook.stop() def _run(self): """Starts the event loop."""