From 7cffbd642e5704edd9019247427947ea356e3f25 Mon Sep 17 00:00:00 2001 From: EtorixDev <92535668+EtorixDev@users.noreply.github.com> Date: Mon, 28 Oct 2024 00:23:18 -0700 Subject: [PATCH 1/3] WinWait requires at least one of the main 4 keys be set. --- ahk/_async/engine.py | 4 ++++ ahk/_sync/engine.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/ahk/_async/engine.py b/ahk/_async/engine.py index 64b9b33..20306ce 100644 --- a/ahk/_async/engine.py +++ b/ahk/_async/engine.py @@ -3315,6 +3315,10 @@ async def win_wait( """ Analog for `WinWait `_ """ + 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, diff --git a/ahk/_sync/engine.py b/ahk/_sync/engine.py index e6d2da8..3779feb 100644 --- a/ahk/_sync/engine.py +++ b/ahk/_sync/engine.py @@ -3302,6 +3302,10 @@ def win_wait( """ Analog for `WinWait `_ """ + 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, From 9507775c6f4312cf76612036fe195223ffa5f766 Mon Sep 17 00:00:00 2001 From: EtorixDev <92535668+EtorixDev@users.noreply.github.com> Date: Mon, 28 Oct 2024 01:20:29 -0700 Subject: [PATCH 2/3] Cast control to number if numeric & unset ctrl if falsy for v2. --- ahk/templates/daemon-v2.ahk | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/ahk/templates/daemon-v2.ahk b/ahk/templates/daemon-v2.ahk index 78e815f..6989193 100644 --- a/ahk/templates/daemon-v2.ahk +++ b/ahk/templates/daemon-v2.ahk @@ -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] @@ -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) @@ -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] @@ -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] @@ -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] @@ -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) From 323bc5f93d389c2e7846ee4b11ccd0239cdba762 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 20 Dec 2024 09:11:11 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- ahk/_async/engine.py | 2 +- ahk/_constants.py | 16 ++++++---------- ahk/_sync/engine.py | 2 +- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/ahk/_async/engine.py b/ahk/_async/engine.py index 20306ce..3e01a7b 100644 --- a/ahk/_async/engine.py +++ b/ahk/_async/engine.py @@ -3317,7 +3317,7 @@ async def win_wait( """ 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" + 'Expected non-blank value for at least one of the following: title, text, exclude_title, exclude_text' ) args = self._format_win_args( title=title, diff --git a/ahk/_constants.py b/ahk/_constants.py index c643eab..60f5a60 100644 --- a/ahk/_constants.py +++ b/ahk/_constants.py @@ -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] @@ -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) @@ -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] @@ -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] @@ -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] @@ -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) diff --git a/ahk/_sync/engine.py b/ahk/_sync/engine.py index 3779feb..cbf44eb 100644 --- a/ahk/_sync/engine.py +++ b/ahk/_sync/engine.py @@ -3304,7 +3304,7 @@ def win_wait( """ 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" + 'Expected non-blank value for at least one of the following: title, text, exclude_title, exclude_text' ) args = self._format_win_args( title=title,