PcExpert Posted December 9, 2007 Share Posted December 9, 2007 (edited) Hi all, How to let a msgbox only show once, so when there's been clicked on OK or the box timedout it doesnt appear anymore? A piece of the code: If @MIN>27 Then txt1() EndIf EndFunc Func txt1() MsgBox(64, "Internet Block", "De computer gaat automatisch uit over 2 minuten", 10) checkf() EndFunc I thought that if I did it like the above, when it's 28 minutes it goes to function txt1 and then forgets the if loop, but that didnt work out the way I expected, because it keeps displaying the msgbox. Thanks! Edited December 9, 2007 by PcExpert Link to comment Share on other sites More sharing options...
AlmarM Posted December 9, 2007 Share Posted December 9, 2007 Whats the whole source code? Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
PcExpert Posted December 9, 2007 Author Share Posted December 9, 2007 (edited) The whole source:Opt("TrayIconHide", 1)HotKeySet("!{HOME}", "unlock")boot()Func boot()If IniRead("settings.ini", "Settings", "Date", "") = @MDAY & "-" & @MON & "-" & @YEAR ThenShutdown(5)ElseRegWrite("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", "REG_DWORD", "1") While 1Sleep(10)check()WEndEndIfEndFuncFunc check()If @HOUR>19 Thenblock() EndIfEndFuncFunc block()Sleep(10)if WinExists("Eigenschappen voor Datum en tijd") ThenWinClose("Eigenschappen voor Datum en tijd")sleep(10) EndIfif ProcessExists("msmsgs.exe") ThenProcessClose("msmsgs.exe") Sleep(10)EndIfif ProcessExists("firefox.exe") ThenProcessClose("firefox.exe") Sleep(10)EndIfif ProcessExists("iexplore.exe") ThenProcessClose("iexplore.exe") Sleep(10)EndIfif ProcessExists("msnmsgr.exe") ThenProcessClose("msnmsgr.exe") Sleep(10)EndIfIf @MIN>27 Thentxt1()EndIfEndFuncFunc txt1()MsgBox(64, "Internet Block", "De computer gaat automatisch uit over 2 minuten", 10)checkf() EndFuncFunc checkf()Sleep(10)if WinExists("Eigenschappen voor Datum en tijd") ThenWinClose("Eigenschappen voor Datum en tijd")sleep(10) EndIf sleep(10) if ProcessExists("msmsgs.exe") ThenProcessClose("msmsgs.exe") Sleep(10)EndIfif ProcessExists("firefox.exe") ThenProcessClose("firefox.exe") Sleep(10)EndIfif ProcessExists("iexplore.exe") ThenProcessClose("iexplore.exe") Sleep(10)EndIfif ProcessExists("msnmsgr.exe") ThenProcessClose("msnmsgr.exe") Sleep(10)EndIfIf @MIN>29 Then txt2()EndIf EndFunc Func txt2()IniWrite("settings.ini", "Settings", "Date", @MDAY & "-" & @MON & "-" & @YEAR) MsgBox(64, "Internet Block", "De computer wordt uitgezet", 10)Shutdown(5)EndFuncFunc Unlock()$unlock = InputBox("Internet Block", "Please enter your password:", "", "*") If $unlock = "passwordhere" Thenunlock1()EndIfEndFuncFunc unlock1()$unlock1 = InputBox("Internet Block", "Please specify the amount of seconds to allow internet. Use * for unlimited")If $unlock1 = "*" ThenExitElseSleep($unlock1 & "000")check() EndIfEndFunc Edited December 9, 2007 by PcExpert Link to comment Share on other sites More sharing options...
PcExpert Posted December 10, 2007 Author Share Posted December 10, 2007 *bump* Link to comment Share on other sites More sharing options...
erebus Posted December 10, 2007 Share Posted December 10, 2007 Something like this (not tested): Global $checkvar If @MIN>27 Then txt1() EndIf Func txt1() If $checkvar = 0 Then MsgBox(64, "Internet Block", "De computer gaat automatisch uit over 2 minuten", 10) $checkvar = 1 checkf() EndIf EndFunc Link to comment Share on other sites More sharing options...
PcExpert Posted December 12, 2007 Author Share Posted December 12, 2007 (edited) That works, but when I try to add a second ' $checkvar' that becomes '$checkvar2' the second one doesnt work. But the first still does.How can this be solved?CODE:Global $checkvarGlobal $checkvar2Opt("TrayIconHide", 1)HotKeySet("!{HOME}", "unlock")boot()Func boot()If IniRead("settings.ini", "Settings", "Date", "") = @MDAY & "-" & @MON & "-" & @YEAR ThenShutdown(5)ElseRegWrite("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", "REG_DWORD", "1") While 1Sleep(10)check()WEndEndIfEndFuncFunc check()If @HOUR>19 Thenblock() EndIfEndFuncFunc block()Sleep(10)if WinExists("Eigenschappen voor Datum en tijd") ThenWinClose("Eigenschappen voor Datum en tijd")sleep(10) EndIfif ProcessExists("msmsgs.exe") ThenProcessClose("msmsgs.exe") Sleep(10)EndIfif ProcessExists("wlmail.exe") ThenProcessClose("wlmail.exe") Sleep(10)EndIfif ProcessExists("firefox.exe") ThenProcessClose("firefox.exe") Sleep(10)EndIfif ProcessExists("iexplore.exe") ThenProcessClose("iexplore.exe") Sleep(10)EndIfif ProcessExists("msnmsgr.exe") ThenProcessClose("msnmsgr.exe") Sleep(10)EndIfIf @MIN>27 Thentxt1()EndIfEndFuncFunc txt1()If $checkvar = 0 Then MsgBox(64, "Internet Block", "De computer gaat automatisch uit over 2 minuten", 10) $checkvar = 1 checkf()EndIfEndFuncFunc checkf()Sleep(10)if WinExists("Eigenschappen voor Datum en tijd") ThenWinClose("Eigenschappen voor Datum en tijd")sleep(10) EndIf sleep(10) if ProcessExists("msmsgs.exe") ThenProcessClose("msmsgs.exe") Sleep(10)EndIfif ProcessExists("wlmail.exe") ThenProcessClose("wlmail.exe") Sleep(10)EndIfif ProcessExists("firefox.exe") ThenProcessClose("firefox.exe") Sleep(10)EndIfif ProcessExists("iexplore.exe") ThenProcessClose("iexplore.exe") Sleep(10)EndIfif ProcessExists("msnmsgr.exe") ThenProcessClose("msnmsgr.exe") Sleep(10)EndIfIf @MIN>29 Then txt2()EndIf EndFunc Func txt2()IniWrite("settings.ini", "Settings", "Date", @MDAY & "-" & @MON & "-" & @YEAR) If $checkvar2 = 0 Then MsgBox(64, "Internet Block", "De computer gaat nu automatisch uit", 10) $checkvar2 = 1EndIfShutdown(5)EndFuncFunc Unlock()$unlock = InputBox("Internet Block", "Please enter your password:", "", "*") If $unlock = "Makey01yz12" Thenunlock1()EndIfEndFuncFunc unlock1()$unlock1 = InputBox("Internet Block", "Please specify the amount of seconds to allow internet. Use * for unlimited")If $unlock1 = "*" ThenExitElseSleep($unlock1 & "000")check() EndIfEndFuncThanks! Edited December 12, 2007 by PcExpert Link to comment Share on other sites More sharing options...
PcExpert Posted December 13, 2007 Author Share Posted December 13, 2007 *bump* Link to comment Share on other sites More sharing options...
Developers Jos Posted December 13, 2007 Developers Share Posted December 13, 2007 (edited) That is because the checkf() is only performed one time .... move the call for the func outside the If-EndIF. Func txt1() If $checkvar = 0 Then MsgBox(64, "Internet Block", "De computer gaat automatisch uit over 2 minuten", 10) $checkvar = 1 EndIf checkf() EndFunc Edited December 13, 2007 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. 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