Jump to content

MsgBox


Recommended Posts

  • Moderators

ileandros,

You test the return value from the MsgBox, not the original button. The MsgBox exits automatically when you press one of its buttons: ;)

Case $hButton5
    ; Create MsgBox and wait for the user to click a button on the MsgBox
    If MsgBox(4, "Update", " Check for updates?") = 6 Then
        ; If the "Yes" button was pressed
        gui3()
    Else
        ; In all other cases
        Exit
    EndIf

All cler? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

ileandros,

You test the return value from the MsgBox, not the original button. The MsgBox exits automatically when you press one of its buttons: ;)

Case $hButton5
    ; Create MsgBox and wait for the user to click a button on the MsgBox
    If MsgBox(4, "Update", " Check for updates?") = 6 Then
        ; If the "Yes" button was pressed
        gui3()
    Else
        ; In all other cases
        Exit
    EndIf

All cler? :)

M23

Nah this also gives the same action as the 6 =Yes :/

I feel nothing.It feels great.

Link to comment
Share on other sites

  • Moderators

ileandros,

Then post the working code you run that has the MsgBox remaining open after you press one if its buttons. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

ileandros,

That is not "working code" - I mean a full script that can actually be run. :)

Make it easy for us to help you - then we all win. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Ahhh yes i thought only the gui for the button :)

Here it is.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include <IE.au3>

Global $hGUI2 = 9999, $hButton3 = 9999 ; Predeclare the variables with dummy values to prevent firing the Case statements

gui1()

Func gui1()

$hForm1 = GUICreate("", 674, 190, 195, 130) 
$oIE = _IECreateEmbedded()
GUICtrlCreateObj($oIE,295,35,330,110)
$hButton1 = GUICtrlCreateButton("", 295, 150, 50, 25)
$hButton3 = GUICtrlCreateButton("", 355, 150, 50, 25)
$hButton5 = GUICtrlCreateButton("?",660,1,15,20)
$hButton2 = GUICtrlCreateButton("", 40, 150, 80, 25)
$hButton4 = GUICtrlCreateButton("Exit", 545, 150, 80, 25)
$List1 = GUICtrlCreateList("", 40, 35, 201, 110)
GUICtrlSetData(-1,"")
$hGroup1 = GUICtrlCreateGroup("", 24, 16, 230, 170)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$hGroup2 = GUICtrlCreateGroup("", 280, 16, 365, 170)
GUICtrlCreateGroup("", -99, -99, 1, 1)



GUISetState(@SW_SHOW)



    While 1
        $aMsg = GUIGetMsg(1) ; Use advanced parameter to get array
        Switch $aMsg[1] ; check which GUI sent the message
            Case $hForm1
                Switch $aMsg[0] ; Now check for the messages for $hGUI1
                    Case $GUI_EVENT_CLOSE ; If we get the CLOSE message from this GUI - we exit <<<<<<<<<<<<<<<
                        ExitLoop




Case $hButton5
MsgBox (4,"Update", " Check for updates?")
if $hButton5 = 6 Then
gui3()
Elseif 
exit


EndIf
Case $hButton4
MsgBox(0,"Exit","Now exiting...")
Exit



                EndSwitch
            Case $hGUI2
                Switch $aMsg[0] ; Now check for the messages for $hGUI2
                    Case $GUI_EVENT_CLOSE ; If we get the CLOSE message from this GUI - we just delete the GUI <<<<<<<<<<<<<<<
                        GUIDelete($hGUI2)
                        GUICtrlSetState($hButton2, $GUI_ENABLE) 
                EndSwitch
        EndSwitch
    WEnd

EndFunc   ;==>gui1

Func gui2()

$hGUI2 = GUICreate("Youtube",800,600,200,50)
$oIE = _IECreateEmbedded()
GUICtrlCreateObj($oIE,10,10,780,580)
_IENavigate($oIE,"")
GUISetState(@SW_SHOW)

EndFunc 

Func gui3()

