FileForums

FileForums (https://fileforums.com/index.php)
-   PC Games - CD/DVD Conversions (https://fileforums.com/forumdisplay.php?f=39)
-   -   Progress bar for Tasks (https://fileforums.com/showthread.php?t=94294)

danswano 07-03-2013 15:02

Progress bar for Tasks
 
Hello, is it possible to show a progress bar for tasks/install action?

Note: i don't want the actual percentage of the operation, i just want a simple progress bar, let's say i have 4 tasks (like DX9 and VC++).
I want a progress bar to move 25% for each task of the four tasks until it's done.

Thanks you :)

altef_4 07-03-2013 23:57

Code:

[Setup]
AppName=Example
AppVerName=Example
DefaultDirName={pf}\Example
OutputDir=.
OutputBaseFilename=Example

[Tasks]
Name: VCCheck; Description: Установить Microsoft Visual C++ 2005 Redist
Name: PhysXCheck; Description: Установить Nvidia PhysX

[Run]
Filename: {src}\Redist\vcredist_x86.exe; Parameters: /q; StatusMsg: Устанавливаем Microsoft Visual C++ 2005 Redist...; Flags: waituntilterminated; Tasks: VCCheck; Check: SetPBPos
Filename: {src}\Redist\PhysX.exe; Parameters: /qn; StatusMsg: Устанавливаем Nvidia PhysX...; Flags: waituntilterminated; Tasks: PhysXCheck; Check: SetPBPos

[_Code]
function SetPBPos:boolean;
begin
  if (WizardForm.ProgressGauge.Max > 100) then WizardForm.ProgressGauge.Max:=100;
  if (WizardForm.ProgressGauge.Position = 100) then WizardForm.ProgressGauge.Position:=0;
  WizardForm.ProgressGauge.Position:=WizardForm.ProgressGauge.Position + 50;
  result:= true;
end;


Grumpy 08-03-2013 00:09

Quote:

Originally Posted by altef_4 (Post 414989)
Code:

[Setup]
AppName=Example
AppVerName=Example
DefaultDirName={pf}\Example
OutputDir=.
OutputBaseFilename=Example

[Tasks]
Name: VCCheck; Description: Install Microsoft Visual C++ 2005 Redist
Name: PhysXCheck; Description: Install Nvidia PhysX

[Run]
Filename: {src}\Redist\vcredist_x86.exe; Parameters: /q; StatusMsg: Installing Microsoft Visual C++ 2005 Redist...; Flags: waituntilterminated; Tasks: VCCheck; Check: SetPBPos
Filename: {src}\Redist\PhysX.exe; Parameters: /qn; StatusMsg: Installing Nvidia PhysX...; Flags: waituntilterminated; Tasks: PhysXCheck; Check: SetPBPos

[_Code]
function SetPBPos:boolean;
begin
  if (WizardForm.ProgressGauge.Max > 100) then WizardForm.ProgressGauge.Max:=100;
  if (WizardForm.ProgressGauge.Position = 100) then WizardForm.ProgressGauge.Position:=0;
  WizardForm.ProgressGauge.Position:=WizardForm.ProgressGauge.Position + 50;
  result:= true;
end;


Thanks 'altef_4' just be wary of the 'Russian' words though .... I think my red edits are correct. Feel free to correct me if I am wrong. ;)

altef_4 08-03-2013 00:21

Quote:

Originally Posted by Grumpy (Post 414990)
Thanks 'altef_4' just be wary of the 'Russian' words though .... I think my red edits are correct. Feel free to correct me if I am wrong. ;)

in English this words means 'install' and 'installing', and it's just example, you can edit what you want.

danswano 08-03-2013 05:24

The code didn't work for me, i want the progress bar to appear here if you got me wrong:
http://i48.tinypic.com/29ding5.jpg

pakrat2k2 08-03-2013 05:27

check the switches /q , /qn see if thats the problem

danswano 08-03-2013 05:30

The switch of DX9 is /silent
the switch of VC++ is /q

is that wrong?

altef_4 08-03-2013 05:31

What script do you use? Give example or full script.

danswano 08-03-2013 05:36

It's the original russian ISDone 0.6 final.
Quote:

