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

Function DetermineTargetControl

source/script2.cpp:9037–9067  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9035
9036
9037ResultType DetermineTargetControl(HWND &aControl, HWND &aWindow, ResultToken &aResultToken, ExprTokenType *aParam[], int aParamCount
9038 , int aNonWinParamCount, bool aThrowIfNotFound)
9039{
9040 aWindow = aControl = nullptr;
9041 // Only functions which can operate on top-level windows allow Control to be
9042 // omitted (and a select few other functions with more optional parameters).
9043 // This replaces the old "ahk_parent" string used with ControlSend, but is
9044 // also used by SendMessage.
9045 LPTSTR control_spec = nullptr;
9046 if (!ParamIndexIsOmitted(0))
9047 {
9048 switch (DetermineTargetHwnd(aWindow, aResultToken, *aParam[0]))
9049 {
9050 case OK:
9051 aControl = aWindow;
9052 if (!aControl)
9053 return aResultToken.Error(ERR_NO_CONTROL, ErrorPrototype::Target);
9054 return OK;
9055 case FAIL:
9056 return FAIL;
9057 }
9058 // Since above didn't return, it wasn't a pure Integer or object {Hwnd}.
9059 control_spec = ParamIndexToString(0, _f_number_buf);
9060 }
9061 if (!DetermineTargetWindow(aWindow, aResultToken, aParam + 1, aParamCount - 1, aNonWinParamCount))
9062 return FAIL;
9063 aControl = control_spec ? ControlExist(aWindow, control_spec) : aWindow;
9064 if (!aControl && aThrowIfNotFound)
9065 return aResultToken.Error(ERR_NO_CONTROL, ErrorPrototype::Target);
9066 return OK;
9067}
9068
9069
9070

Callers 1

BIF_DECLFunction · 0.85

Calls 4

DetermineTargetHwndFunction · 0.85
DetermineTargetWindowFunction · 0.85
ControlExistFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected