Jump to content

Help with msgbox


Recommended Posts

Ok so what i am trying to do is when the message box appears it has two buttons (ok and cancel) all i want it to do is if you click ok it plays the song if not it just goes bk to doing nothing. Thing is im stuck with what to do after the msgbox() code i dont know what to add after this part ive been reading through the help file and just cant get my head aroound it. Tried lots of different ways and failed so hopefully some1 can point me in the rite direction or show me a little code to work from thanks.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

Example()

; Simple example: Embedding an Internet Explorer Object inside an AutoIt GUI
;
; See also: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/objects/internetexplorer.asp
Func Example()
    Local $oIE, $GUIActiveX, $GUI_Button_Song, $GUI_Button_Forward
    Local $GUI_Button_Home, $GUI_Button_Stop, $msg
    
    $oIE = ObjCreate("Shell.Explorer.2")

    ; Create a simple GUI for our output
    GUICreate("Testing something", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
    $GUIActiveX = GUICtrlCreateObj ($oIE, 10, 40, 600, 360)
    $GUI_Button_Song = GUICtrlCreateButton("Random Song", 10, 420, 100, 30)
    $GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 420, 100, 30)
    $GUI_Button_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30)
    $GUI_Button_Stop = GUICtrlCreateButton("Stop", 330, 420, 100, 30)

    GUISetState()       ;Show GUI

    $oIE.navigate("www.youtube.com")

    ; Waiting for user to close the window
    While 1
        $msg = GUIGetMsg()

        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $GUI_Button_Home
                $oIE.navigate("http://www.youtube.com")
            Case $msg = $GUI_Button_Song
                MsgBox(1, "Test", "Listen to this song")
                $oIE.navigate("http://www.youtube.com/watch?v=Qit3ALTelOo&feature=fvst")
            Case $msg = $GUI_Button_Forward
                $oIE.GoForward
            Case $msg = $GUI_Button_Stop
                $oIE.Stop
        EndSelect
        
    WEnd

    GUIDelete()
EndFunc   ;==>Example
Link to comment
Share on other sites

MsgBox: Success: Returns the ID of the button pressed.

Button Pressed Return Value  
OK  1 
CANCEL  2

$ms=MsgBox(1, "Test", "Listen to this song")

if $ms==1 Then playsong()

if $ms==2 Then donothing()

I ran. I ran until my muscles burned and my veins pumped battery acid. Then I ran some more.

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