#NoTrayIcon
#include <INet.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Local $MPfad=@WindowsDir & "\media\tada.wav",$Icqnummer            g!

;GUI
$ICQ =     GUICreate("ICQ Melder", 219, 147, 564, 419)
$Input1 = GUICtrlCreateInput("", 72, 32, 65, 21)
$Label1 = GUICtrlCreateLabel("ICQ Nummer des Kontaktes", 40, 8, 135, 17)
$Button2 =GUICtrlCreateButton("Abzuspielenden Sound  wählen", 16, 56, 185, 25, $WS_GROUP)
$Button1 =GUICtrlCreateButton("Start", 72, 112, 67, 25, $WS_GROUP)
$Label2 = GUICtrlCreateLabel("Wiedergabe Anzah wählen", 16, 88, 138, 17)
$Combo1 = GUICtrlCreateCombo("1",152, 88, 41, 25,$CBS_DROPDOWNLIST)
GUICtrlSetData(-1,"2|3|4|5|6|7|8|9|10")
GUISetState()

;Mainloop
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button1
            $Icqnummer = GUICtrlRead($Input1)
            If $Icqnummer = "" Then     ;Error-Check
                MsgBox(4096, "Error", "Keine ICQ Nummer eingegeben!", 10)
                ContinueCase    ;Jumped zum nächsten "Case"
            EndIf

            If ICQState($Icqnummer) Then    ;Falls sie richtig ist, Status prüfen!
                for $n = 1 to GUICtrlRead($Combo1) step 1    ;wiederhole von 1 bis was in der Combo steht!
                    SoundPlay($MPfad,1)
                Next
					Exit
            Else
                If @error then MsgBox(4096, "Error", "ICQ Nummer inkorrekt!", 10)
            endif

        Case $Button2
            $MPfad= FileOpenDialog('Select Musik', '', 'mp3(*.mp3)|wav(*.wav)', 3)
            If @error = True Then
                $MPfad=@WindowsDir & "\media\tada.wav"
            EndIf
    EndSwitch
WEnd


func ICQState($hID)
    $sSource = _INetGetSource("http://www.icq.com/people/"&$hID&"/")
    If @error then return SetError(@error)
    If StringInStr ( $sSource, "online.gif" ) then return 1
endfunc
