PDA

View Full Version : Progress Bar for file.runs?



Solmos
11-18-2006, 07:00 AM
function Run_CB(Source,Run,Total)
local npgress = ((Run/Total) * 100);
Progress.SetCurrentPos("Progress1", npgress);
return true;
end

Progress.SetCurrentPos("Progress1", 0);
Progress.SetText("Progress1", "");
Progress.SetEnabled("Progress1", true);
Progress.SetVisible("Progress1", true);

aa = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "SOFTWARE\\User\\Program\\1");
if aa == true then
Label.SetVisible("Label2", true);
File.Run("AutoPlay\\Docs\\Program\\1.exe", "/s", "", SW_SHOWNORMAL, true, Run_CB);
Label.SetVisible("Label2", false);
end

aaa = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "SOFTWARE\\User\\Program\\2");
if aaa == true then
Label.SetVisible("Label2", true);
File.Run("AutoPlay\\Docs\\Program\\2.exe", "/s", "", SW_SHOWNORMAL, true, Run_CB);
Label.SetVisible("Label2", false);
end

Progress.SetVisible("Progress1", true);
Progress.SetCurrentPos("Progress1", 0);
Progress.SetText("Progress1", "");

Not work :rolleyes :rolleyes

solution please?!? or other example please!!

and added text %? ej: 1%, 2%, etc...??

thx

Solmos
11-18-2006, 03:24 PM
please help!!!

thx!!!:rolleyes :rolleyes

Tek
11-18-2006, 04:53 PM
I don't think the File.Run action has a callback function.

usernameCasper
11-19-2006, 09:12 AM
Hey guys,

as the File.Run has no return value, it isnt possible to set current position, cause u dont know the amount of time when its ready to run.
So you are not able to put text in the progressbar refered to the non existing return value.
You could put text by refering the time your system will use to show that file (run and show). You must remember not all systems open the same amount of time comparing to eachother. So if you system takes 5 seconds to show that file, u can set for every second 20% in your progressbar.

-Kind Regards,
Casper

Solmos
11-19-2006, 01:28 PM
Hey guys,

as the File.Run has no return value, it isnt possible to set current position, cause u dont know the amount of time when its ready to run.
So you are not able to put text in the progressbar refered to the non existing return value.
You could put text by refering the time your system will use to show that file (run and show). You must remember not all systems open the same amount of time comparing to eachother. So if you system takes 5 seconds to show that file, u can set for every second 20% in your progressbar.

-Kind Regards,
Casper

one example please!!?

thx

usernameCasper
11-20-2006, 02:40 AM
there are 2 simple ways to do this:
First is to give your button the following statement: Page.StartTimer(500);
Go to the page where the progressbar is set, then go to the scriptscreen of that page, go to the tab On Timer.
Here you can put in your preferences. The interval for Refresh the page is set to 0,5 seconds.
Than use the Progress statements.
getProgressCurrentPosition, etc.
For filling in text into the progesbar based on position, you can use this:


percentComplete = ((currentPos - range.Begin) / (range.End - range.Begin)) * 100;
Progress.SetText("MyProgressBar", percentComplete .. "%");

Remember that the page refreshtime is 0,5 seconds.
So its handy to use this in mind, currentPos = currentPos + 10;
this will use the currentPosition of the progressbar (0) plus 10 for the first refresh. second will be: 10 + 10 = 20 (position of range).
I refere you to use the statements in Progress. for the avaible settings, such as SetPos,GetPos,SetRange,SetText, etc.
And dont forget to stop the timer when it reach 100%, so when it reach you last SetRange of you progressbar !! You dont want to set it in a loop and see the text in your progressbar after 1 hour !! :)
So use the if-else statement.

Or use the Progress.StepSize and Progress.StepIt statement :)

Hope this will help you out :)

Kind Regards,
Casper

usernameCasper
11-20-2006, 03:36 AM
If some1 have a better idea, post them please :)
A program who is already builded, like *.exe files, most time they wont give you a value (a value to a third partity program) but maybe the value is builded in the exe itself.
Or you decompile it, thats illegal !! So forget get value from exe (in most cases). As I work for the goverment, I can advise you dont try or search for decompilers.

Sincerely,
Casper

Solmos
11-20-2006, 05:34 AM
First, pardon by my English, but is that I do not speak English.


Thank you very much by the answer yet to usernameCasper, can put to me an example complete scrip that it would have to put (I am very inexperienced with the Autoplay).

