Darknight1366 Posted January 9, 2011 Posted January 9, 2011 $answer = MsgBox(4, "!!!!!", "Running a lot applications together you task manager has corrupted, Would you like to restart now?") If $answer = 7 Then MsgBox(0, "!!!!!", "Restart soon or your computer will corrupt") EndIf Exit If $answer - 6 Then Shutdown(2) Exit EndIf When I pressed "No" My computer rebooted! Did I type anything wrong in this script? Visit HugeSoft(TM) To Get Any Coding Help or Anything
Kalin Posted January 9, 2011 Posted January 9, 2011 (edited) Eh, I'm lazy. So I'll let my code do the talking. $answer = MsgBox(4, "!!!!!", "Running a lot applications together you task manager has corrupted, Would you like to restart now?") If $answer = 7 Then MsgBox(0, "!!!!!", "Restart soon or your computer will corrupt") If $answer = 6 Then MsgBox(0, "", "Computer shut down") ; ShutDown(2) Edited January 9, 2011 by Kalin
Darknight1366 Posted January 9, 2011 Author Posted January 9, 2011 @ Kalin Where's Exit or EndIf?? Visit HugeSoft(TM) To Get Any Coding Help or Anything
Kalin Posted January 9, 2011 Posted January 9, 2011 @ Kalin Where's Exit or EndIf??Run it and see, they aren't required.
timsta97 Posted January 9, 2011 Posted January 9, 2011 (edited) I think there are a couple things wrong with your script. Did you mean to put Exit before the first EndIf Statement? The rest of your script will be unreachable. You could also use the Else statement instead of another if statement. It isn't necessary when there are only two buttons. Here are my adjustments: $answer = MsgBox(4, "!!!!!", "Running a lot applications together you task manager has corrupted, Would you like to restart now?") If $answer == 7 Then MsgBox(0, "!!!!!", "Restart soon or your computer will corrupt") Else Shutdown(2) EndIf Also, the Exit command is not required. Edited January 9, 2011 by timsta97
shanet Posted January 9, 2011 Posted January 9, 2011 @ Kalin Where's Exit or EndIf?? With single line if statements, they are not required. Have a look: If 1 Then MsgBox(0, "Single Line Statement", "This is a single line statement") If 0 Then MsgBox(0, "Multi Line Statement", "This if statement will do more than one thing," & @CRLF & "therefore more than one line" & @CRLF $ "will be used." ;This is 'another function' EndIf I hope this makes it clearer? shanet [font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS: %programfiles%/AutoIt3/autoit3.chm
shanet Posted January 9, 2011 Posted January 9, 2011 You could also use the Else statement instead of another if statement. It isn't necessary when there are only two buttons. Here are my adjustments: $answer = MsgBox(4, "!!!!!", "Running a lot applications together you task manager has corrupted, Would you like to restart now?") If $answer == 7 Then MsgBox(0, "!!!!!", "Restart soon or your computer will corrupt") Else Shutdown(2) EndIf Also, the Exit command is not required. This is a good solution to the one above However I would personally do it another way in case it doesnt end with a value of -6 Here is how I would do it: $answer = MsgBox(4, "!!!!!", "Running a lot applications together you task manager has corrupted, Would you like to restart now?") If $answer = 7 Then MsgBox(0, "!!!!!", "Restart soon or your computer will corrupt") Elseif $answer = 6 Then Shutdown(2) EndIf Exit You may notice that in timsta97's version, the if statement condition was: $answer == 7 However mine is $answer = 7 Unlike programming languages such as C++, you do not need to check the value of the variable with ==. Its like magic You can set the variable value with its own line. $var1 = 10 ;lines of code $var1 = 9 There you go if $var1 = 10 Then MsgBox(0, "Hello", "Hello!") Hope this helps a bit more? shanet [font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS: %programfiles%/AutoIt3/autoit3.chm
Darknight1366 Posted January 9, 2011 Author Posted January 9, 2011 Thanks a lot you everyone, I understood it. I am a novice to autoit. So please don't laugh at me! lol. Visit HugeSoft(TM) To Get Any Coding Help or Anything
Kalin Posted January 9, 2011 Posted January 9, 2011 With single line if statements, they are not required. Have a look: If 1 Then MsgBox(0, "Single Line Statement", "This is a single line statement") If 0 Then MsgBox(0, "Multi Line Statement", "This if statement will do more than one thing," & @CRLF & "therefore more than one line" & @CRLF $ "will be used." ;This is 'another function' EndIf I hope this makes it clearer? shanet Uh, are you implying I already didn't know that? You wouldn't need to use more than one line in the code snippet I gave. Exit is useless in this script. A good replacement of Exit would of just been to set a timeout for the MsgBox.
ripdad Posted January 9, 2011 Posted January 9, 2011 $answer = MsgBox(4, "!!!!!", "Running a lot applications together you task manager has corrupted, Would you like to restart now?")I don't think I've ever seen Task Manager corrupted. How is that done? <grin> "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward
shanet Posted January 9, 2011 Posted January 9, 2011 Uh, are you implying I already didn't know that? No I am not. I did it to try and explain to DarkNight1366 how it works. I was not inferring that you dont already know that, especially considering that is in your code already. [font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS: %programfiles%/AutoIt3/autoit3.chm
shanet Posted January 9, 2011 Posted January 9, 2011 I don't think I've ever seen Task Manager corrupted. How is that done? <grin>I think its meant to be a bit of a joke script?As long as its not dangerous, its not a problem agreed? [font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS: %programfiles%/AutoIt3/autoit3.chm
shanet Posted January 9, 2011 Posted January 9, 2011 I don't think I've ever seen Task Manager corrupted. How is that done? <grin>I think its meant to be a bit of a joke script?As long as its not dangerous (keylogger, virii) or bots and stuff, its not a problem agreed?We all love playing jokes on people [font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS: %programfiles%/AutoIt3/autoit3.chm
ripdad Posted January 9, 2011 Posted January 9, 2011 The Data Protection virus likes to play jokes too - it's hard to know the difference .. "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward
Darknight1366 Posted January 9, 2011 Author Posted January 9, 2011 ripdad, Hey did you use ToolTip or something??? Would you please tell me?? Visit HugeSoft(TM) To Get Any Coding Help or Anything
Kalin Posted January 9, 2011 Posted January 9, 2011 (edited) ripdad, Hey did you use ToolTip or something??? Would you please tell me?? lul... $timeout = 40 ; 40 seconds $iconID = 2 ; warning icon TrayTip("WARNING!!!!!!!!!", "OMG U R GETTING HAXED", $timeout, $iconID) Oh, forgot to add. When using TrayTips you should control the delay with the Sleep() command instead of relying on the timeout alone. It'll still close too fast. So use sleep to add additional time. Edited January 9, 2011 by Kalin
timsta97 Posted January 9, 2011 Posted January 9, 2011 Unlike programming languages such as C++, you do not need to check the value of the variable with ==.Its like magic You can set the variable value with its own line.$var1 = 10;lines of code$var1 = 9You're right; it isn't necessary, before I learned C++ and C# I never used the double equals, but I always put it in because I now use C# mostly. It doesn't hurt to put it in; it affects the code in no way whatsoever.
Moderators Melba23 Posted January 9, 2011 Moderators Posted January 9, 2011 timsta97,It doesn't hurt to put it in; it affects the code in no way whatsoever.Actually it does. Using the == operator forces a case-sensitive comparison between the 2 operands converted to strings, which takes considerable more processing than the = operator.So the recommendation is to use the == operator only when you need the case sensitive comparison. In all other cases you should use the = operator.I hope that clears up any misconceptions. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Darknight1366 Posted January 10, 2011 Author Posted January 10, 2011 @Kalin I know how to do the traytip, but I wanted to know how do you change the autoit icon?? (Tick) Visit HugeSoft(TM) To Get Any Coding Help or Anything
bo8ster Posted January 10, 2011 Posted January 10, 2011 timsta97,Actually it does. Using the == operator forces a case-sensitive comparison between the 2 operands converted to strings, which takes considerable more processing than the = operator.So the recommendation is to use the == operator only when you need the case sensitive comparison. In all other cases you should use the = operator.I hope that clears up any misconceptions. M23I remember reading the thread on the usage of the two. It was related to bug or enhancement, too hard to find.By convention I use == for strings and = for numbers. I thought it forced the conversion to string, wasn't sure it was case sensitivity. Thanks Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]
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