MCPcopy Create free account
hub / github.com/Aegel5/SimpleSwitcher / RunProcess

Method RunProcess

src/WorkerImplement.cpp:244–288  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

242}
243
244TStatus WorkerImplement::RunProcess(HotKeyType hk, bool after_wait) {
245
246 GETCONF;
247
248 int i = hk;
249 ResetFlag(i, hk_RunProgram_flag);
250 if (i >= cfg->run_programs.size()) {
251 return SW_ERR_UNKNOWN;
252 }
253 const auto& it = cfg->run_programs[i];
254
255 if (!it.enabled) {
256 RETURN_SUCCESS;
257 }
258
259 if (it.delay > 0 && !after_wait) {
260 Worker()->PostMsg([hk](auto p) {p->RunProcess(hk, true); }, it.delay);
261 RETURN_SUCCESS;
262 }
263
264 if (it.type == CommandType::Snippet) {
265 ProcessSnippet(it.cmd);
266 RETURN_SUCCESS;
267 }
268
269 auto wpath = StrUtils::Convert(it.cmd);
270 auto wargs = StrUtils::Convert(it.args);
271
272 PathUtils::NormalizeDelims(wpath);
273
274 LOG_ANY(L"run program {} {}", wpath.c_str(), wargs.c_str());
275
276 procstart::CreateProcessParm parm;
277 parm.sExe = wpath.c_str();
278 parm.sCmd = wargs.c_str();
279
280 // todo - use proxy process for unelevated.
281 //parm.admin = it.elevated ? TSWAdmin::SW_ADMIN_ON : TSWAdmin::SW_ADMIN_OFF;
282
283 parm.mode = procstart::SW_CREATEPROC_SHELLEXE;
284 CAutoHandle hProc;
285 IFS_RET(procstart::SwCreateProcess(parm, hProc));
286
287 RETURN_SUCCESS;
288}
289
290void WorkerImplement::ProcessOurHotKey(Message_Hotkey&& keyData) {
291

Callers 1

Draw_run_tabMethod · 0.80

Calls 9

ResetFlagFunction · 0.85
WorkerFunction · 0.85
ProcessSnippetFunction · 0.85
NormalizeDelimsFunction · 0.85
SwCreateProcessFunction · 0.85
c_strMethod · 0.80
ConvertFunction · 0.50
sizeMethod · 0.45
PostMsgMethod · 0.45

Tested by

no test coverage detected