Sign in to follow this  
Followers 0
gigilihooie

Only allow one msgbox to pop up?

5 posts in this topic

Is there a way to make it when you press a button acouple times, only one instance of a msgbox pops up? Like I have now, if you press the button three times, three msgbox's pop up. I have looked and could not find anything.

Share this post


Link to post
Share on other sites



Is there a way to make it when you press a button acouple times, only one instance of a msgbox pops up? Like I have now, if you press the button three times, three msgbox's pop up. I have looked and could not find anything.

An example:

$GUI = GUICreate("EXAMPLE",200,200,50,50)
$BUTTON = GUICtrlCreateButton("MsgBox",50,50,100,100)
GUISetState(@SW_SHOW,$GUI)

While 1
    $MSG = GUIGetMsg()
    If $MSG = -3 Then
        Exit
    ElseIf $MSG = $BUTTON And Not(WinExists("TEST")) Then
        MsgBox(0,"TEST","THIS IS A MESSAGE BOX")
    EndIf
    Sleep(20)
WEnd

When the words fail... music speaks

Share this post


Link to post
Share on other sites

I'll just use a modified version Of Andreiks code to give you another example. His is best if you want to prvent multiple message boxes but if you only want a message box to appear once and then not show up again this will do it.

;
$GUI = GUICreate("EXAMPLE",200,200,50,50)
$BUTTON = GUICtrlCreateButton("MsgBox",50,50,100,100)
$iDispMsg = 1
GUISetState(@SW_SHOW,$GUI)

While 1
    $MSG = GUIGetMsg()
    Switch $Msg
        Case -3
           Exit
        Case $BUTTON
           If $iDispMsg Then MsgBox(0,"TEST","THIS IS A MESSAGE BOX")
           $iDispMsg = 0
    EndSwitch
WEnd
;

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Heres my version :)

Global $Num = 0

$GUI = GUICreate("EXAMPLE", 100, 100, -1, -1)
$BUTTON = GUICtrlCreateButton("MSGBOX", 10, 10, 80, 80)

GUISetState()
While 1
    $nMsg = GUIGetMsg()
    Select
    Case $nMsg = -3
        Exit
    Case $nMsg = $BUTTON
        If $Num = 2 Then
            MsgBox(0, "", "Test")
            $Num = 0
        Else
            $Num += 1
        EndIf
    EndSelect
WEnd

AlmarM


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

Andreik

Your example doesn't work :)

My 5 cents:

$GUI = GUICreate("EXAMPLE", 200, 200)
$BUTTON = GUICtrlCreateButton("MsgBox", 50, 50, 100, 100)
GUISetState(@SW_SHOW, $GUI)

While 1
    $MSG = GUIGetMsg()
    Switch $MSG
        Case - 3
            Exit
        Case $BUTTON
            MsgBox(0, "TEST", "THIS IS A MESSAGE BOX", 0, $GUI)
    EndSwitch
WEnd

:)

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