| 545 | |
| 546 | |
| 547 | Script::Script() |
| 548 | : mFirstLine(NULL), mLastLine(NULL), mCurrLine(NULL) |
| 549 | , mThisHotkeyName(_T("")), mPriorHotkeyName(_T("")), mThisHotkeyStartTime(0), mPriorHotkeyStartTime(0) |
| 550 | , mEndChar(0), mThisHotkeyModifiersLR(0) |
| 551 | , mOnClipboardChangeIsRunning(false), mExitReason(EXIT_NONE) |
| 552 | , mFirstLabel(NULL), mLastLabel(NULL) |
| 553 | , mLastHotFunc(nullptr), mUnusedHotFunc(nullptr) |
| 554 | , mFirstTimer(NULL), mLastTimer(NULL), mTimerEnabledCount(0), mTimerCount(0) |
| 555 | , mFirstMenu(NULL), mLastMenu(NULL), mMenuCount(0) |
| 556 | , mOpenBlock(NULL), mNextLineIsFunctionBody(false), mNoUpdateLabels(false) |
| 557 | , mClassObjectCount(0), mUnresolvedClasses(NULL), mClassProperty(NULL), mClassPropertyDef(NULL) |
| 558 | , mCurrFileIndex(0), mCombinedLineNumber(0) |
| 559 | , mFileSpec(_T("")), mFileDir(_T("")), mFileName(_T("")), mOurEXE(_T("")), mOurEXEDir(_T("")), mMainWindowTitle(_T("")) |
| 560 | , mScriptName(NULL) |
| 561 | , mIsReadyToExecute(false), mAutoExecSectionIsRunning(false) |
| 562 | , mIsRestart(false), mErrorStdOut(false), mErrorStdOutCP(-1) |
| 563 | #ifndef AUTOHOTKEYSC |
| 564 | , mValidateThenExit(false) |
| 565 | , mCmdLineInclude(NULL) |
| 566 | #endif |
| 567 | , mUninterruptedLineCountMax(1000), mUninterruptibleTime(17) |
| 568 | , mCustomIcon(NULL), mCustomIconSmall(NULL) // Normally NULL unless there's a custom tray icon loaded dynamically. |
| 569 | , mCustomIconFile(NULL), mIconFrozen(false), mTrayIconTip(NULL) // Allocated on first use. |
| 570 | , mCustomIconNumber(0) |
| 571 | { |
| 572 | // v1.0.25: mLastScriptRest (removed in v2) and mLastPeekTime are now initialized |
| 573 | // right before the auto-exec section of the script is launched, which avoids an |
| 574 | // initial Sleep(10) in ExecUntil that would otherwise occur. |
| 575 | ZeroMemory(&mNIC, sizeof(mNIC)); // Constructor initializes this, to be safe. |
| 576 | mNIC.hWnd = NULL; // Set this as an indicator that it tray icon is not installed. |
| 577 | |
| 578 | // This is done here rather than in Init() because by then CreateRootPrototypes() |
| 579 | // definitely would have already caused functions to be added to the list. |
| 580 | mFuncs.Alloc(100); // Avoid multiple reallocations for simple scripts. |
| 581 | |
| 582 | #ifdef _DEBUG |
| 583 | if (ID_FILE_EXIT < ID_MAIN_FIRST) // Not a very thorough check. |
| 584 | ScriptError(_T("DEBUG: ID_FILE_EXIT is too large (conflicts with IDs reserved via ID_USER_FIRST).")); |
| 585 | if (MAX_CONTROLS_PER_GUI > ID_USER_FIRST - 3) |
| 586 | ScriptError(_T("DEBUG: MAX_CONTROLS_PER_GUI is too large (conflicts with IDs reserved via ID_USER_FIRST).")); |
| 587 | if (g_ActionCount != ACT_LAST_NAMED_ACTION + 1) |
| 588 | ScriptError(_T("DEBUG: g_act and enum_act are out of sync.")); |
| 589 | int LargestMaxParams, i; |
| 590 | // Find the Largest value of MaxParams used by any command and make sure it |
| 591 | // isn't something larger than expected by the parsing routines: |
| 592 | for (LargestMaxParams = i = 0; i < g_ActionCount; ++i) |
| 593 | if (g_act[i].MaxParams > LargestMaxParams) |
| 594 | LargestMaxParams = g_act[i].MaxParams; |
| 595 | if (LargestMaxParams > MAX_ARGS) |
| 596 | ScriptError(_T("DEBUG: At least one command supports more arguments than allowed.")); |
| 597 | if (sizeof(ActionTypeType) == 1 && g_ActionCount > 256) |
| 598 | ScriptError(_T("DEBUG: Since there are now more than 256 Action Types, the ActionTypeType") |
| 599 | _T(" typedef must be changed.")); |
| 600 | // Ensure binary-search arrays are sorted correctly: |
| 601 | for (int i = 1; i < _countof(g_BIF); ++i) |
| 602 | if (_tcsicmp(g_BIF[i-1].mName, g_BIF[i].mName) >= 0) |
| 603 | ScriptError(_T("DEBUG: g_BIF out of order."), g_BIF[i].mName); |
| 604 | for (int i = 1; i < _countof(g_BIV_A); ++i) |