lucarim Posted November 6, 2009 Share Posted November 6, 2009 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") Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 6, 2009 Moderators Share Posted November 6, 2009 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 EndSwitchAs 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
lordicast Posted November 6, 2009 Share Posted November 6, 2009 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] Link to comment Share on other sites More sharing options...
Bowmore Posted November 6, 2009 Share Posted November 6, 2009 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 isMsgBox(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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now