;#define NeedSize "5000000000"
#define NeedMem 512
#define SecondProgressBar
;#define Components
;#define records
;#define facompress
;#define PrecompInside
#define SrepInside
;#define MSCInside
;#define precomp "0.40"
;#define unrar
;#define XDelta
;#define PackZIP

[Setup]
AppName=APPLICATION
AppVerName=1.0.0
DefaultDirName={pf}\APPLICATION
DefaultGroupName=APPLICATION
OutputDir=.
OutputBaseFilename=setup
VersionInfoCopyright=PR
SolidCompression=yes
#ifdef NeedSize
ExtraDiskSpaceRequired={#NeedSize}
#endif

#ifdef Components
[Types]
Name: full; Description: Full installation; Flags: iscustom

[Components]
#endif

[Registry]

[Icons]
Name: {commondesktop}\APPLICATION; Filename: {app}\APPLICATION.EXE; WorkingDir: {app}; Check: CheckError;

[Tasks]
Name: "DX9"; Description: "Install DirectX 9";
Name: "VC2005"; Description: "Install Visual C++ 2005 Redistributable";

[Run]
Tasks: DX9; Filename: "{src}\DirectX 9\DXSETUP.exe"; Parameters: /silent; StatusMsg: "Installing DirectX 9.."; Flags: SkipIfDoesntExist;
Tasks: VC2005; Filename: "{src}\Visual C++ 2005 Redistributable\vcredist_x86.exe"; Parameters: /q; StatusMsg: "Installing Visual C++ 2005 Redistributable.."; Flags: SkipIfDoesntExist;

[Files]
Source: Include\English.ini; DestDir: {tmp}; Flags: dontcopy
Source: Include\unarc.dll; DestDir: {tmp}; Flags: dontcopy
Source: ISDone.dll; DestDir: {tmp}; Flags: dontcopy
#ifdef records
Source: records.inf; DestDir: {tmp}; Flags: dontcopy
#endif

#ifdef PrecompInside
Source: Include\CLS-precomp.dll; DestDir: {tmp}; Flags: dontcopy
Source: Include\packjpg_dll.dll; DestDir: {tmp}; Flags: dontcopy
Source: Include\packjpg_dll1.dll; DestDir: {tmp}; Flags: dontcopy
Source: Include\precomp.exe; DestDir: {tmp}; Flags: dontcopy
Source: Include\zlib1.dll; DestDir: {tmp}; Flags: dontcopy
#endif
#ifdef SrepInside
Source: Include\CLS-srep.dll; DestDir: {tmp}; Flags: dontcopy
#endif
#ifdef MSCInside
Source: Include\CLS-MSC.dll; DestDir: {tmp}; Flags: dontcopy
#endif
#ifdef facompress
Source: Include\facompress.dll; DestDir: {tmp}; Flags: dontcopy
#endif
#ifdef precomp
#if precomp == "0.38"
Source: Include\precomp038.exe; DestDir: {tmp}; Flags: dontcopy
#else
#if precomp == "0.4"
Source: Include\precomp040.exe; DestDir: {tmp}; Flags: dontcopy
#else
#if precomp == "0.41"
Source: Include\precomp041.exe; DestDir: {tmp}; Flags: dontcopy
#else
#if precomp == "0.42"
Source: Include\precomp042.exe; DestDir: {tmp}; Flags: dontcopy
#else
Source: Include\precomp038.exe; DestDir: {tmp}; Flags: dontcopy
Source: Include\precomp040.exe; DestDir: {tmp}; Flags: dontcopy
Source: Include\precomp041.exe; DestDir: {tmp}; Flags: dontcopy
Source: Include\precomp042.exe; DestDir: {tmp}; Flags: dontcopy
#endif
#endif
#endif
#endif
#endif
#ifdef unrar
Source: Include\Unrar.dll; DestDir: {tmp}; Flags: dontcopy
#endif
#ifdef XDelta
Source: Include\XDelta3.dll; DestDir: {tmp}; Flags: dontcopy
#endif
#ifdef PackZIP
Source: Include\7z.dll; DestDir: {tmp}; Flags: dontcopy
Source: Include\packZIP.exe; DestDir: {tmp}; Flags: dontcopy
#endif
Source: Include\precomp04.exe; DestDir: {tmp}; Flags: dontcopy;

[CustomMessages]
ExtractedFile=Installing:
Extracted=Installing...
CancelButton=Cancel
Error=Error!
ElapsedTime=Elapsed Time:
RemainingTime=Remaining Time:
EstimatedTime=Estimated Time:
AllElapsedTime=All Elapsed Time:



[Languages]

[UninstallDelete]
Type: filesandordirs; Name: {app}

[Code]
const
PCFonFLY=true;
notPCFonFLY=false;
var
LabelPct1,LabelCurrFileName,LabelTime1,LabelTime2, LabelTime3: TLabel;
ISDoneProgressBar1: TNewProgressBar;
#ifdef SecondProgressBar
LabelPct2: TLabel;
ISDoneProgressBar2:TNewProgressBar;
#endif
MyCancelButton: TButton;
ISDoneCancel:integer;
ISDoneError:boolean;
PCFVer:double;

type
TCallback = function (OveralPct,CurrentPct: integer;CurrentFile,TimeStr1,TimeStr2,TimeStr3:PAn siChar): longword;

function WrapCallback(callback:TCallback; paramcount:integer):longword;external 'wrapcallback@files:ISDone.dll stdcall delayload';

function ISArcExtract(CurComponent:Cardinal; PctOfTotal:double; InName, OutPath, ExtractedPath: AnsiString; DeleteInFile:boolean; Password, CfgFile, WorkPath: AnsiString; ExtractPCF: boolean ):boolean; external 'ISArcExtract@files:ISDone.dll stdcall delayload';
function IS7ZipExtract(CurComponent:Cardinal; PctOfTotal:double; InName, OutPath: AnsiString; DeleteInFile:boolean; Password: AnsiString):boolean; external 'IS7zipExtract@files:ISDone.dll stdcall delayload';
function ISRarExtract(CurComponent:Cardinal; PctOfTotal:double; InName, OutPath: AnsiString; DeleteInFile:boolean; Password: AnsiString):boolean; external 'ISRarExtract@files:ISDone.dll stdcall delayload';
function ISPrecompExtract(CurComponent:Cardinal; PctOfTotal:double; InName, OutFile: AnsiString; DeleteInFile:boolean):boolean; external 'ISPrecompExtract@files:ISDone.dll stdcall delayload';
function ISSRepExtract(CurComponent:Cardinal; PctOfTotal:double; InName, OutFile: AnsiString; DeleteInFile:boolean):boolean; external 'ISSrepExtract@files:ISDone.dll stdcall delayload';
function ISxDeltaExtract(CurComponent:Cardinal; PctOfTotal:double; minRAM,maxRAM:integer; InName, DiffFile, OutFile: AnsiString; DeleteInFile, DeleteDiffFile:boolean):boolean; external 'ISxDeltaExtract@files:ISDone.dll stdcall delayload';
function ISPackZIP(CurComponent:Cardinal; PctOfTotal:double; InName, OutFile: AnsiString;ComprLvl:integer; DeleteInFile:boolean):boolean; external 'ISPackZIP@files:ISDone.dll stdcall delayload';
function ShowChangeDiskWindow(Text, DefaultPath, SearchFile:AnsiString):boolean; external 'ShowChangeDiskWindow@files:ISDone.dll stdcall delayload';

function Exec2 (FileName, Param: PAnsiChar;Show:boolean):boolean; external 'Exec2@files:ISDone.dll stdcall delayload';
function ISFindFiles(CurComponent:Cardinal; FileMask:AnsiString; var ColFiles:integer):integer; external 'ISFindFiles@files:ISDone.dll stdcall delayload';
function ISPickFilename(FindHandle:integer; OutPath:AnsiString; var CurIndex:integer; DeleteInFile:boolean):boolean; external 'ISPickFilename@files:ISDone.dll stdcall delayload';
function ISGetName(TypeStr:integer):PAnsichar; external 'ISGetName@files:ISDone.dll stdcall delayload';
function ISFindFree(FindHandle:integer):boolean; external 'ISFindFree@files:ISDone.dll stdcall delayload';
function ISExec(CurComponent:Cardinal; PctOfTotal,SpecifiedProcessTime:double; ExeName,Parameters,TargetDir,OutputStr:AnsiString; Show:boolean):boolean; external 'ISExec@files:ISDone.dll stdcall delayload';

function SrepInit(TmpPath:PAnsiChar;VirtMem,MaxSave:Cardina l):boolean; external 'SrepInit@files:ISDone.dll stdcall delayload';
function PrecompInit(TmpPath:PAnsiChar;VirtMem:cardinal;Pre compVers:single):boolean; external 'PrecompInit@files:ISDone.dll stdcall delayload';
function FileSearchInit(RecursiveSubDir:boolean):boolean; external 'FileSearchInit@files:ISDone.dll stdcall delayload';
function ISDoneInit(RecordFileName:AnsiString; TimeType,Comp1,Comp2,Comp3:Cardinal; WinHandle, NeededMem:longint; callback:TCallback):boolean; external 'ISDoneInit@files:ISDone.dll stdcall';
function ISDoneStop:boolean; external 'ISDoneStop@files:ISDone.dll stdcall';
function ChangeLanguage(Language:AnsiString):boolean; external 'ChangeLanguage@files:ISDone.dll stdcall delayload';
function SuspendProc:boolean; external 'SuspendProc@files:ISDone.dll stdcall';
function ResumeProc:boolean; external 'ResumeProc@files:ISDone.dll stdcall';

function ProgressCallback(OveralPct,CurrentPct: integer;CurrentFile,TimeStr1,TimeStr2,TimeStr3:PAn siChar): longword;
begin
if OveralPct<=1000 then ISDoneProgressBar1.Position := OveralPct;
LabelPct1.Caption := IntToStr(OveralPct div 10)+'.'+chr(48 + OveralPct mod 10)+'%';
#ifdef SecondProgressBar
if CurrentPct<=1000 then ISDoneProgressBar2.Position := CurrentPct;
LabelPct2.Caption := IntToStr(CurrentPct div 10)+'.'+chr(48 + CurrentPct mod 10)+'%';
#endif
LabelCurrFileName.Caption:=ExpandConstant('{cm:Ext ractedFile} ')+MinimizePathName(CurrentFile, LabelCurrFileName.Font, LabelCurrFileName.Width-ScaleX(100));
LabelTime1.Caption:=ExpandConstant('{cm:ElapsedTim e} ')+TimeStr2;
LabelTime2.Caption:=ExpandConstant('{cm:RemainingT ime} ')+TimeStr1;
LabelTime3.Caption:=ExpandConstant('{cm:AllElapsed Time}')+TimeStr3;
Result := ISDoneCancel;
end;

procedure CancelButtonOnClick(Sender: TObject);
begin
SuspendProc;
if MsgBox(SetupMessage(msgExitSetupMessage), mbConfirmation, MB_YESNO) = IDYES then ISDoneCancel:=1;
ResumeProc;
end;

procedure HideControls;
begin
WizardForm.FileNamelabel.Hide;
ISDoneProgressBar1.Hide;
LabelPct1.Hide;
LabelCurrFileName.Hide;
LabelTime1.Hide;
LabelTime2.Hide;
MyCancelButton.Hide;
#ifdef SecondProgressBar
ISDoneProgressBar2.Hide;
LabelPct2.Hide;
#endif
end;

procedure CreateControls;
var PBTop:integer;
begin
PBTop:=ScaleY(50);
ISDoneProgressBar1 := TNewProgressBar.Create(WizardForm);
with ISDoneProgressBar1 do begin
Parent := WizardForm.InstallingPage;
Height := WizardForm.ProgressGauge.Height;
Left := ScaleX(0);
Top := PBTop;
Width := ScaleX(365);
Max := 1000;
end;
LabelPct1 := TLabel.Create(WizardForm);
with LabelPct1 do begin
Parent := WizardForm.InstallingPage;
AutoSize := False;
Left := ISDoneProgressBar1.Width+ScaleX(5);
Top := ISDoneProgressBar1.Top + ScaleY(2);
Width := ScaleX(80);
end;
LabelCurrFileName := TLabel.Create(WizardForm);
with LabelCurrFileName do begin
Parent := WizardForm.InstallingPage;
AutoSize := False;
Width := ISDoneProgressBar1.Width+ScaleX(30);
Left := ScaleX(0);
Top := ScaleY(30);
end;
#ifdef SecondProgressBar
PBTop:=PBTop+ScaleY(25);
ISDoneProgressBar2 := TNewProgressBar.Create(WizardForm);
with ISDoneProgressBar2 do begin
Parent := WizardForm.InstallingPage;
Left := ScaleX(0);
Top := PBTop+ScaleY(8);
Width := ISDoneProgressBar1.Width;
Max := 1000;
Height := WizardForm.ProgressGauge.Height;
end;
LabelPct2 := TLabel.Create(WizardForm);
with LabelPct2 do begin
Parent := WizardForm.InstallingPage;
AutoSize := False;
Left := ISDoneProgressBar2.Width+ScaleX(5);
Top := ISDoneProgressBar2.Top + ScaleY(2);
Width := ScaleX(80);
end;
#endif
LabelTime1 := TLabel.Create(WizardForm);
with LabelTime1 do begin
Parent := WizardForm.InstallingPage;
AutoSize := False;
Width := ISDoneProgressBar1.Width div 2;
Left := ScaleX(0);
Top := PBTop + ScaleY(35);
end;
LabelTime2 := TLabel.Create(WizardForm);
with LabelTime2 do begin
Parent := WizardForm.InstallingPage;
AutoSize := False;
Width := LabelTime1.Width+ScaleX(40);
Left := ISDoneProgressBar1.Width div 2;
Top := LabelTime1.Top;
end;
LabelTime3 := TLabel.Create(WizardForm);
with LabelTime3 do begin
Parent := WizardForm.FinishedPage;
AutoSize := False;
Width := 300;
Left := 180;
Top := 200;
end;
MyCancelButton:=TButton.Create(WizardForm);
with MyCancelButton do begin
Parent:=WizardForm;
Width:=ScaleX(135);
Caption:=ExpandConstant('{cm:CancelButton}');
Left:=ScaleX(360);
Top:=WizardForm.cancelbutton.top;
OnClick:=@CancelButtonOnClick;
end;
end;

Procedure CurPageChanged(CurPageID: Integer);
Begin
if (CurPageID = wpFinished) and ISDoneError then
begin
LabelTime3.Hide;
WizardForm.Caption:= ExpandConstant('{cm:Error}');
WizardForm.FinishedLabel.Font.Color:= clRed;
WizardForm.FinishedLabel.Caption:= SetupMessage(msgSetupAborted) ;
end;
end;

function CheckError:boolean;
begin
result:= not ISDoneError;
end;

procedure CurStepChanged(CurStep: TSetupStep);
var Comps1,Comps2,Comps3, TmpValue:cardinal;
FindHandle1,ColFiles1,CurIndex1,tmp:integer;
ExecError:boolean;
InFilePath,OutFilePath,OutFileName:PAnsiChar;
begin
if CurStep = ssInstall then begin
WizardForm.ProgressGauge.Hide;
WizardForm.CancelButton.Hide;
CreateControls;
WizardForm.StatusLabel.Caption:=ExpandConstant('{c m:Extracted}');
ISDoneCancel:=0;

ExtractTemporaryFile('unarc.dll');

#ifdef PrecompInside
ExtractTemporaryFile('CLS-precomp.dll');
ExtractTemporaryFile('packjpg_dll.dll');
ExtractTemporaryFile('packjpg_dll1.dll');
ExtractTemporaryFile('precomp.exe');
ExtractTemporaryFile('zlib1.dll');
#endif
#ifdef SrepInside
ExtractTemporaryFile('CLS-srep.dll');
#endif
#ifdef MSCInside
ExtractTemporaryFile('CLS-MSC.dll');
#endif
#ifdef facompress
ExtractTemporaryFile('facompress.dll');
#endif
#ifdef records
ExtractTemporaryFile('records.inf');
#endif
#ifdef precomp
#if precomp == "0.38"
ExtractTemporaryFile('precomp038.exe');
#else
#if precomp == "0.40"
ExtractTemporaryFile('precomp040.exe');
#else
#if precomp == "0.41"
ExtractTemporaryFile('precomp041.exe');
#else
#if precomp == "0.42"
ExtractTemporaryFile('precomp042.exe');
#else
ExtractTemporaryFile('precomp038.exe');
ExtractTemporaryFile('precomp040.exe');
ExtractTemporaryFile('precomp041.exe');
ExtractTemporaryFile('precomp042.exe');
#endif
#endif
#endif
#endif
#endif
#ifdef unrar
ExtractTemporaryFile('Unrar.dll');
#endif
#ifdef XDelta
ExtractTemporaryFile('XDelta3.dll');
#endif
#ifdef PackZIP
ExtractTemporaryFile('7z.dll');
ExtractTemporaryFile('PackZIP.exe');
#endif

ExtractTemporaryFile('English.ini');

Comps1:=0; Comps2:=0; Comps3:=0;
#ifdef Components
TmpValue:=1;
if IsComponentSelected('text\rus') then Comps1:=Comps1+TmpValue;
TmpValue:=TmpValue*2;
if IsComponentSelected('text\eng') then Comps1:=Comps1+TmpValue;
TmpValue:=TmpValue*2;
if IsComponentSelected('voice\rus') then Comps1:=Comps1+TmpValue;
TmpValue:=TmpValue*2;
if IsComponentSelected('voice\eng') then Comps1:=Comps1+TmpValue;
#endif

#ifdef precomp
PCFVer:={#precomp};
#else
PCFVer:=0;
#endif
ISDoneError:=true;
if ISDoneInit(ExpandConstant('{src}\records.inf'), $F777, Comps1,Comps2,Comps3, MainForm.Handle, {#NeedMem}, @ProgressCallback) then begin
repeat
ChangeLanguage('English');
if not SrepInit('',512,0) then break;
if not FileSearchInit(true) then break;

if not ISArcExtract ( 0, 100ExpandConstant('{src}\data.arc'), ExpandConstant('{app}\'), '', false, 'zxc123', ExpandConstant('{tmp}\arc.ini'), ExpandConstant('{app}\'), notPCFonFLY{PCFonFLY}) then break;

FindHandle1:=ISFindFiles(0,ExpandConstant('{app}\* .ogg'),ColFiles1);
ExecError:=false;
while not ExecError and ISPickFilename(FindHandle1,ExpandConstant('{app}\' ),CurIndex1,true) do begin
InFilePath:=ISGetName(0);
OutFilePath:=ISGetName(1);
OutFileName:=ISGetName(2);
ExecError:=not ISExec(0, 0, 0, ExpandConstant('{tmp}\oggdec.exe'), '"'+InFilePath+'" -w "'+OutFilePath+'"',ExpandConstant('{tmp}'),OutFile Name,false);
end;
ISFindFree(FindHandle1);
if ExecError then break;

ISDoneError:=false;
until true;
ISDoneStop;
end;
HideControls;
WizardForm.CancelButton.Visible:=true;
WizardForm.CancelButton.Enabled:=false;
end;
if (CurStep=ssPostInstall) and ISDoneError then begin
Exec2(ExpandConstant('{uninstallexe}'), '/VERYSILENT', false);
end;
end;

altef_4 08-03-2013 06:28

look hare

danswano 08-03-2013 08:41

Thank you altef, can i make the progress bar percent dynamic?
if i have 2 tasks then this code should be:
Quote:

WizardForm.ProgressGauge.Position:=WizardForm.Prog ressGauge.Position +50;
and if i have 4 tasks the code should be:
Quote:

WizardForm.ProgressGauge.Position:=WizardForm.Prog ressGauge.Position +25;
is there any thing could be added to the code so it calculate the percentage dynamicly based on the number of the tasks?

altef_4 08-03-2013 11:41

Modified script with automatic check selected tasks and dynamicly changes position of progress bar depending on selected tasks number.
UPD: added showing installing progress in win7 taskbar click me

danswano 08-03-2013 14:11

I got this error:
Quote:

Compile Error!
Line: 314
Error: Column 34:
Unknown identifier 'ITEMCOUNT'

pakrat2k2 08-03-2013 14:22

http://fileforums.com/showpost.php?p...&postcount=234 link is there for enhanced version

danswano 08-03-2013 14:32

I have a small issue that there is no green progress bar at the windows task bar, is there a patched version of ISDone to enable it?


All times are GMT -7. The time now is 19:47.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
FileForums @ https://fileforums.com