sambalec Posted April 11, 2009 Posted April 11, 2009 Hello again How can I use a password to exit my script when i use right-click mouse on my icon ( right bottom ) ? Many thanks
isolation Posted April 11, 2009 Posted April 11, 2009 Opt("OnExitFunc","OnAutoItExit");"OnAutoItExit" called where OnAutoItExit is the name of your func
sambalec Posted April 11, 2009 Author Posted April 11, 2009 Ok thanks but how can i have for example "Close the program with password" when I click on icon ?
CodyBarrett Posted April 11, 2009 Posted April 11, 2009 TrayCreateItem ( text [, menuID [, menuentry [, menuradioitem]]] ) [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size]
Mat Posted April 11, 2009 Posted April 11, 2009 (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 April 11, 2009 by mdiesel AutoIt Project Listing
sambalec Posted April 11, 2009 Author Posted April 11, 2009 (edited) Thanks but i won't the button to exit on a window but in the option icon place ( TrayCreateItem("Close with password") ) Edited April 11, 2009 by sambalec
Mat Posted April 11, 2009 Posted April 11, 2009 Thanks but i won't the button to exit on a window but in the option icon place ( TrayCreateItem("Close with password") )?? 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. AutoIt Project Listing
Mat Posted April 11, 2009 Posted April 11, 2009 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 AutoIt Project Listing
sambalec Posted April 11, 2009 Author Posted April 11, 2009 Good, now I use : CODEOpt("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.
Mat Posted April 11, 2009 Posted April 11, 2009 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. AutoIt Project Listing
sambalec Posted April 11, 2009 Author Posted April 11, 2009 (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 April 11, 2009 by sambalec
Mat Posted April 11, 2009 Posted April 11, 2009 oh then it's exitloop your looking for. check helpfile as always its there under keyword/statement ref AutoIt Project Listing
sambalec Posted April 11, 2009 Author Posted April 11, 2009 (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 April 11, 2009 by sambalec
Mat Posted April 11, 2009 Posted April 11, 2009 (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 needa) to constantly check for something in an infinite loopB ) to have a GUIc) 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 ) Edited April 11, 2009 by mdiesel AutoIt Project Listing
sambalec Posted April 11, 2009 Author Posted April 11, 2009 Yes, my checking informations code is the loop... CODEOpt("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
Mat Posted April 11, 2009 Posted April 11, 2009 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 AutoIt Project Listing
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now