Sign in to follow this  
Followers 0
Audrey

Force user to close Msgbox before continue

8 posts in this topic

Hi All,

I'm Audrey (the female newbie) and super fresh on AutoIt.

My first problem writing a script is perhaps a simple one for you out there!

In the code below you have a mainpage and a button. Pressing the button will open the Msgbox.

Now, I want to force the close the Msgbox first (by clicking the OK button) before he can continue with mainpage.

This box would be a message or something, that has to be confirmed by the user, before he can do anything else.

I tried the Disable/Enable and the lock/unlock function, but it was not working..

Can this be done?

All the best,

Audrey

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

Example1()

; example 1
Func Example1()
    Local $msg, $button

    GUICreate("Mainpage")
    $button = GUICtrlCreateButton("Button", 30, 30, 70)
    GUISetState()

    While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        If $msg = $button Then MsgBox(0, "Help", "Please close me!")
            
    WEnd
    GUIDelete()
EndFunc

Share this post


Link to post
Share on other sites



Audrey,

Welcome to the AutoIt forum. :unsure:

Take a look at the Modal MsgBox Styles tutorial in the Wiki - it will explain how to set the style of your MsgBox to prevent the user from interacting with the main GUI until the MsgBox is cleared. ;)

Come back if you are still unclear. :>

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I tried the Disable/Enable and the lock/unlock function, but it was not working..

Melba23 already pointed out how to solve your problem, anyway, I'm just curious why disable/enable is not working.

I tried it and it worked fine changing this:

If $msg = $button Then MsgBox(0, "Help", "Please close me!")

to this:

If $msg = $button Then
    GUISetState(@SW_DISABLE)
    MsgBox(0, "Help", "Please close me!")
    GUISetState(@SW_ENABLE)
EndIf

Edit: I mistyped Melba's nick :unsure:

Edited by sahsanu

Share this post


Link to post
Share on other sites

Or set the "parent" param of MsgBox

Yes, I think that is the best way, everyone should do it! You don't have to remember so many funny numbers and the dialog flashes if you click on the parent. (And it should be in the Wiki).


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

martin,

it should be in the Wiki

It is now! :>

AdmiralAlkex,

Thanks for the suggestion. :unsure:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Yes, I think that is the best way, everyone should do it!

I think so too.

@Audrey, this is what Melba23 said:

MsgBox(8192, "Help", "Please close me!") ;pay attention to 8192

and this is an example using parent as suggested by AdmiralAlkex and Martin :unsure:.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

Example1()

; example 1
Func Example1()
    Local $msg, $button, $mygui

    $mygui=GUICreate("Mainpage")
    $button = GUICtrlCreateButton("Button", 30, 30, 70)
    GUISetState()

    While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        If $msg = $button Then MsgBox(0, "Help", "Please close me!","",$mygui)
    WEnd
    GUIDelete()
EndFunc

Share this post


Link to post
Share on other sites

Hi Guys (I assume) :unsure:

I did not know there were replies already, because my notification button was switched off. :>

Thanks for all the solutions. This will help me a lot further!

My new newbie questions will be posted soon.

Greetings,

Audrey

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