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

Method Invoke

source/input_object.cpp:75–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73
74
75ResultType InputObject::Invoke(ResultToken &aResultToken, int aID, int aFlags, ExprTokenType *aParam[], int aParamCount)
76{
77 switch (aID)
78 {
79 case M_Start:
80 if (input.InProgress())
81 return OK;
82 input.Buffer[input.BufferLength = 0] = '\0';
83 return InputStart(input);
84
85 case M_Wait:
86 DWORD wait_ms, tick_start;
87 wait_ms = ParamIndexIsOmitted(0) ? UINT_MAX : (UINT)(ParamIndexToDouble(0) * 1000);
88 tick_start = GetTickCount();
89 while (input.InProgress() && (GetTickCount() - tick_start) < wait_ms)
90 MsgSleep();
91 // Return EndReason:
92 case P_EndReason:
93 _o_return(input.GetEndReason(NULL, 0));
94
95 case M_Stop:
96 if (input.InProgress())
97 input.Stop();
98 return OK;
99
100 case P_Input:
101 _o_return(input.Buffer, input.BufferLength);
102
103 case P_InProgress:
104 _o_return(input.InProgress());
105
106 case P_EndKey:
107 aResultToken.symbol = SYM_STRING;
108 if (input.Status == INPUT_TERMINATED_BY_ENDKEY)
109 input.GetEndReason(aResultToken.marker = _f_retval_buf, _f_retval_buf_size);
110 else
111 aResultToken.marker = _T("");
112 return OK;
113
114 case P_EndMods:
115 {
116 aResultToken.symbol = SYM_STRING;
117 TCHAR *cp = aResultToken.marker = aResultToken.buf;
118 const auto mod_string = MODLR_STRING;
119 for (int i = 0; i < 8; ++i)
120 if (input.EndingMods & (1 << i))
121 {
122 *cp++ = mod_string[i * 2];
123 *cp++ = mod_string[i * 2 + 1];
124 }
125 *cp = '\0';
126 return OK;
127 }
128
129 case P_Match:
130 aResultToken.symbol = SYM_STRING;
131 if (input.Status == INPUT_TERMINATED_BY_MATCH && input.EndingMatchIndex < input.MatchCount)
132 aResultToken.marker = input.match[input.EndingMatchIndex];

Callers

nothing calls this directly

Calls 6

InputStartFunction · 0.85
MsgSleepFunction · 0.85
InProgressMethod · 0.80
GetEndReasonMethod · 0.80
StopMethod · 0.80
SetTimeoutTimerMethod · 0.80

Tested by

no test coverage detected