Skype Push2Talk ObjectError

  • Hey Ihr,

    Ich hab mal ein Push2Talk für Skype gebastelt. Dabei hab ich die Scriptpassagen von einem anderen Thread genommen, dazu eine GUI gepackt.


    Nur 1 kleines Problem:

    AutoIt Script
    [autoit]


    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <Misc.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1_1 = GUICreate("Skype Push2Talk", 242, 236, 192, 124)
    $bgpic = GuiCtrlCreatePic (@SCRIPTDIR & "\skype-logo.jpg",-20,-10,262,250)
    $pic = GUICtrlSetState(-1,$GUI_DISABLE)
    $headline = GUICtrlCreateLabel("Skype Push2Talk", 8, 8, 204, 33)
    GUICtrlSetFont(-1, 15, 800, 0, "Nightclub BTN")
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetBkColor(-1, 0x000000)
    $copyright = GUICtrlCreateLabel("by Schrubber", 136, 40, 100, 21)
    GUICtrlSetFont(-1, 8, 800, 0, "Nightclub BTN")
    GUICtrlSetColor(-1, 0xFF0000)
    GUICtrlSetBkColor(-1, 0x000000)
    $status_lable = GUICtrlCreateLabel("Status", 8, 168, 50, 21)
    GUICtrlSetFont(-1, 8, 800, 0, "Nightclub BTN")
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetBkColor(-1, 0x000000)
    $status = GUICtrlCreateLabel("inactive", 64, 168, 56, 21)
    GUICtrlSetFont(-1, 8, 800, 0, "Nightclub BTN")
    GUICtrlSetColor(-1, 0xFF0000)
    GUICtrlSetBkColor(-1, 0x000000)
    $b_activate = GUICtrlCreateButton("Activate", 8, 192, 65, 33, $WS_GROUP)
    GUICtrlSetFont(-1, 8, 800, 0, "Nightclub BTN")
    GUICtrlSetColor(-1, 0xFF0000)
    GUICtrlSetBkColor(-1, 0xC0C0C0)
    $b_deactivate = GUICtrlCreateButton("Deactivate", 80, 192, 81, 33, $WS_GROUP)
    GUICtrlSetFont(-1, 8, 800, 0, "Nightclub BTN")
    GUICtrlSetColor(-1, 0xFF0000)
    GUICtrlSetBkColor(-1, 0xC0C0C0)
    $b_quit = GUICtrlCreateButton("Exit", 168, 192, 65, 33, $WS_GROUP)
    GUICtrlSetFont(-1, 8, 800, 0, "Nightclub BTN")
    GUICtrlSetColor(-1, 0xFF0000)
    GUICtrlSetBkColor(-1, 0xC0C0C0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    $oSkype = ""
    $key = ""
    $sAttach = "No"

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    $oSkype.Mute = "False"
    Exit

    [/autoit] [autoit][/autoit] [autoit]

    Case $b_quit
    $oSkype.Mute = "False"
    Exit

    [/autoit] [autoit][/autoit] [autoit]

    Case $b_activate
    if(ProcessExists("Skype.exe")) then
    $key = IniRead("key.ini", "keyconfig", "key", "")
    if($key = "") Then
    MSGBOX(0, "Error", "No Key is declared. Please edit your key.ini!")
    Else
    $oSkype = ObjCreate("Skype4COM.Skype")
    $oSkype.Attach()
    $sAttach = $oSkype.AttachmentStatus
    EndIf
    Else
    MSGBOX(0, "Error", "Skype is not running!")
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Case $b_deactivate
    GUICtrlSetData($status, "inactive")
    GUICtrlSetColor($status, 0xFF0000)
    $oSkype.Mute = "False"
    $sAttach = "Deactivated"
    EndSwitch
    _push2talk()
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _push2talk()
    If(ProcessExists("Skype.exe")) Then
    If $sAttach = "Success" Or $sAttach = "Erfolg" Then
    $oSkype.Mute = "True"
    GUICtrlSetData($status, "active")
    GUICtrlSetColor($status, 0x00FF00)

    [/autoit] [autoit][/autoit] [autoit]

    If _IsPressed($key) Then
    $oSkype.Mute = "False"
    While _IsPressed($key)
    sleep(64)
    WEnd
    $oSkype.Mute = "True"
    Else
    Sleep(100)
    EndIf
    Else
    Sleep(100)
    EndIf
    Else
    Sleep(100)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit]
    key.ini


    [keyconfig]
    key=20


    Wenn ich das starte, sagt er mir beim schließen wieder, dass $oSkype kein Object sei.
    Wie behebe ich dies? Das Programm funzt, wenn ich es mit activate usw. benutze, jedoch nicht, wenn ichs nur schließe.

    Will ja keinen Error kriegen :)


    Danke im vorraus,
    Schrubber

  • Ja weil du ja auch erst das Objekt erstellst wenn du es aktivierst.

    Kannst ja so umschreiben:

    Spoiler anzeigen
    [autoit]

    Case $GUI_EVENT_CLOSE
    If IsObj($oSkype) Then $oSkype.Mute = "False"
    Exit
    Case $b_quit
    If IsObj($oSkype) Then $oSkype.Mute = "False"
    Exit

    [/autoit]