#NoTrayIcon #region: - Option Opt('MustDeclareVars', 1) Opt('TrayIconDebug', 0) Opt('TrayIconHide', 1) #endregion #region: - Include #Include <Misc.au3> #endregion #region: - Cmd Line If $CmdLine[0] > 0 AND StringInStr($CmdLineRaw, '/File:') AND StringInStr($CmdLineRaw, '/PID:') Then Global $sFilePath, $sProcessName, $iPID, $iTimeoutCheck $iTimeoutCheck = 100; ms $sFilePath = _Cmd_Read($CmdLineRaw, '/File:') $sProcessName = StringRegExpReplace(FileGetLongName($sFilePath), '.+\\', '') $iPID = _Cmd_Read($CmdLineRaw, '/PID:') If StringInStr($CmdLineRaw, '/Timeout:') Then _ $iTimeoutCheck = _Cmd_Read($CmdLineRaw, '/Timeout:') Else _Pro_Exit() EndIf #endregion #region: - Global: Название и версия программы, ProID Global $sProName, $sProVer, $sProNameVer, $sProIDText $sProName = 'Run If No Exists Launcher' $sProVer = 'v0.1' $sProNameVer = $sProName & ' ' & $sProVer $sProIDText = $sProNameVer & ' [ID] ' & $sProNameVer #endregion #region: - Одна копия программы If _Singleton($sProIDText, 1) == 0 Then ToolTip('Зпускатель уже запущенн', 10, 100+70*2); можно удалить Sleep(500); можно удалить _Pro_Exit() EndIf #endregion #region: - Sleep, Exit While 1 Sleep($iTimeoutCheck) _RunProcessIfNoExists() WEnd Func _Pro_Exit() Exit EndFunc #endregion Func _Cmd_Read($sCmdLine, $sArgument) If Not StringInStr($sCmdLine, $sArgument) Then Return '' Local $sRetCmd = StringRegExpReplace($sCmdLine, '(?i)(?s).*?' & $sArgument & '"(.*?)".*?$', '\1') If $sRetCmd = $sCmdLine Or @extended < 1 Then Return '' Return StringStripWS($sRetCmd, 3) EndFunc Func _RunProcessIfNoExists() Local $i, $aProcessList $aProcessList = ProcessList($sProcessName) For $i = 1 To $aProcessList[0][0] If $aProcessList[$i][1] == $iPID Then ToolTip('Зпускатель запущен' & @CRLF & 'Контроллируемая програама (' & $sProcessName & ') запущенна', 10, 100+70); можно удалить Return EndIf Next ToolTip('Зпускатель запущен' & @CRLF & 'Контроллируемая програама (' & $sProcessName & ') НЕ запущенна', 10, 100+70); можно удалить Exit Run($sFilePath) EndFunc |