Sign in to follow this  
Followers 0
sambalec

Ho to set a password to exit my script ?

16 posts in this topic

Hello again :D

How can I use a password to exit my script when i use right-click mouse on my icon ( right bottom ) ?

Many thanks

Share this post


Link to post
Share on other sites



Opt("OnExitFunc","OnAutoItExit");"OnAutoItExit" called

where OnAutoItExit is the name of your func

Share this post


Link to post
Share on other sites

Ok thanks but how can i have for example "Close the program with password" when I click on icon ?

Share this post


Link to post
Share on other sites

TrayCreateItem ( text [, menuID [, menuentry [, menuradioitem]]] )

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

TrayCreateItem ( text [, menuID [, menuentry [, menuradioitem]]] )

??

If I'm right you actually want to create anIcon in a GUI...

in which case, use Bs_Icon style on a button (check out helpfile for more)

on click bring up an input box, which if the correct passwrd is enetered, end script

eg:

GUICreate ("GUI", 100, 100)
$Button = GuiCtrlCreateButton ("Exit", 50, 50)
GUISetState ()

While 1
Select
   Case GuiGetMsg() = $Button
      $PassBox = InputBox ("ExitScript", "Please enter the password to exit the sscript.", "", "*M")
      If $PassBox = "Password" Then
         Exit
      Else
         MsgBox (48, "Error", "Incorrect password has been entered")
      EndIf
   Case Else
     ;;;
EndSelect
wend
Edited by mdiesel

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Thanks but i won't the button to exit on a window but in the option icon place ( TrayCreateItem("Close with password") ):D

Edited by sambalec

Share this post


Link to post
Share on other sites

Thanks but i won't the button to exit on a window but in the option icon place ( TrayCreateItem("Close with password") ):D

?? Not sure what you mean here, I presume you want the same to happen but for the tray Icon...

Just use exactly the same code, and replace The case $Button with $Traymenuitem or whatever you've made the handle.

Share this post


Link to post
Share on other sites

not hard:

Opt("TrayMenuMode",1)

GUICreate ("GUI", 100, 100)
$Button = GuiCtrlCreateButton ("Exit", 50, 50)
GUISetState ()
$close  = TrayCreateItem("Close", -1)

While 1
Select
   Case TrayGetMsg() = $Close
      $PassBox = InputBox ("ExitScript", "Please enter the password to exit the sscript.", "", "*M")
      If $PassBox = "Password" Then
         Exit
      Else
         MsgBox (48, "Error", "Incorrect password has been entered")
      EndIf
   Case GuiGetMsg() = $Button
      $PassBox = InputBox ("ExitScript", "Please enter the password to exit the sscript.", "", "*M")
      If $PassBox = "Password" Then
         Exit
      Else
         MsgBox (48, "Error", "Incorrect password has been entered")
      EndIf
   Case Else
    ;;;
EndSelect
wend

Share this post


Link to post
Share on other sites

Good, now I use :

CODE
Opt("TrayMenuMode",1)

GUISetState ()

$close = TrayCreateItem("Close", -1)

While 1

Select

Case TrayGetMsg() = $Close

$PassBox = InputBox ("Quitter le filtrage", "Entrez votre mot de passe parental", "", "*M")

If $PassBox = "Password" Then

Exit

Else

MsgBox (48, "Erreur", "Mot de passe incorrect")

EndIf

Case Else

;;;

EndSelect

wend

But, is it possible to use this in a function and not a while ? cause my script stay in the while and doesn't continue.

Share this post


Link to post
Share on other sites

yes, just put in the loop CloseScript ()

and add:

Func CloseScript ()
Local $PassBox
$PassBox = InputBox ("Quitter le filtrage", "Entrez votre mot de passe parental", "", "*M")
If $PassBox = "Password" Then
Exit
Else
MsgBox (48, "Erreur", "Mot de passe incorrect")
EndIf
EndFunc

to give you:

Opt("TrayMenuMode",1)

GUISetState ()
$close = TrayCreateItem("Close", -1)

While 1
Select
Case TrayGetMsg() = $Close
CloseScript ()

Case Else
;;;
EndSelect
wend

Func CloseScript ()
Local $PassBox
$PassBox = InputBox ("Quitter le filtrage", "Entrez votre mot de passe parental", "", "*M")
If $PassBox = "Password" Then
Exit
Else
MsgBox (48, "Erreur", "Mot de passe incorrect")
EndIf
EndFunc

you are going to have to include a loop somewhere though, and just build it into the loop.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

the problem is my code, I use a infinite while to find string on internet page. And it's not possible to use the stopscript while ? How can I do ... ?

Edited by sambalec

Share this post


Link to post
Share on other sites

oh

then it's exitloop your looking for.

check helpfile as always :D its there under keyword/statement ref

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

I know but I never want exit this loop when my script is started, possible ?

maybe use a script who control another script...

Edited by sambalec

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

I know but I never want exit this loop when my script is started, possible ?

maybe use a script who control another script...

kk...so you need

a) to constantly check for something in an infinite loop

B ) to have a GUI

c) to close GUI with tray icon.

look for alternatives - put it in the same loop, but just hide the GUI? or maybe GUIDelete?

lol cant use B and ) :D

Edited by mdiesel

Share this post


Link to post
Share on other sites

Yes, my checking informations code is the loop...

CODE
Opt("TrayMenuMode",1)

Func CloseScript ()

Local $PassBox

$PassBox = InputBox ("Quitter le filtrage", "Entrez votre mot de passe parental", "", "*M")

If $PassBox = "Password" Then

Exit

Else

MsgBox (48, "Erreur", "Mot de passe incorrect")

EndIf

EndFunc

GUISetState ()

$close = TrayCreateItem("Close", -1)

While 1

Select

Case TrayGetMsg() = $Close

CloseScript ()

Case Else

;My checking informations loop

while 1

;checking code with never Exitloop

Wend

EndSelect

wend

Share this post


Link to post
Share on other sites

no, becouse autoit must finish a line and then move onto the next.

Opt("TrayMenuMode",1)

GUICreate ("GUI", 100, 100)
$Button = GuiCtrlCreateButton ("Exit", 50, 50)

GUISetState ()
$close = TrayCreateItem("Close", -1)

;My checking informations loop
while 1
;checking code with never Exitloop
If TrayGetMsg () = $close Then
$PassBox = InputBox ("Quitter le filtrage", "Entrez votre mot de passe parental", "", "*M")
If $PassBox = "Password" Then
GUISetState (@SW_HIDE)
Else
MsgBox (48, "Erreur", "Mot de passe incorrect")
EndIf
EndIf
Wend

notice how the icon is still there after you click close, and autoit.exe is still in the process list? the script is still running but the GUI Is gone!

magic!

now you can also make it show again the same way

Opt("TrayMenuMode",1)

GUICreate ("GUI", 100, 100)
$Button = GuiCtrlCreateButton ("Exit", 50, 50)

GUISetState ()
$close = TrayCreateItem("Close", -1)
$open = TrayCreateItem("Open", -1)

;My checking informations loop
while 1
  ;checking code with never Exitloop
   If TrayGetMsg () = $close Or GUIGETMSG () = $Button Then
      $PassBox = InputBox ("Quitter le filtrage", "Entrez votre mot de passe parental", "", "*M")
      If $PassBox = "Password" Then
         GUISetState (@SW_HIDE)
      Else
         MsgBox (48, "Erreur", "Mot de passe incorrect")
      EndIf
   ElseIf TrayGetMsg () = $Open Then
      GUISetState (@SW_SHOW)
   EndIf
Wend

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  
Followers 0