Jump to content
Sign in to follow this  
au3scr

password box

Recommended Posts

au3scr

Hi

How i can make myscript ask password before close?

here is work that i have .

I want that it only close if input value is "root"

could anyone help me?

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("KMenu", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
GUISetBkColor(0x3A6EA5)
$MenuItem1 = GUICtrlCreateMenu("Exit")
$MenuItem11 = GUICtrlCreateMenuItem("exit", $MenuItem1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $MenuItem11
            #Region --- CodeWizard generated code Start ---
;InputBox features: Title=Yes, Prompt=Yes, Default Text=No, Input Length=4, Pwd Char=p
If Not IsDeclared("sInputBoxAnswer") Then Local $sInputBoxAnswer
$sInputBoxAnswer = InputBox("Close","You must be root to close this window, Type your password here:","","p4","-1","-1","-1","-1")
Select
    Case @Error = 0 ;OK - The string returned is valid

    Case @Error = 1 ;The Cancel button was pushed

    Case @Error = 3 ;The InputBox failed to open

EndSelect
#EndRegion --- CodeWizard generated code End ---
            exit
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites
au3scr

How i add password request here?

Sorry if its stupid question,but i just dont know it. :)

#include <GUIConstants.au3>
Opt("OnExitFunc", "endscript")

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("KMenu", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
GUISetBkColor(0x3A6EA5)
$MenuItem1 = GUICtrlCreateMenu("Exit")
$MenuItem11 = GUICtrlCreateMenuItem("exit", $MenuItem1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $MenuItem11
            endscript ()
    EndSwitch
WEnd

Func endscript ()
    Exit
EndFunc

Share this post


Link to post
Share on other sites
ReaImDown

Opt("OnExitFunc", "endscript") ;<----top of script

Func endscript()

$Password = InputBox("Enter Password", "Enter a password", "", "*")

EndFunc ;==>endscript

Edited by ReaImDown

[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]

Share this post


Link to post
Share on other sites
ReaImDown

thank you, it works now

np, it was nothing, also, it can be found in the helpfile

also, it doesnt do anything with the password in the example I gave...it asks 4 the pass, then it just turns off lol,

Edited by ReaImDown

[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.