Ah! another thing, I tapeworm another idea, but not if it is possible to be done. The idea is that whenever is finished installing an application, the percentage raises, for example if I have selected that settles 3 applications, when finishing installing first that the progress bar shows a 33%, when it finishes installing second, that shows a 66% etc…

But this also tendria that to be applied in but cases, like for example if I select 20 applications… when finishing installing first mostrar� a 5%, etc…

thank you very much by its aid!

(the translated text this by means of google)

usernameCasper
11-20-2006, 05:53 AM
Hey Solmos :)
Glad to help you !
ghehe i like the google translations, its not that bad ;)
I prefer this one: http://www.worldlingo.com/en/products_services/worldlingo_translator.html
most languages are displayed :)
If im home, i can give you the code, its hard to give you the code from out of my head, as im pretty new to the language from AMS :)

For putting text on progressbar after closing an application you installed is very simple.
Use the File-statement, i think its File.Open or File.Run, give the File-statement a "name" (cause it gains a returnvalue) and set the last attribute, a boolean to true, this will give the "name" a value giving you the possibility to set other functions.
Like this: If "name.boolean = true" then
'performAction' etc. Progress.SetText("progressbar","33%");
else if name1.boolean = true; then ...... etc.
By installing 3 apps in a row, meaning 3 apps will automatically installed you can use macro's / scripting from C++. I don't know if AMS supports this, but Borland C++ does, I think its best for you, you start with AMS. If you are more experienced try other languages as u wish, but AMS owns many languages as i can say :):yes

Good luck with coding :)
-Casper

Solmos
11-20-2006, 06:01 AM
Thanks again for its aid, but it can put scrip to me complete? (I not to become scrips…)

In which it comments to put the text, serious single if 3 programs settled, but and if I select 20 programs? everything in he himself scrip.

thanks

usernameCasper
11-20-2006, 06:18 AM
Hey Solmos,

If you use more, than you can set the number of files to be done.
the range of you progressbar is 200 for example.
so 200/20 = 10 steps for each file.
its very easy !
try coding / scripting with the statements in my previous posts, only try and you will learn what these attributes do. If you dont know why its not working or giving errors, post them and i will help you out ! :)

Sincerely,
Casper

Solmos
11-20-2006, 06:29 AM
thanks but I am very lost,

as I begin scrip?

usernameCasper
11-20-2006, 07:08 AM
Use the helpfile in AMS regularly and you can code within 10 days !
Hope this will work for beginning scripting, or just read the manual they provided ! :)

Solmos
11-20-2006, 07:57 AM
Progress.SetCurrentPos("Progress1", 0);
Progress.SetEnabled("Progress1", true);
Progress.SetVisible("Progress1", true);
Progress.SetText("Progress1","0%");

aa = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "SOFTWARE\\user\\1");
if aa == true then
File.Run("AutoPlay\\Docs\\Programs\\1.exe", "/s", "", SW_SHOWNORMAL, true);
end
Progress.SetText("Progress1","33%");
Progress.SetCurrentPos("Progress1", 33);

aaa = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "SOFTWARE\\user\\2");
if aaa == true then
File.Run("AutoPlay\\Docs\\Programs\\2.exe", "/s","", SW_SHOWNORMAL, true);
end
Progress.SetText("Progress1","66%");
Progress.SetCurrentPos("Progress1", 66);

etc

Progress.SetVisible("Progress1", true);
Progress.SetCurrentPos("Progress1", 100);
Progress.SetText("Progress1", "100%");

As I can put that it marks “%” according to I number of selected programs?

for example, if I select 5… when installing first that it shows 20%, when installing second 40%, etc

But I select 30 programs… that when installing first it shows 3%,etc…

please, help me to do scrip

thanks

usernameCasper
11-20-2006, 08:04 AM
it could be like that, but why making more code as it can done with less code?
Example, what i posted be4 in this post:



percentComplete = ((currentPos - range.Begin) / (range.End - range.Begin)) * 100;
Progress.SetText("MyProgressBar", percentComplete .. "%");

Solmos
11-20-2006, 08:14 AM
percentComplete = ((currentPos - range.Begin) / (range.End - range.Begin)) * 100;
Progress.SetText("MyProgressBar", percentComplete .. "%");

aa = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "SOFTWARE\\user\\1");
if aa == true then
File.Run("AutoPlay\\Docs\\Programs\\1.exe", "/s", "", SW_SHOWNORMAL, true);
end

aaa = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "SOFTWARE\\user\\2");
if aaa == true then
File.Run("AutoPlay\\Docs\\Programs\\2.exe", "/s","", SW_SHOWNORMAL, true);
end

