| 242 | } |
| 243 | |
| 244 | TStatus 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 | |
| 290 | void WorkerImplement::ProcessOurHotKey(Message_Hotkey&& keyData) { |
| 291 |
no test coverage detected