MSFN Forum: AutoIt progress bar (steps) from RunOnceEx or batch - MSFN Forum

Jump to content



Unattended CD/DVD Guide Homepage · MSFN Forum Rules

Welcome to the Applications Installs forum. Make sure you read the forum rules before you start posting.

Links/Requests to warez and/or any illegal material (porn, cracks, serials, etc..) will not be tolerated. Discussion of circumventing WGA/activation/timebombs/keygens or any other illegal activity will also not be tolerated.

We try our best to keep this forum clean of illegal content. If you see any illegal activity use the "report" button you find in every post to report the specific post to the moderators. If you ignore any of the rules you will be banned without notice.

Read Forum Rules
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

AutoIt progress bar (steps) from RunOnceEx or batch Rate Topic: -----

#1 User is offline   phaolo 

  • Member
  • PipPip
  • Group: Members
  • Posts: 151
  • Joined: 12-March 07

Posted 11 July 2008 - 08:10 AM

Hello I'd like to enable a progress bar for some silent installs or tweaks.
I don't want to time it, but instead to increase the steps from the code sections (from RunOnceEx or batch files)
I thought at Autoit script, but i have some problems:

1- I don't know how to pass parameters to an active script, so I only managed to run again the same script with new parameters. Last one kills all of them.. not a very good solution.
2- ProgressOn and ProgressSet maintain the process bar window opened only if I add a sleep(ms) line. That wouldn't be a problem if only the batch file that launches the script wouldn't wait too! Where do I do wrong?



Here is the script.
It's a test and I'm not expert, so pardon my programming errors

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

If $CMDLINE[0] = 0 Then
Exit
Else
Dim $Max
Dim $Counter

$Max = $CMDLINE[1]
$Counter = $CMDLINE[2]

ProgressOn("Status","","")

ProgressSet(($Counter/$Max)*100,"","Completed " & ($Counter/$Max)*100 & "%")

; I'd like to avoid this
Sleep(2000)

If $Counter = $Max Then
Sleep(2000)
RunWait(@ComSpec & " /c " & 'taskkill /f /im actbar.exe ', "", @SW_HIDE)
Exit
EndIf
EndIf

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


Example for the file that launches the script (could be in RunOnceEx too):
actbar.exe 10 1
(...some code..)
actbar.exe 10 3
(...some code..)
actbar.exe 10 6
(...some code..)
actbar.exe 10 10

This post has been edited by phaolo: 11 July 2008 - 08:37 AM



#2 User is offline   MHz 

  • SendToA3X v1.7
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,634
  • Joined: 02-August 04

Posted 11 July 2008 - 09:30 AM

Hi phaolo,
There is no condition to keep the script running. A loop can be used to keep the script running and that is what I will use below.

Here is some minor modifications to your code that may suit your need. Comments added to explain the steps of operation.
 
If $CMDLINE[0] <> 2 Then
	; Exit if 2 parameters were not used
	Exit 1
Else
	; assign parameters to friently variable names
	Global $Max = $CMDLINE[1]
	Global $Counter = $CMDLINE[2]
	; show progress window
	ProgressOn("Status", "", "")
	; set data to progress window
	ProgressSet(($Counter / $Max) * 100, "", "Completed " & ($Counter / $Max) * 100 & "%")
	; title to use for the interpreter window title
	Global Const $AUTOIT_TITLE = @ScriptName & '_Interpreter'
	; close any previous progress windows
	If WinExists($AUTOIT_TITLE) Then
		WinClose($AUTOIT_TITLE)
		WinWaitClose($AUTOIT_TITLE)
	EndIf
	; set current window as the main interpreter window title
	AutoitWinSetTitle($AUTOIT_TITLE)
	; if max is reached, then exit
	If $Counter = $Max Then
		Sleep(2000)
		Exit
	EndIf
EndIf

; keep the current process running
While 1
	Sleep(250)
WEnd
 

It will overlap the window of the previous execution of progress to prevent a pause between progress window updating and you can change it if it causes issue.

I tested using this script and runs it from the desktop fine.
 
Run('"' & @DesktopDir & '\actbar.exe" 10 2')
Sleep(2000)
Run('"' & @DesktopDir & '\actbar.exe" 10 4')
Sleep(2000)
Run('"' & @DesktopDir & '\actbar.exe" 10 6')
Sleep(2000)
Run('"' & @DesktopDir & '\actbar.exe" 10 8')
Sleep(2000)
Run('"' & @DesktopDir & '\actbar.exe" 10 10')
 


:)

#3 User is offline   phaolo 

  • Member
  • PipPip
  • Group: Members
  • Posts: 151
  • Joined: 12-March 07

Posted 11 July 2008 - 12:46 PM

