#region: - Option Opt('GUIOnEventMode', 1) Opt('MustDeclareVars', 1) Opt('TrayIconDebug', 1) Opt('TrayIconHide', 0) #endregion HotKeySet('{ESC}', '_Pro_Exit') #region: - Include #include <GUIConstantsEx.au3> #Include <Misc.au3> #include <WindowsConstants.au3> #endregion #region: - Global: Название и версия программы, ProID Global $sProName, $sProVer, $sProNameVer, $sProIDText, $sProFilePath $sProName = 'Run If No Exists' $sProVer = 'v0.1' $sProNameVer = $sProName & ' ' & $sProVer $sProIDText = $sProNameVer & ' [ID] ' & $sProNameVer $sProFilePath = StringLower(FileGetShortName(@ScriptFullPath)) #endregion #region: - Одна копия программы If _Singleton($sProIDText, 1) == 0 Then _Pro_Exit() #endregion #region: - Global Global $hWinMain FileInstall('RunIfNoExistsLauncher.exe', @TempDir & '\RunIfNoExistsLauncher.dat', 1) Global $iLauncherPID, $sLauncherProcessName, $sLauncherFilePath $sLauncherFilePath = StringLower(FileGetShortName(@TempDir & '\' & 'RunIfNoExistsLauncher.dat')) $sLauncherProcessName = StringRegExpReplace($sLauncherFilePath, '.+\\', '') #endregion ;~ MsgBox(0, '', $sProFilePath & @CRLF & $sLauncherFilePath & @CRLF & $sLauncherProcessName) ;~ Exit #region: - Главное окно $hWinMain = GUICreate($sProName, 400, 400, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, '_Pro_Exit') #endregion #region: - После создания всех GUI GUISetState(@SW_SHOW, $hWinMain) #endregion #region: - Sleep, Exit While 1 Sleep(100) _RunProcessIfNoExists() WEnd Func _Pro_Exit() HotKeySet('{ESC}') ProcessClose($iLauncherPID) ProcessWaitClose($iLauncherPID, 2000) FileDelete($sLauncherFilePath) Exit EndFunc #endregion Func _RunProcessIfNoExists() Local $i, $aProcessList If NOT FileExists($sLauncherFilePath) Then _ FileInstall('RunIfNoExistsLauncher.exe', @TempDir & '\RunIfNoExistsLauncher.dat', 1) $aProcessList = ProcessList($sLauncherProcessName) For $i = 1 To $aProcessList[0][0] If $aProcessList[$i][1] == $iLauncherPID Then Return Next $iLauncherPID = Run($sLauncherFilePath & ' /File:"' & $sProFilePath & '" /PID:"' & @AutoItPID & '"') ToolTip('PID запускателя: ' & $iLauncherPID, 10, 100); можно удалить EndFunc |