JoosTy
(Fresh Scripter)
2005-12-01 12:01 PM
Loginscript with progressbar

Hi All..

I want to add a Progressbar to my Loginscript.

Can You explane it in this exemple:

Code:

Break On Cls ;- Remove CLS if using WKIX32
$nul=SetConsole("Hide") ;- Hide console when script is done



;------------------------Function
$FuncToExecute=Split("fnScrFunc1,fnScrFunc2,fnScrFunc3,fnScrFunc4,fnScrFunc5,fnScrFunc6",",")




;-------------------------Installing Kixform
$frmRoot = CreateObject("Kixtart.Form")
If @ERROR
$nul=SetConsole("Show")
"KiXforms.dll not installed/registered" ?
Exit(1)
EndIf




;-------------------------Making Form
$frmMain = CreateObject("Kixtart.Form")
$frmMain.Size = 560,410
$frmMain.SysMenu = 0
$frmMain.Text = "YooowWW"
$frmMain.BackColor = 114, 125, 157
$frmMain.Center

$picture = $frmMain.controls.Picturebox ("", 25, 25, 499, 340)
$picture.picture = "esj.bmp"
$picture.BorderStyle = 0


;----------------------------Tekst functie
$ProgressTextBox = $picture.Label
$ProgressTextBox.BackColor = 187, 192, 213
$ProgressTextBox.bounds = 10, 220, 480, 20
$ProgressTextBox.forecolor = 255, 255, 255
$ProgressTextBox.fontsize = 12
$ProgressTextBox.fontbold = true
$ProgressTextBox.FontName = Tahoma
$ProgressTextBox.TextAlign = MiddleCenter



;-------------------------Script functies uitvoeren
$frmMain.Show
;$prgStatus.Max = Ubound($FuncToExecute)+1
For Each $sFunction in $FuncToExecute
;$prgStatus.Value = $prgStatus.Value+1
$nul=Execute($sFunction)
Sleep 1
Next
Exit()

;-------------------------Functies





Function fnScrFunc1()
$ProgressTextBox.text = "Mapping Network Drives"
SLEEP 1
EndFunction

Function fnScrFunc2()
$ProgressTextBox.text = "Change This Computer Name"
SLEEP 1
EndFunction

Function fnScrFunc3()
$ProgressTextBox.text = "Change Network Drive Icons"
SLEEP 1
EndFunction

Function fnScrFunc4()
$ProgressTextBox.text = "Set the correct domain time"
SETTIME "\\SSC01"
EndFunction

Function fnScrFunc5()
$ProgressTextBox.text = "Set some internet favorites"
SLEEP 1
EndFunction

Function fnScrFunc6()
$ProgressTextBox.text = "Logonscript complete. Thank you."
Sleep 1
EndFunction




Can he skip When a Function is completed?

Greets JoosTy


ChristopheM
(Hey THIS is FUN)
2005-12-01 05:24 PM
Re: Loginscript with progressbar

the line
Code:
$FuncToExecute=Split("fnScrFunc1,fnScrFunc2,fnScrFunc3,fnScrFunc4,fnScrFunc5,fnScrFunc6",",")

initializes an array that contains the list of functions to be called.


in the loop
Code:
For Each $sFunction ... next  


each function defined in the array is called sequentially. But there is a mistake in the code.
Code:
;$prgStatus.Max = Ubound($FuncToExecute)+1
For Each $sFunction in $FuncToExecute
;$prgStatus.Value = $prgStatus.Value+1
$nul=Execute($sFunction)
Next


the two commented lines should be uncommented because they are implementing the progressbar !!!


ashwin
(Lurker)
2006-03-05 12:22 AM
Re: Loginscript with progressbar

I have tested this script.
Now I just only want to add a messagebox at the end.
The problem now is that the messagebox doen't appear on the screen.
It is essential for the script that it contains the message.

How to solve this???


Benny69
(MM club member)
2006-03-05 03:45 AM
Re: Loginscript with progressbar

didn't we discuss this over here?
http://www.kixforms.org/forum/viewtopic.php?t=1096