¿¿??

not work?

usernameCasper
11-20-2006, 09:13 AM
¿?
U didnt init the variables ...

Solmos
11-20-2006, 10:03 AM
variables??

Please one example please!!!!!!!!!!!!!!!!!!!!!

usernameCasper
11-20-2006, 01:55 PM
Ok, im home.
Paste this code into your app:

On Click (Button):


function startPageTimer1()
Page.StartTimer(250)
givePermission1 = true;
end

startPageTimer1();


On Timer (Page properties):


if givePermission1 == true then
--Aangeroepen door function startPageTimer1(),givePermission1 / called by function startPageTimer1(),givePermission1
Progress.SetRange("Progress1",0,120);
currentPos = Progress.GetCurrentPos("Progress1");
if currentPos < 119 then
Progress.SetCurrentPos("Progress1", currentPos + 10);
nCurrentPos = Progress.GetCurrentPos("Progress1");
tRange = Progress.GetRange("Progress1");
nPercentComplete = ((nCurrentPos - tRange.Begin) / (tRange.End - tRange.Begin)) * 100;
nPercentCompleteAfgerond = Math.Floor(nPercentComplete);
Progress.SetText("Progress1", nPercentCompleteAfgerond .. "%");
else
Page.StopTimer();
end
end

----------------


It can be done by at least 3 methods, I like this 1, its more secure and guarantees for no errorvalues.
This will work, post it if this is what you want.

Kind Regards,
Casper

Solmos
11-20-2006, 02:25 PM
thank you very much!

But it has a problem, and it is that it arrives at the 100% before finishing installing the first selected program...

On Click (Button Install):


function startPageTimer1()
Page.StartTimer(250)
givePermission1 = true;
end

startPageTimer1();



On Timer (Page properties):


if givePermission1 == true then
--Aangeroepen door function startPageTimer1(),givePermission1 / called by function startPageTimer1(),givePermission1
Progress.SetRange("Progress1",0,120);
currentPos = Progress.GetCurrentPos("Progress1");
if currentPos < 119 then
Progress.SetCurrentPos("Progress1", currentPos + 10);
nCurrentPos = Progress.GetCurrentPos("Progress1");
tRange = Progress.GetRange("Progress1");
nPercentComplete = ((nCurrentPos - tRange.Begin) / (tRange.End - tRange.Begin)) * 100;
nPercentCompleteAfgerond = Math.Floor(nPercentComplete);
Progress.SetText("Progress1", nPercentCompleteAfgerond .. "%");
else
Page.StopTimer();
end
end

On Show


aa = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "SOFTWARE\\user\\1");
if aa == true then
File.Run("AutoPlay\\Docs\\Programs\\1.exe", "/s", "", SW_SHOWNORMAL, true);
end

aaa = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "SOFTWARE\\user\\2");
if aaa == true then
File.Run("AutoPlay\\Docs\\Programs\\2.exe", "/s","", SW_SHOWNORMAL, true);
end

usernameCasper
11-20-2006, 03:00 PM
no problem :):yes
Cause this is a timebased setText statement.
You can adjust the Page.StartTimer(2000) to set the update to perform actions in On Timer to 2 seconds for example.
Or just setText to "33%" for each returned value for installing an app ;)
Good luck !

Greets,
Casper

usernameCasper
11-21-2006, 02:10 AM
in the above code, you also can add



function startStopTimer1()
Page.StopTimer()
givePermission1 = false;
end


than at the following code, replace Page.StopTimer() into startStopTimer1():


.............
.............
nPercentCompleteAfgerond = Math.Floor(nPercentComplete);
Progress.SetText("Progress1", nPercentCompleteAfgerond .. "%");
else
startStopTimer1();
end
end


Kind Regards,
Casper

Solmos
11-21-2006, 03:10 PM
thx usernameCasper but not work...

with this method the time of installation is simulated... is not good method, if you have another one metodo you I thank for it.

usernameCasper
11-21-2006, 04:12 PM
Uhmmsz,
IMO there are 4 ways to do it.
1) Time based setRange by waiting for value from closing first installapp
2) Time based setRange by setting currentPos for each second (not smart, as not all pc's opens or install an application the same time)
3) Get source code from that installapp, you may get it if its open source.
4) Make that installer yourself :)

If you dont want solution 1 and 2, as I think you dont want them, than there is 3 and 4 left.
Open source, source code, if you're new to coding, forgot this IMO
make an installer by yourself, same as 3 ...

Kind Regards,
Casper