Skip to content

Commit

Permalink
[feat] add ability to change SendMode
Browse files Browse the repository at this point in the history
  • Loading branch information
spyoungtech committed Feb 28, 2024
1 parent 41e73e1 commit 8ab9a98
Show file tree
Hide file tree
Showing 9 changed files with 514 additions and 46 deletions.
127 changes: 108 additions & 19 deletions ahk/_async/engine.py

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions ahk/_async/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def result(self, timeout: Optional[float] = None) -> T_SyncFuture:
'AHKGetClipboardAll',
'AHKGetCoordMode',
'AHKGetSendLevel',
'AHKGetSendMode',
'AHKGetTitleMatchMode',
'AHKGetTitleMatchSpeed',
'AHKGetVolume',
Expand Down Expand Up @@ -125,6 +126,7 @@ def result(self, timeout: Optional[float] = None) -> T_SyncFuture:
'AHKSetCoordMode',
'AHKSetDetectHiddenWindows',
'AHKSetSendLevel',
'AHKSetSendMode',
'AHKSetTitleMatchMode',
'AHKSetVolume',
'AHKShowToolTip',
Expand Down Expand Up @@ -540,6 +542,10 @@ async def function_call(self, function_name: Literal['AHKSetCoordMode'], args: L
@overload
async def function_call(self, function_name: Literal['AHKGetSendLevel']) -> int: ...
@overload
async def function_call(self, function_name: Literal['AHKSetSendMode'], args: List[str]) -> None: ...
@overload
async def function_call(self, function_name: Literal['AHKGetSendMode']) -> str: ...
@overload
async def function_call(self, function_name: Literal['AHKSetSendLevel'], args: List[str]) -> None: ...
@overload
async def function_call(self, function_name: Literal['AHKWinWait'], args: Optional[List[str]] = None, *, blocking: bool = True, engine: Optional[AsyncAHK[Any]] = None) -> Union[AsyncWindow, AsyncFutureResult[AsyncWindow]]: ...
Expand Down
114 changes: 111 additions & 3 deletions ahk/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -1728,14 +1728,25 @@
direction := args[5]
r := args[6]
relative_to := args[7]
send_mode := args[8]
current_coord_rel := Format("{}", A_CoordModeMouse)
current_send_mode := Format("{}", A_SendMode)
if (send_mode != "") {
SendMode, %send_mode%
}
if (relative_to != "") {
CoordMode, Mouse, %relative_to%
}
Click, %x%, %y%, %button%, %direction%, %r%
if (send_mode != "") {
SendMode, %current_send_mode%
}
if (relative_to != "") {
CoordMode, Mouse, %current_coord_rel%
}
Expand Down Expand Up @@ -1779,6 +1790,18 @@
{% endblock AHKSetCoordMode %}
}
AHKGetSendMode(args*) {
return FormatResponse("ahk.message.StringResponseMessage", A_SendMode)
}
AHKSetSendMode(args*) {
mode := args[1]
SendMode, %mode%
return FormatNoValueResponse()
}
AHKMouseClickDrag(args*) {
{% block AHKMouseClickDrag %}
button := args[1]
Expand All @@ -1789,6 +1812,11 @@
speed := args[6]
relative := args[7]
relative_to := args[8]
send_mode := args[8]
current_send_mode := Format("{}", A_SendMode)
if (send_mode != "") {
SendMode, %send_mode%
}
current_coord_rel := Format("{}", A_CoordModeMouse)
Expand All @@ -1802,6 +1830,10 @@
CoordMode, Mouse, %current_coord_rel%
}
if (send_mode != "") {
SendMode, %current_send_mode%
}
return FormatNoValueResponse()
{% endblock AHKMouseClickDrag %}
Expand Down Expand Up @@ -1880,18 +1912,29 @@
str := args[1]
key_delay := args[2]
key_press_duration := args[3]
send_mode := args[4]
current_delay := Format("{}", A_KeyDelay)
current_key_duration := Format("{}", A_KeyDuration)
current_send_mode := Format("{}", A_SendMode)
if (key_delay != "" or key_press_duration != "") {
SetKeyDelay, %key_delay%, %key_press_duration%
}
if (send_mode != "") {
SendMode, %send_mode%
}
Send,% str
if (key_delay != "" or key_press_duration != "") {
SetKeyDelay, %current_delay%, %current_key_duration%
}
if (send_mode != "") {
SendMode, %current_send_mode%
}
return FormatNoValueResponse()
{% endblock AHKSend %}
}
Expand All @@ -1901,18 +1944,30 @@
str := args[1]
key_delay := args[2]
key_press_duration := args[3]
send_mode := args[4]
current_delay := Format("{}", A_KeyDelay)
current_key_duration := Format("{}", A_KeyDuration)
current_send_mode := Format("{}", A_SendMode)
if (key_delay != "" or key_press_duration != "") {
SetKeyDelay, %key_delay%, %key_press_duration%
}
if (send_mode != "") {
SendMode, %send_mode%
}
SendRaw,% str
if (key_delay != "" or key_press_duration != "") {
SetKeyDelay, %current_delay%, %current_key_duration%
}
if (send_mode != "") {
SendMode, %current_send_mode%
}
return FormatNoValueResponse()
{% endblock AHKSendRaw %}
}
Expand Down Expand Up @@ -4728,11 +4783,23 @@
y := args[2]
speed := args[3]
relative := args[4]
send_mode := args[5]
current_send_mode := Format("{}", A_SendMode)
if (send_mode != "") {
SendMode send_mode
}
if (relative != "") {
MouseMove(x, y, speed, "R")
MouseMove(x, y, speed, "R")
} else {
MouseMove(x, y, speed)
MouseMove(x, y, speed)
}
if (send_mode != "") {
SendMode current_send_mode
}
resp := FormatNoValueResponse()
return resp
{% endblock AHKMouseMove %}
Expand All @@ -4747,7 +4814,13 @@
direction := args[5]
r := args[6]
relative_to := args[7]
send_mode := args[8]
current_coord_rel := Format("{}", A_CoordModeMouse)
current_send_mode := Format("{}", A_SendMode)
if (send_mode != "") {
SendMode send_mode
}
if (relative_to != "") {
CoordMode("Mouse", relative_to)
Expand All @@ -4759,6 +4832,9 @@
CoordMode("Mouse", current_coord_rel)
}
if (send_mode != "") {
SendMode current_send_mode
}
return FormatNoValueResponse()
{% endblock AHKClick %}
Expand Down Expand Up @@ -4798,6 +4874,19 @@
{% endblock AHKSetCoordMode %}
}
AHKGetSendMode(args*) {
return FormatResponse("ahk.message.StringResponseMessage", A_SendMode)
}
AHKSetSendMode(args*) {
mode := args[1]
SendMode mode
return FormatNoValueResponse()
}
AHKMouseClickDrag(args*) {
{% block AHKMouseClickDrag %}
button := args[1]
Expand All @@ -4808,8 +4897,13 @@
speed := args[6]
relative := args[7]
relative_to := args[8]
send_mode := args[9]
current_coord_rel := Format("{}", A_CoordModeMouse)
current_send_mode := Format("{}", A_SendMode)
if (send_mode != "") {
SendMode send_mode
}
if (relative_to != "") {
CoordMode("Mouse", relative_to)
Expand All @@ -4831,6 +4925,10 @@
CoordMode("Mouse", current_coord_rel)
}
if (send_mode != "") {
SendMode current_send_mode
}
return FormatNoValueResponse()
{% endblock AHKMouseClickDrag %}
Expand Down Expand Up @@ -4904,8 +5002,14 @@
str := args[1]
key_delay := args[2]
key_press_duration := args[3]
send_mode := args[4]
current_delay := Format("{}", A_KeyDelay)
current_key_duration := Format("{}", A_KeyDuration)
current_send_mode := Format("{}", A_SendMode)
if (send_mode != "") {
SendMode send_mode
}
if (key_delay != "" or key_press_duration != "") {
SetKeyDelay(key_delay, key_press_duration)
Expand All @@ -4914,6 +5018,10 @@
Send(str)
if (send_mode != "") {
SendMode current_send_mode
}
if (key_delay != "" or key_press_duration != "") {
SetKeyDelay(current_delay, current_key_duration)
}
Expand Down
Loading

0 comments on commit 8ab9a98

Please sign in to comment.