Gargoyle
(MM club member)
2006-03-05 06:17 AM
Re: Loginscript with progressbar

In the script above there is no messagebox commands.

If you want one just add it like so

Code:

Next
$nul = MessageBox("Insert your Text Here","Notice",64)
Exit()

Les
(KiX Master)
2006-03-05 07:03 AM
Re: Loginscript with progressbar

Exit is not a function
Is that a KiX MessageBox() in a KF script?


Gargoyle
(MM club member)
2006-03-05 07:10 AM
Re: Loginscript with progressbar

Quote:

Exit is not a function
Is that a KiX MessageBox() in a KF script?




Ok that is what I get for cut and paste....
And yea that would be a KiX on top of a KF script. My bad, but it would still work.....


ashwin
(Lurker)
2006-03-05 09:38 AM
Re: Loginscript with progressbar

Quote:

In the script above there is no messagebox commands.

If you want one just add it like so

Code:

Next
$nul = MessageBox("Insert your Text Here","Notice",64)
Exit()




This seems ok, but when I execute this, I still don't see any messagebox.

I've tried running in debug mode. It appears the whole $nul = MessageBox("Insert your Text Here","Notice",64) is skipped.

I guess you cannot add MessageBox() in a kixform.

Btw. I have solved the whole problem by using a batch file. in the batchfile i refer to login.kix and afterwars to logix2.kix

login.kix is the script with progressbar and login2.kix contains code to create the messagebox.

Thanks for the idea though.


Gargoyle
(MM club member)
2006-03-05 09:52 AM
Re: Loginscript with progressbar

Did you insert the messagebox command between your next and your exit. Or did you just copy and paste the whole thing into your script? I geuss I was not very specific as to how to do it.

I use messagebox along with KF with no problems.


Les
(KiX Master)
2006-03-05 03:06 PM
Re: Loginscript with progressbar

Quote:

Ok that is what I get for cut and paste....
And yea that would be a KiX on top of a KF script. My bad, but it would still work.....



Hmmm... cut and paste gives me an error.

The form should be redesigned to use the KiXforms built-ins to display whatever message on the main form before the progress bar starts. That way users can read the message while waiting for the script to complete.


ashwin
(Lurker)
2006-03-05 10:51 PM
Re: Loginscript with progressbar

Quote:

Did you insert the messagebox command between your next and your exit. Or did you just copy and paste the whole thing into your script? I geuss I was not very specific as to how to do it.

I use messagebox along with KF with no problems.




Yes I have used cut and paste, and still the same




Quote:

Quote:

Ok that is what I get for cut and paste....
And yea that would be a KiX on top of a KF script. My bad, but it would still work.....



Hmmm... cut and paste gives me an error.

The form should be redesigned to use the KiXforms built-ins to display whatever message on the main form before the progress bar starts. That way users can read the message while waiting for the script to complete.





After quite bit of testing I I've come to the following result:

Code:

Break On CLS ;- Remove CLS if using WKIX32
$nul=SetConsole("Hide") ;- Hide console when script is done

;------------------------Function
$FuncToExecute=Split("fnScrFunc1,fnScrFunc2,fnScrFunc3,fnScrFunc4,fnScrFunc5,fnScrFunc6",",")

$System = CreateObject("Kixtart.System")
If Not $System
$= MessageBox("KiXforms Not Initiated. This Script Will Now Close.","Error",16)
Quit()
EndIf

;-------------------------Making Form
$Root = $System.Form()
$frmMain = $System.Form($Root)
$frmMain.TopMost = "True"
$frmMain.Size = 560,410
$frmMain.SysMenu = 1
$frmMain.Text = "Logging in..."
$frmMain.BackColor = 114, 125, 157

$picture = $frmMain.controls.Picturebox ("", 25, 25, 499, 340)
$picture.picture = "esj.bmp"
$picture.BorderStyle = 0

;----------------------------Tekst functie
$ProgressTextBox = $picture.Label
$ProgressTextBox.BackColor = 187, 192, 213
$ProgressTextBox.bounds = 10, 220, 480, 20
$ProgressTextBox.forecolor = 255, 255, 255
$ProgressTextBox.fontsize = 12
$ProgressTextBox.fontbold = true
$ProgressTextBox.FontName = Tahoma
$ProgressTextBox.TextAlign = MiddleCenter

$ProgressBar = $picture.ProgressBar()
$ProgressBar.Left = $ProgressTextBox.Left
$ProgressBar.Top = $ProgressTextBox.Bottom + 10
$ProgressBar.Width = $ProgressTextBox.Width
$ProgressBar.Height = $ProgressTextBox.Height

$ProgressTextBox1 = $picture.Label
$ProgressTextBox1.BackColor = 187, 192, 213
$ProgressTextBox1.bounds = 10, 20, 480, 100
;$ProgressTextBox1.forecolor = 255, 255, 255
;$ProgressTextBox1.fontsize = 12
;$ProgressTextBox1.fontbold = true
;$ProgressTextBox1.FontName = Tahoma
;$ProgressTextBox1.TextAlign = MiddleCenter

;-------------------------Script functies uitvoeren
$frmMain.Center
$frmMain.Show
;$prgStatus.Max = Ubound($FuncToExecute)+1
For Each $sFunction in $FuncToExecute
;$prgStatus.Value = $prgStatus.Value+1
$nul=Execute($sFunction)
Sleep 1
Next
Exit()

;-------------------------Functies

Function fnScrFunc1()
$ProgressTextBox.text = "Your message"
$ProgressBar.Value = $ProgressBar.Value + 16
Sleep 1
EndFunction

Function fnScrFunc2()
$ProgressTextBox.text = "Change This Computer Name"
$ProgressBar.Value = $ProgressBar.Value + 16
Sleep 1
EndFunction

Function fnScrFunc3()
$ProgressTextBox.text = "Change Network Drive Icons"
$ProgressBar.Value = $ProgressBar.Value + 16
Sleep 1
EndFunction

Function fnScrFunc4()
$ProgressTextBox.text = "Set the correct domain time"
$ProgressBar.Value = $ProgressBar.Value + 16
SetTime "\\SSC01"
EndFunction

Function fnScrFunc5()
$ProgressTextBox.text = "Set some internet favorites"
$ProgressBar.Value = $ProgressBar.Value + 16
Sleep 1
EndFunction

Function fnScrFunc6()
$ProgressTextBox.text = "Logonscript complete. Thank you."
$ProgressBar.Value = 100
Sleep 1.5
EndFunction

Next
$nul = MessageBox("Test_message","Test_title",64)
Exit()



I've added:

$ProgressTextBox1 = $picture.Label
$ProgressTextBox1.BackColor = 187, 192, 213
$ProgressTextBox1.bounds = 10, 20, 480, 100
;$ProgressTextBox1.forecolor = 255, 255, 255
;$ProgressTextBox1.fontsize = 12
;$ProgressTextBox1.fontbold = true
;$ProgressTextBox1.FontName = Tahoma
;$ProgressTextBox1.TextAlign = MiddleCenter

The last five are unimportant

and added

Code:
$ProgressTextBox1.text = "your text"


within Function fnScrFunc1()

Now you'll see your message above the login bar.


Gargoyle
(MM club member)
2006-03-05 11:17 PM
Re: Loginscript with progressbar

Nope that is not what I meant at all. See code snippet below
Code:

$frmMain.Center
$frmMain.Show
;$prgStatus.Max = Ubound($FuncToExecute)+1
For Each $sFunction in $FuncToExecute
;$prgStatus.Value = $prgStatus.Value+1
$nul=Execute($sFunction)
Sleep 1
Next
;Insert here
$nul = MessageBox("Test_message","Test_title",64)
Exit()



Or go with what works for you


ashwin
(Lurker)
2006-03-05 11:47 PM
Re: Loginscript with progressbar

Thx that work fine now.

Although now I don't have to use this anymore, since I use the form to show my message. I think some other guys I know will appreciate this