Jump to content

msgbox buttons


Recommended Posts

ok stupid newbie question

lets say I have a program to shut down my comp after it has run. I want to put a msgbox up with the yes and no buttons.( this much I can do)

how do I get it to stop shutdown by clicking on no. and continue shutdown if yes is clicked or box times out?

Link to comment
Share on other sites

  • Moderators

Tuna,

Welcome to the AutoIt forum. :mellow:

You need to check the return from your MsgBox. From the Help file for MsgBox:

Return Value - Success: Returns the ID of the button pressed.

Button Pressed     Return Value  
YES                6 
NO                 7

So you need something like this:

$iReply = MsgBox(4, "ShutDown", "Dou you really want to shutdowm?")

If $iReply = 6 Then MsgBox(0, "Reply", "You pressed 'Yes'")
If $iReply = 7 Then MsgBox(0, "Reply", "You pressed 'No'")

There are fancier ways to do it, but we will start with that!

To shut down - look in the Help file for Shutdown. :party:

As you might have noticed - the Help file is a good place to look for help on AutoIt. :party:

As you are obviously new to coding, might I suggest that you read the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) - this will help you enormously. You should also look at the excellent tutorials that you will find here and here - you will find other tutorials in the Wiki (the link is at the top of the page). There are even video tutorials on YouTube if you prefer watching to reading. I know you want to start coding NOW, but a little study will save you a lot of trouble later on, believe me. :party:

I hope this helps. Enjoy coding in Autoit. :P

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

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