Skip to content

Commit

Permalink
Only hook mouse events when they are needed
Browse files Browse the repository at this point in the history
  • Loading branch information
WhiteMagic committed May 6, 2018
1 parent 8655e24 commit fe624a7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions action_plugins/macro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions gremlin/event_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down

0 comments on commit fe624a7

Please sign in to comment.