Sign in to follow this  
Followers 0
lucarim

Msgbox Help

4 posts in this topic

I am trying to create a MsgBox that would give you OK and cancel, but depending on which you choose it do different things. for instance if you choose OK then it restarts computer if you choose cancel it logs off computer. If you could provide an example it would be great, but Any help is appreciated.

the MsgBox code Im using is

MsgBox(1, "Attention", "Press OK to restart or CANCEL To Logoff")

Share this post


Link to post
Share on other sites



lucarim,

First, welcome to the Autoit forums. :)

This is one of the ways to do what you want:

$iResult = MsgBox(1, "Attention", "Press OK to restart or CANCEL To Logoff")

Switch $iResult
    Case 1  ; look at MsgBox in the Help file to see which buttons give which return value
        ; restart code goes here
    Case 2
        ; Logoff code goes here
EndSwitch

As a beginner, reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously. You should also look at the excellent tutorials that you will find here and here. There are even video tutorials on YouTube if you do not like reading - and one of them actually does what you wanted to do!

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

or you can you use if's dont forget to write the function,

$MSB = MsgBox(1, "Test", "OK shut down , Cancel logoff")
If $MSB = 1 Then
    ;Reboot()
ElseIf $MSB = 2 Then
    ;Logoff()
EndIf

Func Logoff()
    ;you logoff script
EndFunc   ;==>Logoff
Func Reboot()
    ;you reboot script
EndFunc   ;==>Reboot

[Cheeky]Comment[/Cheeky]

Share this post


Link to post
Share on other sites

I am trying to create a MsgBox that would give you OK and cancel, but depending on which you choose it do different things. for instance if you choose OK then it restarts computer if you choose cancel it logs off computer. If you could provide an example it would be great, but Any help is appreciated.

the MsgBox code Im using is

MsgBox(1, "Attention", "Press OK to restart or CANCEL To Logoff")

I you have downloaded the customised version of SciTe SciTE4AutoIt3 which is highly recommended, it comes with the CodeWizard tool which can help you create the code for things like MsgBox without having to remember what all the options and parameters are. 


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

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