Jump to content

Only display the msgbox once


 Share

Recommended Posts

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 by PcExpert
Link to comment
Share on other sites

The whole source:

Opt("TrayIconHide", 1)

HotKeySet("!{HOME}", "unlock")

boot()

Func boot()

If IniRead("settings.ini", "Settings", "Date", "") = @MDAY & "-" & @MON & "-" & @YEAR Then

Shutdown(5)

Else

RegWrite("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", "REG_DWORD", "1")

While 1

Sleep(10)

check()

WEnd

EndIf

EndFunc

Func check()

If @HOUR>19 Then

block()

EndIf

EndFunc

Func block()

Sleep(10)

if WinExists("Eigenschappen voor Datum en tijd") Then

WinClose("Eigenschappen voor Datum en tijd")

sleep(10)

EndIf

if ProcessExists("msmsgs.exe") Then

ProcessClose("msmsgs.exe")

Sleep(10)

EndIf

if ProcessExists("firefox.exe") Then

ProcessClose("firefox.exe")

Sleep(10)

EndIf

if ProcessExists("iexplore.exe") Then

ProcessClose("iexplore.exe")

Sleep(10)

EndIf

if ProcessExists("msnmsgr.exe") Then

ProcessClose("msnmsgr.exe")

Sleep(10)

EndIf

If @MIN>27 Then

txt1()

EndIf

EndFunc

Func txt1()

MsgBox(64, "Internet Block", "De computer gaat automatisch uit over 2 minuten", 10)

checkf()

EndFunc

Func checkf()

Sleep(10)

if WinExists("Eigenschappen voor Datum en tijd") Then

WinClose("Eigenschappen voor Datum en tijd")

sleep(10)

EndIf

sleep(10)

if ProcessExists("msmsgs.exe") Then

ProcessClose("msmsgs.exe")

Sleep(10)

EndIf

if ProcessExists("firefox.exe") Then

ProcessClose("firefox.exe")

Sleep(10)

EndIf

if ProcessExists("iexplore.exe") Then

ProcessClose("iexplore.exe")

Sleep(10)

EndIf

if ProcessExists("msnmsgr.exe") Then

ProcessClose("msnmsgr.exe")

Sleep(10)

EndIf

If @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)

EndFunc

Func Unlock()

$unlock = InputBox("Internet Block", "Please enter your password:", "", "*")

If $unlock = "passwordhere" Then

unlock1()

EndIf

EndFunc

Func unlock1()

$unlock1 = InputBox("Internet Block", "Please specify the amount of seconds to allow internet. Use * for unlimited")

If $unlock1 = "*" Then

Exit

Else

Sleep($unlock1 & "000")

check()

EndIf

EndFunc

Edited by PcExpert
Link to comment
Share on other sites

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 $checkvar

Global $checkvar2

Opt("TrayIconHide", 1)

HotKeySet("!{HOME}", "unlock")

boot()

Func boot()

If IniRead("settings.ini", "Settings", "Date", "") = @MDAY & "-" & @MON & "-" & @YEAR Then

Shutdown(5)

Else

RegWrite("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", "REG_DWORD", "1")

While 1

Sleep(10)

check()

WEnd

EndIf

EndFunc

Func check()

If @HOUR>19 Then

block()

EndIf

EndFunc

Func block()

Sleep(10)

if WinExists("Eigenschappen voor Datum en tijd") Then

WinClose("Eigenschappen voor Datum en tijd")

sleep(10)

EndIf

if ProcessExists("msmsgs.exe") Then

ProcessClose("msmsgs.exe")

Sleep(10)

EndIf

if ProcessExists("wlmail.exe") Then

ProcessClose("wlmail.exe")

Sleep(10)

EndIf

if ProcessExists("firefox.exe") Then

ProcessClose("firefox.exe")

Sleep(10)

EndIf

if ProcessExists("iexplore.exe") Then

ProcessClose("iexplore.exe")

Sleep(10)

EndIf

if ProcessExists("msnmsgr.exe") Then

ProcessClose("msnmsgr.exe")

Sleep(10)

EndIf

If @MIN>27 Then

txt1()

EndIf

EndFunc

Func txt1()

If $checkvar = 0 Then

MsgBox(64, "Internet Block", "De computer gaat automatisch uit over 2 minuten", 10)

$checkvar = 1

checkf()

EndIf

EndFunc

Func checkf()

Sleep(10)

if WinExists("Eigenschappen voor Datum en tijd") Then

WinClose("Eigenschappen voor Datum en tijd")

sleep(10)

EndIf

sleep(10)

if ProcessExists("msmsgs.exe") Then

ProcessClose("msmsgs.exe")

Sleep(10)

EndIf

if ProcessExists("wlmail.exe") Then

ProcessClose("wlmail.exe")

Sleep(10)

EndIf

if ProcessExists("firefox.exe") Then

ProcessClose("firefox.exe")

Sleep(10)

EndIf

if ProcessExists("iexplore.exe") Then

ProcessClose("iexplore.exe")

Sleep(10)

EndIf

if ProcessExists("msnmsgr.exe") Then

ProcessClose("msnmsgr.exe")

Sleep(10)

EndIf

If @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 = 1

EndIf

Shutdown(5)

EndFunc

Func Unlock()

$unlock = InputBox("Internet Block", "Please enter your password:", "", "*")

If $unlock = "Makey01yz12" Then

unlock1()

EndIf

EndFunc

Func unlock1()

$unlock1 = InputBox("Internet Block", "Please specify the amount of seconds to allow internet. Use * for unlimited")

If $unlock1 = "*" Then

Exit

Else

Sleep($unlock1 & "000")

check()

EndIf

EndFunc

Thanks!

Edited by PcExpert
Link to comment
Share on other sites

  • Developers

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 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...