Skip to content

Commit

Permalink
Merge pull request #83 from DizzyThermal/win-send-delay
Browse files Browse the repository at this point in the history
ahk.window.Window.send now respects delay, supports press_duration
  • Loading branch information
spyoungtech committed May 16, 2020
2 parents e85591d + 231df62 commit 85ef99d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions ahk/templates/window/win_send.ahk
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{% extends "base.ahk" %}
{% block body %}
SetKeyDelay, {{ delay }}, {{ press_duration }}

{% if raw %}ControlSendRaw{% else %}ControlSend{% endif %}, , {{ keys }}, {{ title }}
{% endblock body %}
5 changes: 3 additions & 2 deletions ahk/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def move(self, x='', y='', width=None, height=None):
)
self.engine.run_script(script)

def send(self, keys, delay=None, raw=False, blocking=False, escape=False):
def send(self, keys, delay=10, raw=False, blocking=False, escape=False, press_duration=-1):
"""
Send keystrokes directly to the window.
Uses ControlSend
Expand All @@ -519,7 +519,8 @@ def send(self, keys, delay=None, raw=False, blocking=False, escape=False):
script = self._render_template(
'window/win_send.ahk',
title=f"ahk_id {self.id}",
keys=keys, raw=raw, delay=delay, blocking=blocking
keys=keys, raw=raw, delay=delay,
press_duration=press_duration, blocking=blocking
)
return self.engine.run_script(script, blocking=blocking)

Expand Down

0 comments on commit 85ef99d

Please sign in to comment.