Jump to content

Simple message box interaction - help needed


Recommended Posts

Hi there,

Sorry about this one...it sounds so simple - I am having real trouble with a simple msg box command.

I under stand how to make gui - assign a button and then get various actions to take place when that button is pressed.

However, in the example below

MsgBox(2+16, "Windows Error Example", "Choose message for each action", 5)

if @error = 3 Then

Run('Notepad.exe')

send('Test')

if @error = 5 Then

Run('iexplore.exe')

EndIf

All I am trying to do is that the error box produces three choices: Abort Retry and Ignore

Upon click clicking each error button, a different command needs to be performed.

EG:Abort button should make Notepad run with text then being sent in it

RETRY button should bring up IE

IGNORE button should for instance bring DOS window etc

I have checked the help file again and again, all I can find is that each error button has a return code ID, I have tried doing return commands, if and else etc, I just cannot seem to work out whats happening. Would really appreciate your help with this major hurdle (for me).

Thanks

Jackie

Link to comment
Share on other sites

  • Moderators

JackieMcGee,

It is not @error that you need to trap, it is the return value from the MsgBox function. :blink:

This should help make it clear:

; What value does the Msg Box return?
Switch MsgBox(2+16, "Windows Error Example", "Choose message for each action", 5)
    Case 3
        MsgBox(0, "Return", "You pressed ABORT")
    Case 4
        MsgBox(0, "Return", "You pressed RETRY")
    Case 5
        MsgBox(0, "Return", "You pressed IGNORE")
EndSwitch

You jsut put the code you want in place of the MsgBox lines in each Case.

Any questions? ;)

M23

P.S. When you post code please use Code tags. Put [autoit ] before and [/autoit ] after your posted code (but omit the trailing space - it is only there so the tags display here). Or press the blue button just under the BOLD toolbar button. :P

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

Alternatively you could put the message box return code in a variable:

$errval = MsgBox(2+16, "Windows Error Example", "Choose message for each action", 5)

if $errval = 3 Then
Run('Notepad.exe')
send('Test')

if $errval = 5 Then
Run('iexplore.exe')

EndIf
Edited by Foxhound
Link to comment
Share on other sites

  • Moderators

FoxHound,

I am afraid that your suggested code will not work - did you try to run it before posting? ;)

Perhaps you meant something like:

$errval = MsgBox(2 + 16, "Windows Error Example", "Choose message for each action", 5)

If $errval = 3 Then
    MsgBox(0, "Return", "You pressed ABORT")
ElseIf $errval = 4 Then
    MsgBox(0, "Return", "You pressed RETRY")
ElseIf $errval = 5 Then
    MsgBox(0, "Return", "You pressed IGNORE")
EndIf

Please do continue making suggestions in response to questions :P - but make sure that they run in future! :blink:

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

Thankyou to both of your for your help.

I am very grateful, both ways of the script were very useful for me, a little piece of the jigsaw of the scripting stuff has now been placed and its made some things about cases, variables etc clearer for me. Not everything has clicked yet but I am trying to take it all in. Thanks a bunch

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