$hGUI2 = GUICreate("iRadio v1.0",1000,600,200,50)
$oIE = _IECreateEmbedded()
GUICtrlCreateObj($oIE,10,10,980,580)
_IENavigate($oIE,"http://www.google.gr/")
GUISetState(@SW_SHOW)

EndFunc

I feel nothing.It feels great.

Link to comment
Share on other sites

You're not checking the return from the MsgBox, you're still using the controlID of $hButton5, which just so happens to be 6. You should also change the ElseIf back to an Else statement. Using Melba23's suggestion for the message box will fix this problem.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Developers

You need to run au3check on your code as it contains errors.

As to you question:

If MsgBox(4, "Update", " Check for updates?") = 6 Then
       gui3()
      Else
       Exit
      EndIf
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

You need to run au3check on your code as it contains errors.

As to you question:

If MsgBox(4, "Update", " Check for updates?") = 6 Then
       gui3()
      Else
       Exit
      EndIf

This doesnt work i already tried it... There are no errors.

The problem is that the

Else
gives the same resault as the

If MsgBox(4, "Update", " Check for updates?") = 6 Then
       gui3()
. It doesn't exit the MsgBox :/

I feel nothing.It feels great.

Link to comment
Share on other sites

  • Developers

Well the If I posted is correct and works fine for me.

When I click Yes it will show the Google.gr page and when I click No it will exit the script since that is what Exit does.

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

Well the If I posted is correct and works fine for me.

When I click Yes it will show the Google.gr page and when I click No it will exit the script since that is what Exit does.

I want the No to exit the MsgBox. I just don't know why but my script run it the same as the YES.

What the hell??? Is there another way to do it???? So i can avoid this??

I feel nothing.It feels great.

Link to comment
Share on other sites

  • Developers

I want the No to exit the MsgBox. I just don't know why but my script run it the same as the YES.

What the hell??? Is there another way to do it???? So i can avoid this??

Any button you click on the MSGBOX will exit the MsgBox().

So What exactly do you want to happen when No is clicked and the MSGbox is gone? Just display the Main GUI or something else?

.. by the way... it works best when you do not loose your temper... at least with me...

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

I think you are confusing the ideas of MsgBox with your GUI window. They are separate things. When you click any button on the MsgBox (or the timeout expires), the MsgBox automatically closes and returns a value indicating why it closed (which button was pushed, etc.); the MsgBox does not stick around after that, no matter which button you pushed. The GUI that you created can still stick around after the MsgBox disappears, but that is a different story.

As an experiment, build a simple script with just a message box with Yes, No, Cancel as the buttons. Put the value returned from the MsgBox into a variable. Present that value from a Ok only message box just after that.

Dim $nRetVal

$nRetVal = MsgBox(3+32, "MsgBox Test", "Please press a button.")
MsgBox(64, "MsgBox Test", "The returned number from the last MsgBox was " & $nRetVal & ".")

I like to close the GUI window before exiting with GuiDelete, but that appears to be just me.

Edited by Nutster

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

Link to comment
Share on other sites

Thanks Nutster,

I found what the prob was. Thank to ur help.

I just add this simple

$msgbox
thing and it seems to work fine finally

Case $hButton5
$msgbox = MsgBox (4,"Update", " Check for updates?")
if $msgbox = 6 Then
gui3()
EndIf

As simple as this. I dont know why but adding

$msgbox
solved my prob.

Thank u all for your help :)

I feel nothing.It feels great.

Link to comment
Share on other sites

Thanks Nutster,

I found what the prob was. Thank to ur help.

I just add this simple

$msgbox
thing and it seems to work fine finally

Case $hButton5
$msgbox = MsgBox (4,"Update", " Check for updates?")
if $msgbox = 6 Then
gui3()
EndIf

As simple as this. I dont know why but adding

$msgbox
solved my prob.

Thank u all for your help :)

That is exactly the same a M23 provided, except the Exit

Case $hButton5
    ; Create MsgBox and wait for the user to click a button on the MsgBox
    If MsgBox(4, "Update", " Check for updates?") = 6 Then
        ; If the "Yes" button was pressed
        gui3()
    Else
        ; In all other cases
        Exit
    EndIf

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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