HardHackz Posted February 27, 2007 Share Posted February 27, 2007 Hello, I want to add a confirmation to a shutdown script I have. I know I can use a message box with flag 1 or 2, not quite sure which, and then have it find what the value they clicked was. The problem is, I don't know how to get the value, here is my script right now: expandcollapse popup#Include <Constants.au3> #Include <misc.au3> #NoTrayIcon _Singleton("TrayCommand.exe") Opt("TrayMenuMode", 1) $programs = TrayCreateMenu("Programs") $tools = TrayCreateMenu("Tools", $programs) $internet = TrayCreateMenu("Internet", $programs) $other = TrayCreateMenu("Other", $programs) $websites = TrayCreateMenu("Websites") $system = TrayCreateMenu("System Items") $shutdown = TrayCreateItem("Shutdown",$system) $logoff = TrayCreateItem("Logoff",$system) $suspend = TrayCreateItem("Stand By",$system) $sleep = TrayCreateItem("Hibernate",$system) $reboot = TrayCreateItem("Restart",$system) $zi = TrayCreateItem("ZeroIdentity", $websites) $aim = TrayCreateItem("AIM", $internet) $firefox = TrayCreateItem("Firefox", $internet) $alftp = TrayCreateItem("ALFTP", $internet) $record = TrayCreateItem("Quick Screen Recorder", $tools) $paint = TrayCreateItem("MSPaint", $tools) $alzip = TrayCreateItem("ALZip", $tools) $notepad = TrayCreateItem("Notepad", $tools) $scite = TrayCreateItem("SciTE", $tools) $help = TrayCreateItem("AutoIT Help", $other) TrayCreateItem("") $about = TrayCreateItem("About") $exit = TrayCreateItem("Exit") TraySetState() While 1 $msg = TrayGetMsg() Select Case $msg = 0 ContinueLoop Case $msg = $aim Run("C:\Program Files\AIM6\aim6.exe") Case $msg = $firefox Run("C:\Program Files\Mozilla Firefox\firefox.exe") Case $msg = $notepad Run("notepad.exe") Case $msg = $scite Run("C:\Program Files\AutoIt3\SciTE\SciTE.exe") Case $msg = $alftp Run("C:\Program Files\ESTsoft\ALFTP\ALFTP.exe") Case $msg = $alzip Run("C:\Program Files\ESTsoft\ALZip\ALZip.exe") Case $msg = $paint Run("mspaint.exe") Case $msg = $shutdown Shutdown(1) Case $msg = $reboot Shutdown(2) Case $msg = $logoff Shutdown(0) Case $msg = $sleep Shutdown(64) Case $msg = $suspend Shutdown(32) Case $msg = $zi ShellExecute("http://www.zeroidentity.org/") Case $msg = $record Run("C:\Program Files\Quick Screen Recorder\qsr.exe") Case $msg = $help Run("C:\Program Files\AutoIt3\AutoIt3Help.exe") Case $msg = $about MsgBox(0, "Tray Command v1.0 RC2", "TrayCommand v1.0 RC2 no Comments") Case $msg = $exit ExitLoop EndSelect WEnd Exit [center]My BlogOldSock Programs (AutoIT Apps)A Message to Hackers! (NOT SKIDDIES!)OldSock Programs is my little "company."[/center] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 27, 2007 Moderators Share Posted February 27, 2007 You need to look at MsgBox(XXX, << in the help file to see the different options... Then do... If MsgBox(XX, 'Whatever', 'Do something') = Value ThenoÝ÷ ØLZ^jëh×6MsgBox(64, 'Info', 'Your Click Value = ' & MsgBox(4, 'Choose', 'Choose Yes Or No')) Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
HardHackz Posted February 27, 2007 Author Share Posted February 27, 2007 Okay, thanks a bunch. [center]My BlogOldSock Programs (AutoIT Apps)A Message to Hackers! (NOT SKIDDIES!)OldSock Programs is my little "company."[/center] Link to comment Share on other sites More sharing options...
_Kurt Posted February 27, 2007 Share Posted February 27, 2007 $iMsgBoxAnswer = MsgBox(52,"","Click Yes for another msgbox, or no to exit.") Select Case $iMsgBoxAnswer = 6 Msgbox(0,"","Wow why the hell would you want ANOTHER msgbox?") Case $iMsgBoxAnswer = 7 Exit EndSelect Try that, Kurt Awaiting Diablo III.. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 27, 2007 Moderators Share Posted February 27, 2007 (edited) $iMsgBoxAnswer = MsgBox(52,"","Click Yes for another msgbox, or no to exit.") Select Case $iMsgBoxAnswer = 6 Msgbox(0,"","Wow why the hell would you want ANOTHER msgbox?") Case $iMsgBoxAnswer = 7 Exit EndSelectoÝ÷ Ù:ò¶*êíþ«¨µå¡Êz-ë-jëh×6If MsgBox(52,"","Click Yes for another msgbox, or no to exit.") = 7 Then ExitoÝ÷ ØÚ'yçm¢f¤z+h½êåÉÊ&¦Xj×jwg¢wuú+jö«¦åxò¢é®²ØZ½í¨¦Ø¨Æ®¶sdb×6t&÷S"ÂgV÷C²gV÷C²ÂgV÷C´6Æ6²W2f÷"æ÷FW"×6v&÷Â÷"æòFòWBâgV÷C²ÒbFVà¢×6v&÷ÂgV÷C²gV÷C²ÂgV÷Cµv÷rvFRVÆÂv÷VÆB÷RvçBäõDU"×6v&÷ògV÷C²¤VÇ6P¢W@¤VæD` Edited February 27, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
HardHackz Posted February 27, 2007 Author Share Posted February 27, 2007 Why not just:If MsgBox(52,"","Click Yes for another msgbox, or no to exit.") = 7 Then ExitoÝ÷ ØÚ'yçm¢f¤z+h½êåÉÊ&¦Xj×jwg¢wuú+jö«¦åxò¢é®²ØZ½í¨¦Ø¨Æ®¶sdb×6t&÷S"ÂgV÷C²gV÷C²ÂgV÷C´6Æ6²W2f÷"æ÷FW"×6v&÷Â÷"æòFòWBâgV÷C²ÒbFVà¢×6v&÷ÂgV÷C²gV÷C²ÂgV÷Cµv÷rvFRVÆÂv÷VÆB÷RvçBäõDU"×6v&÷ògV÷C²¤VÇ6P¢W@¤VæD` [center]My BlogOldSock Programs (AutoIT Apps)A Message to Hackers! (NOT SKIDDIES!)OldSock Programs is my little "company."[/center] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 28, 2007 Moderators Share Posted February 28, 2007 (edited) Well the first one didn't work because you probably changed 7 to 1 (and I'm using 52 as the decimal flag, not 1)! There are only 2 return values there with the first example... 6 and 7. Case $msg = $shutdown If MsgBox(1,"Shutdown?","Are you sure you wish to shutdown?") = 1 Then ShutDown(1)You don't need the Continueloop unless you don't want to do anything below that case statement... Edit: Quoted the wrong decimal flag Edited February 28, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
HardHackz Posted February 28, 2007 Author Share Posted February 28, 2007 (edited) Well the first one didn't work because you probably changed 7 to 1 (and I'm using 64 as the decimal flag, not 1)! There are only 2 return values there with the first example... 6 and 7. Case $msg = $shutdown If MsgBox(1,"Shutdown?","Are you sure you wish to shutdown?") = 1 Then ShutDown(1)You don't need the Continueloop unless you don't want to do anything below that case statement...okay, i got it, thanks everyone. btw, if anyone wants the full source: http://www.esnips.com/web/AutoIT-Scripts Also, how can I make the tooltip on it different? EDIT: You'll see in the script I changed it from the way you gave me a little, and what I meant was I had coded it myself the correct way and it didn't work. Edited February 28, 2007 by HardHackz [center]My BlogOldSock Programs (AutoIT Apps)A Message to Hackers! (NOT SKIDDIES!)OldSock Programs is my little "company."[/center] Link to comment Share on other sites More sharing options...
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