Sign in to follow this  
Followers 0
PcExpert

Only display the msgbox once

8 posts in this topic

#1 ·  Posted (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 by PcExpert

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

*bump*

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#6 ·  Posted (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 $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

Share this post


Link to post
Share on other sites

*bump*

Share this post


Link to post
Share on other sites

#8 ·  Posted (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 by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0