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

Method Hotstring

source/hotkey.cpp:2410–2453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2408
2409
2410Hotstring::Hotstring(LPTSTR aName, IObjectPtr aCallback, LPTSTR aOptions, LPTSTR aHotstring, LPTSTR aReplacement
2411 , bool aHasContinuationSection, UCHAR aSuspend)
2412 : mCallback(aCallback) // Any NULL value will cause failure further below.
2413 , mName(NULL)
2414 , mString(NULL), mReplacement(NULL), mStringLength(0)
2415 , mHotCriterion(g->HotCriterion)
2416 , mSuspended(aSuspend)
2417 , mExistingThreads(0)
2418 , mMaxThreads(g_MaxThreadsPerHotkey) // The value of g_MaxThreadsPerHotkey can vary during load-time.
2419 , mPriority(g_HSPriority), mKeyDelay(g_HSKeyDelay), mSendMode(g_HSSendMode) // And all these can vary too.
2420 , mCaseSensitive(g_HSCaseSensitive), mConformToCase(g_HSConformToCase), mDoBackspace(g_HSDoBackspace)
2421 , mOmitEndChar(g_HSOmitEndChar), mSendRaw(aHasContinuationSection ? SCM_RAW_TEXT : g_HSSendRaw)
2422 , mEndCharRequired(g_HSEndCharRequired), mDetectWhenInsideWord(g_HSDetectWhenInsideWord), mDoReset(g_HSDoReset)
2423 , mInputLevel(g_InputLevel)
2424 , mSuspendExempt(g_SuspendExempt || g_SuspendExemptHS)
2425 , mConstructedOK(false)
2426{
2427 bool execute_action = false; // do not assign mReplacement if execute_action is true.
2428 ParseOptions(aOptions, mPriority, mKeyDelay, mSendMode, mCaseSensitive, mConformToCase, mDoBackspace
2429 , mOmitEndChar, mSendRaw, mEndCharRequired, mDetectWhenInsideWord, mDoReset, execute_action, mSuspendExempt);
2430
2431 // To avoid memory leak, this is done only when it is certain the hotstring will be created:
2432 if ( !(mString = SimpleHeap::Malloc(aHotstring)) )
2433 return; // ScriptError() was already called by Malloc().
2434 if ( !(mName = SimpleHeap::Malloc(aName)) )
2435 {
2436 SimpleHeap::Delete(mString); // SimpleHeap allows deletion of most recently added item.
2437 return;
2438 }
2439 mStringLength = (UCHAR)_tcslen(mString);
2440 if (!execute_action && *aReplacement)
2441 {
2442 // SimpleHeap is not used for the replacement as it can be changed at runtime by Hotstring().
2443 if ( !(mReplacement = _tcsdup(aReplacement)) )
2444 {
2445 MemoryError(); // Short msg since very rare.
2446 return;
2447 }
2448 }
2449 else // Leave mReplacement NULL, but make this false so that the hook doesn't do extra work.
2450 mConformToCase = false;
2451
2452 mConstructedOK = true; // Done at the very end.
2453}
2454
2455
2456

Callers

nothing calls this directly

Calls 2

DeleteFunction · 0.85
MemoryErrorFunction · 0.85

Tested by

no test coverage detected