Skip to content

Commit

Permalink
Fixed WinTitles with two different ahk_id values to yield no match.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lexikos committed Apr 20, 2024
1 parent a2251ea commit c51d218
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions source/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1401,13 +1401,16 @@ ResultType WindowSearch::SetCriteria(ScriptThreadSettings &aSettings, LPCTSTR aT
switch (this_criterion)
{
case CRITERION_ID:
mCriterionHwnd = (HWND)ATOU64(start);
HWND hwnd;
hwnd = (HWND)ATOU64(start);
// Note that this can validly be the HWND of a child window; i.e. ahk_id %ChildWindowHwnd% is supported.
if (mCriterionHwnd != HWND_BROADCAST && !IsWindow(mCriterionHwnd)) // Checked here once rather than each call to IsMatch().
if (hwnd != HWND_BROADCAST && !IsWindow(hwnd) // Checked here once rather than each call to IsMatch().
|| (mCriteria & CRITERION_ID) && hwnd != mCriterionHwnd) // Two different IDs have been specified, so there can never be a match.
{
mCriterionHwnd = NULL;
return FAIL; // Inform caller of invalid criteria. No need to do anything else further below.
}
mCriterionHwnd = hwnd;
break;
case CRITERION_PID:
mCriterionPID = ATOU(start);
Expand Down

0 comments on commit c51d218

Please sign in to comment.