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

Method Perform

source/script.cpp:11665–12105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11663
11664
11665ResultType Line::Perform()
11666// Performs only this line's action.
11667// Returns OK or FAIL.
11668// The function should not be called to perform any flow-control actions such as
11669// Goto, Return, Block-Begin, Block-End, If, Else, etc.
11670{
11671 TCHAR buf_temp[MAX_REG_ITEM_SIZE]; // For registry and other things.
11672 WinGroup *group; // For the group commands.
11673 global_struct &g = *::g; // Reduces code size due to replacing so many g-> with g. Eclipsing ::g with local g makes compiler remind/enforce the use of the right one.
11674 ToggleValueType toggle; // For commands that use on/off/neutral.
11675
11676 // Even though the loading-parser already checked, check again, for now,
11677 // at least until testing raises confidence. UPDATE: Don't do this because
11678 // sometimes the number of parameters required at load-time is different from
11679 // that at runtime, because params are taken out or added to the param list:
11680 //if (nArgs < g_act[mActionType].MinParams) ...
11681
11682 switch (mActionType)
11683 {
11684 case ACT_SEND:
11685 case ACT_SENDTEXT:
11686 SendKeys(ARG1, mActionType == ACT_SENDTEXT ? SCM_RAW_TEXT : SCM_NOT_RAW, g.SendMode);
11687 return OK;
11688 case ACT_SENDINPUT: // Raw mode is supported via {Raw} in ARG1.
11689 SendKeys(ARG1, SCM_NOT_RAW, g.SendMode == SM_INPUT_FALLBACK_TO_PLAY ? SM_INPUT_FALLBACK_TO_PLAY : SM_INPUT);
11690 return OK;
11691 case ACT_SENDPLAY: // Raw mode is supported via {Raw} in ARG1.
11692 SendKeys(ARG1, SCM_NOT_RAW, SM_PLAY);
11693 return OK;
11694 case ACT_SENDEVENT:
11695 SendKeys(ARG1, SCM_NOT_RAW, SM_EVENT);
11696 return OK;
11697
11698 case ACT_CLICK:
11699 if (mArgc > 1)
11700 {
11701 // Join all args so that Click(x,y) is equivalent to Click %x% %y%. Anything longer than
11702 // _countof(buf_temp) is almost certainly invalid, so simply truncate in that case.
11703 *buf_temp = '\0';
11704 for (int i = 0; i < mArgc; ++i)
11705 sntprintfcat(buf_temp, _countof(buf_temp), _T("%s,"), sArgDeref[i]);
11706 return PerformClick(buf_temp);
11707 }
11708 return PerformClick(ARG1);
11709 case ACT_MOUSECLICKDRAG:
11710 return PerformMouse(mActionType, SEVEN_ARGS);
11711 case ACT_MOUSECLICK:
11712 return PerformMouse(mActionType, THREE_ARGS, _T(""), _T(""), ARG5, ARG7, ARG4, ARG6);
11713 case ACT_MOUSEMOVE:
11714 return PerformMouse(mActionType, _T(""), ARG1, ARG2, _T(""), _T(""), ARG3, ARG4);
11715
11716 case ACT_DOWNLOAD:
11717 return Download(TWO_ARGS);
11718
11719 case ACT_RUNAS:
11720 StringTCharToWChar(ARG1, g_script.mRunAsUser);
11721 StringTCharToWChar(ARG2, g_script.mRunAsPass);
11722 StringTCharToWChar(ARG3, g_script.mRunAsDomain);

Callers 1

BIF_DECLFunction · 0.80

Calls 15

SendKeysFunction · 0.85
sntprintfcatFunction · 0.85
PerformClickFunction · 0.85
PerformMouseFunction · 0.85
ctoupperFunction · 0.85
SetWorkingDirFunction · 0.85
ATOIFunction · 0.85
SetKeyHistoryMaxFunction · 0.85
ShowMainWindowFunction · 0.85
ResultToBOOLFunction · 0.85
MsgSleepFunction · 0.85
Util_ShutdownFunction · 0.85

Tested by

no test coverage detected