Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unset argument behavior on various functions #359

Merged
merged 4 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
16 changes: 6 additions & 10 deletions ahk/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5354,7 +5354,7 @@
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 @@ -5381,7 +5381,7 @@
}

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 @@ -5396,7 +5396,7 @@
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 @@ -5436,7 +5436,7 @@
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 @@ -5475,7 +5475,7 @@

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 @@ -5500,11 +5500,7 @@
}

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
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
Loading