Webbrowser - Titel Problem

  • Hallo,
    ich habe einen Webbrowser erstellt. soweit so gut, jedoch möchte ich das ich sobald ich auf eine Seite komme der Titel geändert wird.
    Ich könnte zwar eine AdlibRegister Funktion nutzen aber das finde ich nicht gerade schön.
    Hat jemand eine Idee wie ich es anstelle, das sobald ich auf eine Website komme sich der Titel bzw. ein Button per GuiCtrlSetData ändert?
    Hier mein Source:

    [autoit]


    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 625, 443, 192, 124)
    $Obj1 = ObjCreate("Shell.Explorer.2")
    $Obj1_ctrl = GUICtrlCreateObj($Obj1, 0, 64, 620, 372,)
    $Button1 = GUICtrlCreateButton("Titel", 8, 32, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    #cs
    Wenn es einen neuen Titel gfibt dann
    $load = _IEPropertyGet($Obj1,"busy")
    If $load = False Then
    $sTitle = _IEPropertyGet($Obj1,"title")
    GUICtrlSetData($Button1, $sTitle)
    EndIf
    #ce

    EndSwitch
    WEnd

    [/autoit][autoit][/autoit][autoit][/autoit]
  • So?

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <IE.au3>

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

    Global $sTitle

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

    $hGui = GUICreate("Form1", 625, 443, 192, 124)
    $hTitle = GUICtrlCreateButton("Titel", 8, 32, 75, 25)
    $hAddress = GUICtrlCreateInput("", 100, 32, 300, 20)
    $hGo = GUICtrlCreateButton("Go", 420, 30, 50, 25)
    $oIE = _IECreateEmbedded()
    $hIE = GUICtrlCreateObj($oIE, 0, 64, 620, 372)
    GUISetState()

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

    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    Exit
    Case $hGo
    _IENavigate($oIE, GUICtrlRead($hAddress))
    $sTitle = _IEPropertyGet($oIE, "title")
    GUICtrlSetData($hTitle, $sTitle)
    WinSetTitle($hGui, "", $sTitle)
    EndSwitch
    WEnd

    [/autoit]
  • So?

    ich glaube er meint, wenn er auf der Internetseite irgendwelche links aufruft, dass dann der Titel der neu aufgerufenen Seite im Button "Titel" erscheinen soll.

    ProblemUser
    Du hast es doch schon fast gehabt, fehlte nur noch der else-Zweig

    [autoit]

    Case Else

    [/autoit]

    Schau mal hier:

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <IE.au3>

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

    #Region ### START Koda GUI section ### Form=
    $sTitle = "Titel"
    $sNewTitle = ""
    $ready = 0

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

    $Form1 = GUICreate("Form1", 625, 443, 192, 124)
    $Obj1 = ObjCreate("Shell.Explorer.2")
    $Obj1_ctrl = GUICtrlCreateObj($Obj1, 0, 64, 620, 372)
    $Button1 = GUICtrlCreateButton($sTitle, 8, 32, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    _IENavigate($Obj1, "www.google.de", 0); Nur zum testen

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case Else
    $ready = _IEPropertyGet($Obj1, "readystate")
    If $ready >= 3 Then
    $sNewTitle = _IEPropertyGet($Obj1, "title")
    If Not ($sTitle = $sNewTitle) Then
    $sTitle = $sNewTitle
    GUICtrlSetData($Button1, $sTitle)
    EndIf
    EndIf
    EndSwitch
    WEnd

    [/autoit]

    Mit der if abfrage

    [autoit]

    If Not ($sTitle = $sNewTitle) Then

    [/autoit]


    wird das flackern des Buttons verhindert ;)

    und mit "readystate" statt "busy"

    [autoit]

    $ready = _IEPropertyGet($Obj1, "readystate")

    [/autoit]


    kann man den Titel schon aktualisieren obwohl die Seite noch nicht ganz vollständig geladen ist ;)

    Gruß
    CD

  • Ürigens kannst du auch statt

    [autoit]

    If Not ($sTitle = $sNewTitle) Then

    [/autoit][autoit]

    If $sTitle <> $sNewTitle Then

    [/autoit]


    schreiben. ;)