Wow the script is perfect that way, thanks! :)
Nice things the "Interpreter" and "infinite while" solutions (I couldn't understand before why that bar disappeared)


I still have the second problem though, because I'm running actbar.exe from a batch file.
I have to use it as I'm doing registry modifications and various operations. Converting all to a script would be long and full of new errors. Putting it in another script would be a poor solution (multiple files).

Anyway, with the batch the execution stops after the first script launch.
I don't know why, dos shouldn't wait for program termination normally! (only with start /wait)

What the.. ??


I'll add a batch example so you can see the problem.
(You won't reach the first pause :no: )

 
actbar.exe 10 1
pause
actbar.exe 10 3
pause
actbar.exe 10 6
pause
actbar.exe 10 10
 

This post has been edited by phaolo: 11 July 2008 - 12:57 PM


#4 User is offline   MHz 

  • SendToA3X v1.7
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,634
  • Joined: 02-August 04

Posted 11 July 2008 - 07:34 PM

View Postphaolo, on Jul 12 2008, 04:46 AM, said:

Wow the script is perfect that way, thanks! :)
Nice things the "Interpreter" and "infinite while" solutions (I couldn't understand before why that bar disappeared)

Your welcome :)

Quote

I still have the second problem though, because I'm running actbar.exe from a batch file.
I have to use it as I'm doing registry modifications and various operations. Converting all to a script would be long and full of new errors. Putting it in another script would be a poor solution (multiple files).

I am guessing the batch file is a CMD file? That is fine. No matter what type of script that you use, the method of executing Actbar.exe from that script will be basically the same.

Quote

Anyway, with the batch the execution stops after the first script launch.
I don't know why, dos shouldn't wait for program termination normally! (only with start /wait)

What the.. ??

Not AFAIK with the NT based interpreter.
  • The CMD interpreter will wait for an execution until processing the next line when a CMD script is used as to invoke the CMD interpreter initially. I notice some particular executions do return immediately as to possibly respawning a new process or some other unknown reason so using Start /wait tends to handle these more reliabily to prevent the immediate return. The default behavior allows the CMD script to complete the command on the line before progressing with the next line.
  • An execution from a CMD prompt will not wait for an execution unless you use Start /wait. The default behavior allows you to do multiple commands without waiting for the CMD prompt.

Quote

I'll add a batch example so you can see the problem.
(You won't reach the first pause :no: )

Try this CMD script
 
If $CMDLINE[0] <> 2 Then
	; Exit if 2 parameters were not used
	Exit 1
Else
	; assign parameters to friently variable names
	Global $Max = $CMDLINE[1]
	Global $Counter = $CMDLINE[2]
	; show progress window
	ProgressOn("Status", "", "")
	; set data to progress window
	ProgressSet(($Counter / $Max) * 100, "", "Completed " & ($Counter / $Max) * 100 & "%")
	; title to use for the interpreter window title
	Global Const $AUTOIT_TITLE = @ScriptName & '_Interpreter'
	; close any previous progress windows
	If WinExists($AUTOIT_TITLE) Then
		Do
			; attempt to close the previous progress window
			WinClose($AUTOIT_TITLE)
			; perform a sleep if window still exists
			If WinExists($AUTOIT_TITLE) Then
				Sleep(500)
			EndIf
			; exit the loop if the window does not exist
		Until Not WinExists($AUTOIT_TITLE)
	EndIf
	; set current window as the main interpreter window title
	AutoitWinSetTitle($AUTOIT_TITLE)
	; if max is reached, then exit
	If $Counter = $Max Then
		Sleep(2000)
		Exit
	EndIf
EndIf

; keep the current process running
While 1
	Sleep(250)
WEnd
 

I expect that you will need to use Start without the wait switch in your CMD file to execute Actbar.exe so the CMD interpreter can progress to the next line of execution which the latter is the one that you want to wait for.

#5 User is offline   phaolo 

  • Member
  • PipPip
  • Group: Members
  • Posts: 151
  • Joined: 12-March 07

Posted 12 July 2008 - 04:27 AM

No, I'm using a simple BAT. I never encountered a behaviour like that before (usually dos never waits automatically).
Anyway the "start" option works perfectly with the batch. :thumbup


Just RunOnceEx problem remains, even if it is secondary now.
It can only run files and not commands directly, so I can't add the "start" option there.
I couldn't test the script from RunOnceEx for that reason.


p.s: err, is "_interpreter" just a string, right?

This post has been edited by phaolo: 12 July 2008 - 09:06 AM


#6 User is offline   MHz 

  • SendToA3X v1.7
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,634
  • Joined: 02-August 04

Posted 12 July 2008 - 10:10 AM

View Postphaolo, on Jul 12 2008, 08:27 PM, said:

Just RunOnceEx problem remains, even if it is secondary now.
It can only run files and not commands directly, so I can't add the "start" option there.
I couldn't test the script from RunOnceEx for that reason.

Perhaps you can call the Comspec variable. Comspec contains the path to the systems default command interpreter.
"%COMSPEC%" /c Start actbar.exe 10 2

The above command can be added to registry. You may also try using a bat file from the registry and use it to start actbar.exe.

Quote

p.s: err, is "_interpreter" just a string, right?

Correct. Every AutoIt process has a hidden window and the string mentioned is used to set a part of the title for that window. If WinClose is used on that hidden window then the AutoIt process associated with that window closes.

#7 User is offline   phaolo 

  • Member
  • PipPip
  • Group: Members
  • Posts: 151
  • Joined: 12-March 07

Posted 13 July 2008 - 03:55 AM

You answered all questions in a perfect way!

Wow, I didn't know that I could pass commands to cmd.exe.. that is very useful.
Also %COMSPEC% is new for me.

Now I'll just need to correct minor things (for example a fixed 100 is better than $Max hehe)
You helped me a lot MHz, thank you very much.

:hello:


P.S: I found that the Sleep(250) loop causes the program to weight about 3Mb in memory! I've put Sleep(10000) for 300Kb only. I don't think I need small cycles because the script is always killed by the next one.

This post has been edited by phaolo: 13 July 2008 - 09:58 AM


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy