#113567 - 2004-03-18 06:39 PM
Re: How to password protect a script?
|
1984
Starting to like KiXtart
Registered: 2003-08-14
Posts: 150
|
Sorry, Here is the code:
$=SetConsole("minimize")
Break On
;Dim $Form
$Form = CreateObject("Kixtart.FORM")
$Form.CAPTION = "Authentication for @FULLNAME"
$Form.SCALEWIDTH = 300
$Form.SCALEHEIGHT = 60
$Form.FONTSIZE = 8
$Form.FONTNAME = "Verdana"
$Form.PrintXY(15,6,"Enter authenticity Key and press Button")
$Form.CENTER
$txtpassword = $form.textbox("",15,30,100,20)
$txtpassword.passwordchar = "*"
$txtpassword.text = ""
$PSWB = $form.Button("Validate",125,30,100,20)
$PSWB.OnClick = "PasswdC()"
$Form.Show
While $Form.Visible
$=Execute($Form.DoEvents())
;Loop
Exit 1
Function PasswdC()
If $txtpassword.text = 'validate'
Dim $Form
$Form = CreateObject("Kixtart.FORM")
$Form.CAPTION = "Done!"
$Form.SCALEWIDTH = 325
$Form.SCALEHEIGHT = 30
$Form.FONTSIZE = 10
$Form.FONTNAME = "Verdana"
$Form.PrintXY(10,6,"Passwd OK")
$Form.CENTER
$Form.Show
Sleep 3
; (Somewhere here i want to jump to start of secound script)
Else Dim $Form1
$Form1 = CreateObject("Kixtart.FORM")
$Form1.CAPTION = "Faild"
$Form1.SCALEWIDTH = 325
$Form1.SCALEHEIGHT = 30
$Form1.FONTSIZE = 10
$Form1.FONTNAME = "Verdana"
$Form1.PrintXY(10,6,"Wrong code")
$Form1.CENTER
$Form1.Show
Sleep 3
EndIf
Exit
;(Here i will to give the user one more chance or make it exit the script)
EndFunction
; (Here will the secound script begins, if Authentication is OK )
Break On
$Form = CreateObject('Kixtart.Form')
$Form.BackColor = 212,208,200
$Form.ControlBox = "True"
$Form.DrawGrid = "True"
$Form.FontBold = "False"
$Form.FontItalic = "False"
$Form.FontName = "Tahoma"
$Form.FontSize = 8
$Form.FontUnderline = "False"
$Form.ForeColor = 0,0,0
$Form.FormBorderStyle = 3
$Form.Height = 580
$Form.Left = 11
$Form.MaximizeBox = "False"
$Form.MinimizeBox = "True"
$Form.SizeGripStyle = 2
$Form.StartPosition = 4
$Form.Tag = ""
$Form.Text = "My Script"
$Form.Top = 3
$Form.ToolTipText = ""
$Form.TopMost = "False"
$Form.Width = 800
$Form.WindowState = 0
.
.
.
Edited by Cyrus (2004-03-18 06:41 PM)
_________________________
"... Great minds talk about idea' s, average minds talk about events and samll minds talks about people...!"
|
Top
|
|
|
|
#113569 - 2004-03-19 03:53 PM
Re: How to password protect a script?
|
Sealeopard
KiX Master
Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
|
I'd completely rewrite the whole thing along these liens: Code:
$=SetConsole("minimize")
Break On ;Dim $Form $Form = CreateObject("Kixtart.FORM") $Form.CAPTION = "Authentication for @FULLNAME" $Form.SCALEWIDTH = 300 $Form.SCALEHEIGHT = 60 $Form.FONTSIZE = 8 $Form.FONTNAME = "Verdana" $Form.PrintXY(15,6,"Enter authenticity Key and press Button") $Form.CENTER
$txtpassword = $form.textbox("",15,30,100,20) $txtpassword.passwordchar = "*" $txtpassword.text = "" $PSWB = $form.Button("Validate",125,30,100,20) $PSWB.OnClick = "PasswdC()"
$Form.Show While $Form.Visible $=Execute($Form.DoEvents()) Loop $Form=0 IF not $authenticated exit 2 endif
; do the main form ; (Here will the secound script begins, if Authentication is OK ) Break On
$Form = CreateObject('Kixtart.Form') $Form.BackColor = 212,208,200 $Form.ControlBox = "True" $Form.DrawGrid = "True" $Form.FontBold = "False" $Form.FontItalic = "False" $Form.FontName = "Tahoma" $Form.FontSize = 8 $Form.FontUnderline = "False" $Form.ForeColor = 0,0,0 $Form.FormBorderStyle = 3 $Form.Height = 580 $Form.Left = 11 $Form.MaximizeBox = "False" $Form.MinimizeBox = "True" $Form.SizeGripStyle = 2 $Form.StartPosition = 4 $Form.Tag = "" $Form.Text = "My Script" $Form.Top = 3 $Form.ToolTipText = "" $Form.TopMost = "False" $Form.Width = 800 $Form.WindowState = 0
sleep 10
Function PasswdC()
If $txtpassword.text = 'validate' $Authenticated = 1 EndFunction
there are other ways to do thsi, e.g. initializing the KiXforms system first, then create the password prompt. If success create the main form else display a messagebox and exit.
_________________________
There are two types of vessels, submarines and targets.
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 557 anonymous users online.
|
|
|