cheeseandcereal Posted January 26, 2012 Share Posted January 26, 2012 (edited) So I'm writing a code with some functions and I want my function to stop running if the no button is pressed in the msgbox. here is the code: Func Button8() $confirm4 = MsgBox ( 4+64, "Confirmation", "Are you sure you would like to restore your minecraft jar files? This will restore all of your minecraft jar files from the last time that you backed them up. This means that if you are currently having problems with the gametype changer function or you have destroyed a minecraft jar with mods, this should fix it. Use this function before the Old Restore function. *Note* The restore function only restores the jar files that the game changer uses, it will not restore the jar files for minecraft itself. To do that, you have to use the restore function THEN change the gametype afterwards. Continue?" ) If $confirm4 = 6 Then DirRemove ( "C:GametypeSwitcherMinecraftVersions1.8.1", 1 ) DirRemove ( "C:GametypeSwitcherMinecraftVersions1.0.0", 1 ) DirRemove ( "C:GametypeSwitcherMinecraftVersions1.1.0", 1 ) $check21 = DirCopy ( "C:GametypeSwitcherMinecraftVersionsBackupNewBackup1.0.0", "C:GametypeSwitcherMinecraftVersions", 1 ) $check23 = DirCopy ( "C:GametypeSwitcherMinecraftVersionsBackupNewBackup1.1.0", "C:GametypeSwitcherMinecraftVersions", 1 ) $check24 = DirCopy ( "C:GametypeSwitcherMinecraftVersionsBackupNewBackup1.8.1", "C:GametypeSwitcherMinecraftVersions", 1 ) EndIf IF $check21 = 1 And $check23 = 1 And $check24 = 1 Then MsgBox ( 0, "Success", "The restoration of the backup for working minecraft jar files was succesful. If gametype changing was messed up or mods destroyed a minecraft jar, it should now be restored and working. If these functions still do not work, try using the old restore function." ) Else $fail8 = MsgBox ( 4+16, "Failure", "The restoration was a failure. This means that your gametype changer functions may not work properly and it is recommended that you try again. Would you like to try again?" ) EndIf If $fail8 = 6 Then Button8() EndFunc So when I initially start this function a message box will pop up with either yes or no and if you click no, the operation will not happen, but I will get the failed msgbox because of the else function. I'm wondering if there is a command that will stop the function so if I press the no button on the first msgbox, nothing else will pop up. any help would be greatly appreciated Edited January 26, 2012 by cheeseandcereal Link to comment Share on other sites More sharing options...
BrewManNH Posted January 26, 2012 Share Posted January 26, 2012 Look in this wiki post http://www.autoitscript.com/wiki/Interrupting_a_running_function If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
rodent1 Posted January 26, 2012 Share Posted January 26, 2012 (edited) those examples are about interrupting functions in a GUI script. Here are other ways: to interrupt a script and then resume, set a hot key such as the break key. When hit, this will call TogglePause(), which will keep running and cause your script to only do that, till you hit break again. Dim $Paused = False HotKeySet("{PAUSE}", "TogglePause") Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc To exit a function, set up a hot key (here, again, the break key). Make it call a simple function to set a boolean to true, $bDone. In the function you want to exit, you can check for that value, and when true, exit: Dim $bDone = False HotKeySet("{PAUSE}", "quitscript") while not $bDone sleep(500) wend Func quitscript() $bDone = true EndFunc You can use that hot key to bring up a msgbox where you can decide if you want to quit or not. Edited January 26, 2012 by rodent1 Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted January 27, 2012 Share Posted January 27, 2012 Return .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
jvanegmond Posted January 27, 2012 Share Posted January 27, 2012 Return In my mind: "Good call, JohnOn..~~DAMNIT." github.com/jvanegmond Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted January 27, 2012 Share Posted January 27, 2012 In my mind: "Good call, JohnOn..~~DAMNIT." This avatar turned out much better funnier than i expected .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Kidney Posted January 27, 2012 Share Posted January 27, 2012 Func Button8() $confirm4 = MsgBox ( 4+64, "Confirmation", "Are you sure you would like to restore your minecraft jar files? This will restore all of your minecraft jar files from the last time that you backed them up. This means that if you are currently having problems with the gametype changer function or you have destroyed a minecraft jar with mods, this should fix it. Use this function before the Old Restore function. *Note* The restore function only restores the jar files that the game changer uses, it will not restore the jar files for minecraft itself. To do that, you have to use the restore function THEN change the gametype afterwards. Continue?" ) If $confirm4 = 6 Then DirRemove ( "C:GametypeSwitcherMinecraftVersions1.8.1", 1 ) DirRemove ( "C:GametypeSwitcherMinecraftVersions1.0.0", 1 ) DirRemove ( "C:GametypeSwitcherMinecraftVersions1.1.0", 1 ) $check21 = DirCopy ( "C:GametypeSwitcherMinecraftVersionsBackupNewBackup1.0.0", "C:GametypeSwitcherMinecraftVersions", 1 ) $check23 = DirCopy ( "C:GametypeSwitcherMinecraftVersionsBackupNewBackup1.1.0", "C:GametypeSwitcherMinecraftVersions", 1 ) $check24 = DirCopy ( "C:GametypeSwitcherMinecraftVersionsBackupNewBackup1.8.1", "C:GametypeSwitcherMinecraftVersions", 1 ) IF $check21 = 1 And $check23 = 1 And $check24 = 1 Then MsgBox ( 0, "Success", "The restoration of the backup for working minecraft jar files was succesful. If gametype changing was messed up or mods destroyed a minecraft jar, it should now be restored and working. If these functions still do not work, try using the old restore function." ) Else $fail8 = MsgBox ( 4+16, "Failure", "The restoration was a failure. This means that your gametype changer functions may not work properly and it is recommended that you try again. Would you like to try again?" ) EndIf If $fail8 = 6 Then Button8() Else MsgBox(0, "Stop", "Stop was pressed.") EndIf EndFunc u can replace the msgbox with a sleep(0) 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