diff --git a/README.RU.md b/README.RU.md new file mode 100644 index 0000000..1cfadfe --- /dev/null +++ b/README.RU.md @@ -0,0 +1,20 @@ +[![EN](https://user-images.githubusercontent.com/9499881/33184537-7be87e86-d096-11e7-89bb-f3286f752bc6.png)](https://github.com/r57zone/DelayStarter/) +[![RU](https://user-images.githubusercontent.com/9499881/27683795-5b0fbac6-5cd8-11e7-929c-057833e01fb1.png)](https://github.com/r57zone/DelayStarter/blob/master/README.RU.md) + +# DelayStarter +Приложение для запуска других программ после подключения к интернету. Если после запуска Windows интернета отсуствует некоторое время, то можно приложение отложит автозапуск программ, отобразит обратный таймер и запустит их после обнаружения интернет-соединения. + +## Настройка +1. Добавьте полные пути необходимых приложения в файл `Apps.txt`. +2. Добавьте ярлык приложения в автозапуск Windows `%AppData%\Microsoft\Windows\Start Menu\Programs\Startup`. +3. Примерное время задано в файле `Setup.ini`, в милисекундах, оно может записаться автоматически если изменить параметр `FirstRun` на `1`. + +## Скриншоты +![](https://github.com/user-attachments/assets/cee6911c-ce54-4889-af96-5e21daf070c3) + +## Загрузка +>Версия для Windows XP, 7, 8.1, 10, 11.
+**[Загрузить](https://github.com/r57zone/DelayStarter/releases)** + +## Обратная связь +`r57zone[собака]gmail.com` \ No newline at end of file diff --git a/README.md b/README.md index b71a2e2..517b049 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,21 @@ +[![EN](https://user-images.githubusercontent.com/9499881/33184537-7be87e86-d096-11e7-89bb-f3286f752bc6.png)](https://github.com/r57zone/DelayStarter/) +[![RU](https://user-images.githubusercontent.com/9499881/27683795-5b0fbac6-5cd8-11e7-929c-057833e01fb1.png)](https://github.com/r57zone/DelayStarter/blob/master/README.RU.md) +← Choose language | Выберите язык + # DelayStarter -Launching applications aftжений после подключения к интернетуer connecting to the Internet / Запуск прило +Application to start other programs after an internet connection. If there is no internet connection for some time after Windows starts, you can use this application to postpone autorun of programs, display a reverse timer and start them after internet connection is detected. + +## Setup +1. Add the full paths of the required applications to the `Apps.txt` file. +2. Add the application shortcut to the Windows autorun `%AppData%\Microsoft\Windows\Start Menu\Programs\Startup`. +3. The approximate time is set in the `Setup.ini` file, in milliseconds, it can be recorded automatically if you change the `FirstRun` parameter to `1`. + +## Screenshots +![](https://github.com/user-attachments/assets/4caab111-b33c-4ba5-ba1f-4f17c83eee3b) + +## Download +>Version for Windows XP, 7, 8.1, 10, 11.
+**[Download](https://github.com/r57zone/DelayStarter/releases)** + +## Feedback +`r57zone[at]gmail.com` \ No newline at end of file diff --git a/Source/Apps.txt b/Source/Apps.txt new file mode 100644 index 0000000..e69de29 diff --git a/Source/Project1.cfg b/Source/Project1.cfg new file mode 100644 index 0000000..a6a081c --- /dev/null +++ b/Source/Project1.cfg @@ -0,0 +1,38 @@ +-$A8 +-$B- +-$C+ +-$D+ +-$E- +-$F- +-$G+ +-$H+ +-$I+ +-$J- +-$K- +-$L+ +-$M- +-$N+ +-$O+ +-$P+ +-$Q- +-$R- +-$S- +-$T- +-$U- +-$V+ +-$W- +-$X+ +-$YD +-$Z1 +-cg +-AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; +-H+ +-W+ +-M +-$M16384,1048576 +-K$00400000 +-LE"c:\programs\borland\delphi7\Projects\Bpl" +-LN"c:\programs\borland\delphi7\Projects\Bpl" +-w-UNSAFE_TYPE +-w-UNSAFE_CODE +-w-UNSAFE_CAST diff --git a/Source/Project1.dof b/Source/Project1.dof new file mode 100644 index 0000000..c7d17ca --- /dev/null +++ b/Source/Project1.dof @@ -0,0 +1,136 @@ +[FileVersion] +Version=7.0 +[Compiler] +A=8 +B=0 +C=1 +D=1 +E=0 +F=0 +G=1 +H=1 +I=1 +J=0 +K=0 +L=1 +M=0 +N=1 +O=1 +P=1 +Q=0 +R=0 +S=0 +T=0 +U=0 +V=1 +W=0 +X=1 +Y=1 +Z=1 +ShowHints=1 +ShowWarnings=1 +UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; +NamespacePrefix= +SymbolDeprecated=1 +SymbolLibrary=1 +SymbolPlatform=1 +UnitLibrary=1 +UnitPlatform=1 +UnitDeprecated=1 +HResultCompat=1 +HidingMember=1 +HiddenVirtual=1 +Garbage=1 +BoundsError=1 +ZeroNilCompat=1 +StringConstTruncated=1 +ForLoopVarVarPar=1 +TypedConstVarPar=1 +AsgToTypedConst=1 +CaseLabelRange=1 +ForVariable=1 +ConstructingAbstract=1 +ComparisonFalse=1 +ComparisonTrue=1 +ComparingSignedUnsigned=1 +CombiningSignedUnsigned=1 +UnsupportedConstruct=1 +FileOpen=1 +FileOpenUnitSrc=1 +BadGlobalSymbol=1 +DuplicateConstructorDestructor=1 +InvalidDirective=1 +PackageNoLink=1 +PackageThreadVar=1 +ImplicitImport=1 +HPPEMITIgnored=1 +NoRetVal=1 +UseBeforeDef=1 +ForLoopVarUndef=1 +UnitNameMismatch=1 +NoCFGFileFound=1 +MessageDirective=1 +ImplicitVariants=1 +UnicodeToLocale=1 +LocaleToUnicode=1 +ImagebaseMultiple=1 +SuspiciousTypecast=1 +PrivatePropAccessor=1 +UnsafeType=0 +UnsafeCode=0 +UnsafeCast=0 +[Linker] +MapFile=0 +OutputObjs=0 +ConsoleApp=1 +DebugInfo=0 +RemoteSymbols=0 +MinStackSize=16384 +MaxStackSize=1048576 +ImageBase=4194304 +ExeDescription= +[Directories] +OutputDir= +UnitOutputDir= +PackageDLLOutputDir= +PackageDCPOutputDir= +SearchPath= +Packages=vcl;rtl;vclx;indy;inet;xmlrtl;vclie;inetdbbde;inetdbxpress;dbrtl;dsnap;dsnapcon;vcldb;soaprtl;VclSmp;dbexpress;dbxcds;inetdb;bdertl;vcldbx;webdsnap;websnap;adortl;ibxpress;teeui;teedb;tee;dss;visualclx;visualdbclx;vclactnband;vclshlctrls;IntrawebDB_50_70;Intraweb_50_70;Rave50CLX;Rave50VCL;dclOfficeXP;Rz30Ctls70;Rz30DBCtls70 +Conditionals= +DebugSourceDirs= +UsePackages=0 +[Parameters] +RunParams= +HostApplication= +Launcher= +UseLauncher=0 +DebugCWD= +[Language] +ActiveLang= +ProjectLang= +RootDir= +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= diff --git a/Source/Project1.dpr b/Source/Project1.dpr new file mode 100644 index 0000000..d160129 --- /dev/null +++ b/Source/Project1.dpr @@ -0,0 +1,13 @@ +program Project1; + +uses + Forms, + Unit1 in 'Unit1.pas' {Main}; + +{$R *.res} + +begin + Application.Initialize; + Application.CreateForm(TMain, Main); + Application.Run; +end. diff --git a/Source/Project1.res b/Source/Project1.res new file mode 100644 index 0000000..3f51719 Binary files /dev/null and b/Source/Project1.res differ diff --git a/Source/Setup.ini b/Source/Setup.ini new file mode 100644 index 0000000..56a752d --- /dev/null +++ b/Source/Setup.ini @@ -0,0 +1,3 @@ +[Main] +FirstRun=1 +LaunchTime=0 diff --git a/Source/Unit1.ddp b/Source/Unit1.ddp new file mode 100644 index 0000000..4370276 Binary files /dev/null and b/Source/Unit1.ddp differ diff --git a/Source/Unit1.dfm b/Source/Unit1.dfm new file mode 100644 index 0000000..cf918b7 --- /dev/null +++ b/Source/Unit1.dfm @@ -0,0 +1,45 @@ +object Main: TMain + Left = 192 + Top = 125 + BorderIcons = [biSystemMenu] + BorderStyle = bsSingle + Caption = 'DelayStarter' + ClientHeight = 67 + ClientWidth = 346 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'MS Sans Serif' + Font.Style = [] + OldCreateOrder = False + Position = poScreenCenter + OnClose = FormClose + OnCreate = FormCreate + PixelsPerInch = 96 + TextHeight = 13 + object Panel: TPanel + Left = 0 + Top = 0 + Width = 346 + Height = 67 + Align = alClient + BevelOuter = bvNone + Font.Charset = RUSSIAN_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + TabOrder = 0 + object TextLbl: TLabel + Left = 0 + Top = 10 + Width = 346 + Height = 43 + Alignment = taCenter + AutoSize = False + Caption = #1046#1076#1105#1084' '#1087#1086#1076#1082#1083#1102#1095#1077#1085#1080#1103' '#1080#1085#1090#1077#1088#1085#1077#1090'-'#1089#1086#1077#1076#1080#1085#1077#1085#1080#1103'...'#13#1055#1088#1080#1084#1077#1088#1085#1086' '#1086#1089#1090#1072#1083#1086#1089#1100': 0:00' + end + end +end diff --git a/Source/Unit1.pas b/Source/Unit1.pas new file mode 100644 index 0000000..4c95c0c --- /dev/null +++ b/Source/Unit1.pas @@ -0,0 +1,208 @@ +unit Unit1; + +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, WinInet, StdCtrls, ExtCtrls, ShellAPI, IniFiles, ComCtrls; + +type + TMain = class(TForm) + Panel: TPanel; + TextLbl: TLabel; + procedure FormCreate(Sender: TObject); + procedure FormClose(Sender: TObject; var Action: TCloseAction); + private + procedure ThreadTerminate(Sender: TObject); + { Private declarations } + public + { Public declarations } + end; + + TMyThread = class(TThread) + private + { Private declarations } + procedure UpdateUI; + protected + procedure Execute; override; + end; + +var + Main: TMain; + MyThread: TMyThread; + AppsList: TStringList; + FirstRun: boolean; + StartTime, LaunchTime: int64; + + IDS_WAITING_INTERNET_CONNECTION, IDS_REMAINING_TIME: string; + +implementation + +{$R *.dfm} + +function HTTPGet(URL: string): string; +var + hSession, hUrl: HINTERNET; + Buffer: array [1..8192] of Byte; + dwFlags, BufferLen: DWORD; + StrStream: TStringStream; +begin + Result:=''; + hSession:=InternetOpen('Mozilla/4.0 (MSIE 6.0; Windows NT 5.1)', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0); + if Assigned(hSession) then begin + + if Copy(LowerCase(URL), 1, 8) = 'https://' then + dwFlags:=INTERNET_FLAG_SECURE + else + dwFlags:=INTERNET_FLAG_RELOAD; + + hUrl:=InternetOpenUrl(hSession, PChar(URL), nil, 0, dwFlags, 0); + if Assigned(hUrl) then begin + StrStream:=TStringStream.Create(''); + try + repeat + FillChar(Buffer, SizeOf(Buffer), 0); + BufferLen:=0; + if InternetReadFile(hURL, @Buffer, SizeOf(Buffer), BufferLen) then + StrStream.WriteBuffer(Buffer, BufferLen) + else + Break; + Application.ProcessMessages; + until BufferLen = 0; + Result:=StrStream.DataString; + except + Result:=''; + end; + StrStream.Free; + + InternetCloseHandle(hUrl); + end; + + InternetCloseHandle(hSession); + end; +end; + +procedure TMain.ThreadTerminate(Sender: TObject); +begin + //MyThread.Free; // + MyThread:=nil; + PostMessage(Handle, WM_CLOSE, 0, 0); +end; + +function GetLocaleInformation(Flag: integer): string; +var + pcLCA: array [0..20] of Char; +begin + if GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, Flag, pcLCA, 19) <= 0 then + pcLCA[0]:=#0; + Result:=pcLCA; +end; + +procedure TMain.FormCreate(Sender: TObject); +var + Ini: TIniFile; +begin + StartTime:=GetTickCount; + + Ini:=TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'Setup.ini'); + FirstRun:=Ini.ReadBool('Main', 'FirstRun', False); + LaunchTime:=Ini.ReadInteger('Main', 'LaunchTime', 0); + Ini.Free; + + AppsList:=TStringList.Create; + if FileExists(ExtractFilePath(ParamStr(0)) + 'Apps.txt') then + AppsList.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'Apps.txt'); + MyThread:=TMyThread.Create(False); + MyThread.Priority:=tpNormal; + MyThread.OnTerminate:=ThreadTerminate; + + Application.Title:=Caption; + if GetLocaleInformation(LOCALE_SENGLANGUAGE) <> 'Russian' then begin + IDS_WAITING_INTERNET_CONNECTION:='Waiting for internet connection...'; + IDS_REMAINING_TIME:='Remaining time: '; + end else begin + IDS_WAITING_INTERNET_CONNECTION:=' -...'; + IDS_REMAINING_TIME:=' : '; + end; + TextLbl.Caption:=IDS_WAITING_INTERNET_CONNECTION + #13#10 + IDS_REMAINING_TIME + '0:00'; +end; + +procedure TMain.FormClose(Sender: TObject; var Action: TCloseAction); +begin + AppsList.Free; + if Assigned(MyThread) then + begin + MyThread.Terminate; + MyThread.WaitFor; + MyThread.Free; + MyThread:=nil; + end; +end; + +function MsToMinSec(Ms: int64): string; +var + Minutes, Seconds: Integer; +begin + Seconds:=Ms div 1000; + Minutes:=Seconds div 60; + Seconds:=Seconds mod 60; + Result:=Format('%d:%2.2d', [Minutes, Seconds]); +end; + +procedure TMyThread.UpdateUI; +var + RemainingTime: int64; +begin + RemainingTime:=LaunchTime - (GetTickCount - StartTime); + if RemainingTime < 0 then RemainingTime:=0; + + Main.TextLbl.Caption:=IDS_WAITING_INTERNET_CONNECTION + #13#10 + IDS_REMAINING_TIME + MsToMinSec(RemainingTime); +end; + +procedure TMyThread.Execute; +var + Ini: TIniFile; + AppPath, AppParams: string; + i, DelimPos: integer; +begin + while not Terminated do begin + Synchronize(UpdateUI); + + if HTTPGet('http://www.msftconnecttest.com/connecttest.txt') = 'Microsoft Connect Test' then begin + + if FirstRun then begin + Ini:=TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'Setup.ini'); + Ini.WriteBool('Main', 'FirstRun', False); + Ini.WriteInteger('Main', 'LaunchTime', GetTickCount - StartTime); + Ini.Free; + end; + + for i:=0 to AppsList.Count - 1 do begin + + if Trim(AppsList.Strings[i]) = '' then Continue; + if Trim(AppsList.Strings[i])[1] = '#' then Continue; + + DelimPos:=Pos('|', AppsList.Strings[i]); + + if DelimPos > 0 then begin + AppPath:=Copy(AppsList.Strings[i], 1, DelimPos - 1); + AppParams:=Copy(AppsList.Strings[i], DelimPos + 1, Length(AppsList.Strings[i]) - DelimPos); + end else begin + AppPath:=AppsList.Strings[i]; + AppParams:=''; + end; + + if not FileExists(AppsList.Strings[i]) then Continue; + + ShellExecute(0, 'open', PChar(AppPath), PChar(AppParams), nil, SW_SHOWNORMAL); + + end; + + Terminate; + end; + + Sleep(1000); + end; +end; + +end. diff --git a/Source/clear.bat b/Source/clear.bat new file mode 100644 index 0000000..d46ff98 --- /dev/null +++ b/Source/clear.bat @@ -0,0 +1,9 @@ +del *.obj +del *.dcu +del *.~* +del *.hpp +del *.dcp +del *.dpl +del *.cesettings +del *.bak +--del *.exe* \ No newline at end of file