MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / FindGroup

Method FindGroup

source/script.cpp:7360–7382  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7358
7359
7360WinGroup *Script::FindGroup(LPTSTR aGroupName, bool aCreateIfNotFound)
7361// Caller must ensure that aGroupName isn't NULL. But if it's the empty string, NULL is returned.
7362// Returns the Group whose name matches aGroupName. If it doesn't exist, it is created if aCreateIfNotFound==true.
7363// Thread-safety: This function is thread-safe (except when called with aCreateIfNotFound==true) even when
7364// the main thread happens to be calling AddGroup() and changing the linked list while it's being traversed here
7365// by the hook thread. However, any subsequent changes to this function or AddGroup() must be carefully reviewed.
7366{
7367 if (!*aGroupName)
7368 {
7369 if (aCreateIfNotFound)
7370 // An error message must be shown in this case since our caller is about to
7371 // exit the current script thread (and we don't want it to happen silently).
7372 ValueError(_T("Blank group name."), nullptr, FAIL);
7373 return NULL;
7374 }
7375 for (WinGroup *group = mFirstGroup; group != NULL; group = group->mNextGroup)
7376 if (!_tcsicmp(group->mName, aGroupName)) // lstrcmpi() is not used: 1) avoids breaking existing scripts; 2) provides consistent behavior across multiple locales; 3) performance.
7377 return group; // Match found.
7378 // Otherwise, no match found, so create a new group.
7379 if (!aCreateIfNotFound || AddGroup(aGroupName) != OK)
7380 return NULL;
7381 return mLastGroup;
7382}
7383
7384
7385

Callers 3

SetCriteriaMethod · 0.45
PerformMethod · 0.45
BIF_DECLFunction · 0.45

Calls 1

ValueErrorFunction · 0.85

Tested by

no test coverage detected