Skip to content

Commit

Permalink
Merge pull request #353 from EtorixDev/unset-arg
Browse files Browse the repository at this point in the history
Fix unset argument behavior on various functions.
  • Loading branch information
spyoungtech authored Dec 20, 2024
2 parents 7af5750 + 9507775 commit a01980a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
4 changes: 4 additions & 0 deletions ahk/_async/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -3315,6 +3315,10 @@ async def win_wait(
"""
Analog for `WinWait <https://www.autohotkey.com/docs/commands/WinWait.htm>`_
"""
if not title and not text and not exclude_title and not exclude_text:
raise ValueError(
"Expected non-blank value for at least one of the following: title, text, exclude_title, exclude_text"
)
args = self._format_win_args(
title=title,
text=text,
Expand Down
4 changes: 4 additions & 0 deletions ahk/_sync/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -3302,6 +3302,10 @@ def win_wait(
"""
Analog for `WinWait <https://www.autohotkey.com/docs/commands/WinWait.htm>`_
"""
if not title and not text and not exclude_title and not exclude_text:
raise ValueError(
"Expected non-blank value for at least one of the following: title, text, exclude_title, exclude_text"
)
args = self._format_win_args(
title=title,
text=text,
Expand Down
16 changes: 6 additions & 10 deletions ahk/templates/daemon-v2.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -2341,7 +2341,7 @@ AHKWindowList(args*) {
AHKControlClick(args*) {
{% block AHKControlClick %}

ctrl := args[1]
ctrl := IsNumber(args[1]) ? Number(args[1]) : args[1]
title := args[2]
text := args[3]
button := args[4]
Expand All @@ -2368,7 +2368,7 @@ AHKControlClick(args*) {
}

try {
ControlClick(ctrl, title, text, button, click_count, options, exclude_title, exclude_text)
ControlClick(ctrl || unset, title, text, button, click_count, options, exclude_title, exclude_text)
}
finally {
DetectHiddenWindows(current_detect_hw)
Expand All @@ -2383,7 +2383,7 @@ AHKControlClick(args*) {
AHKControlGetText(args*) {
{% block AHKControlGetText %}

ctrl := args[1]
ctrl := IsNumber(args[1]) ? Number(args[1]) : args[1]
title := args[2]
text := args[3]
extitle := args[4]
Expand Down Expand Up @@ -2423,7 +2423,7 @@ AHKControlGetText(args*) {
AHKControlGetPos(args*) {
{% block AHKControlGetPos %}

ctrl := args[1]
ctrl := IsNumber(args[1]) ? Number(args[1]) : args[1]
title := args[2]
text := args[3]
extitle := args[4]
Expand Down Expand Up @@ -2462,7 +2462,7 @@ AHKControlGetPos(args*) {

AHKControlSend(args*) {
{% block AHKControlSend %}
ctrl := args[1]
ctrl := IsNumber(args[1]) ? Number(args[1]) : args[1]
keys := args[2]
title := args[3]
text := args[4]
Expand All @@ -2487,11 +2487,7 @@ AHKControlSend(args*) {
}

try {
if (ctrl != "") {
ControlSend(keys, ctrl, title, text, extitle, extext)
} else {
ControlSend(keys,, title, text, extitle, extext)
}
ControlSend(keys, ctrl || unset, title, text, extitle, extext)
}
finally {
DetectHiddenWindows(current_detect_hw)
Expand Down

0 comments on commit a01980a

Please sign in to comment.