Sign in to follow this  
Followers 0
DW1

IE oddness continues

4 posts in this topic

Hi Dale, or anybody else who can answer this,

Here is my reproducer:

1) Run the code posted at the bottom of this post ( first tab will be at www.google.com )

2) In the first tab, search for "test" (or anything really) in google

- Now the back button will be enabled.

3) Click back

- Now the forward button will be enabled.

4) Click forward

RESULTS I GOT ) I see a blank page now, but if I start mousing over the blank page, I notice it's not blank at all, further more if I just press Alt-A (select All) Everything will appear when highlighted....

Is it just me getting these results?

If not, what is a workaround that doesn't involve the whole GUI being hidden and shown?

Thank you for your time :)

#include <GUIConstants.au3>
#include <GuiTab.au3>
#include <IE.au3>
#include <GuiStatusBar.au3>
#include <array.au3>
HotKeySet("!t", "test")
Global $Tab[10], $oIE[10], $Obj[10]
Global $Title = "My Web Browser", $TabPos1 = 5, $TabPos2 = 35, $TabPos3 = 850, $TabPos4 = 650, $Status = 0, $Title2, $Status2 = ""
Global $backstack[4][2]
$backstack[1][0] = 1
$backstack[2][0] = 1
$backstack[3][0] = 1


_IEErrorHandlerRegister()
$Form = GUICreate($Title, $TabPos3 + 10, $TabPos4 + 30)
$FileMenu = GUICtrlCreateMenu("File")
$FileOpenTab = GUICtrlCreateMenuItem("New Tab", $FileMenu)
$EditMenu = GUICtrlCreateMenu("Edit")
$StatusBar = _GUICtrlStatusBar_Create($Form)
Local $aParts[1] = [500]
_GUICtrlStatusBar_SetParts($StatusBar, $aParts)
$Input = GUICtrlCreateInput("", 7, 7, 305, 22)
$Go = GUICtrlCreateButton("Go", 320, 5, 35, 25, 0)
$Back = GUICtrlCreateButton("Back", 360, 5, 43, 25, 0)
$Forward = GUICtrlCreateButton("Forward", 408, 5, 59, 25, 0)
$Stop = GUICtrlCreateButton("Stop", 472, 5, 43, 25, 0)
$Refresh = GUICtrlCreateButton("Refresh", 520, 5, 59, 25, 0)
$Home = GUICtrlCreateButton("Home", 584, 5, 43, 25, 0)
$CreateTab = GUICtrlCreateTab($TabPos1, $TabPos2, $TabPos3, $TabPos4 - 50)
GUICtrlSetState($Back, $GUI_DISABLE)
GUICtrlSetState($Forward, $GUI_DISABLE)
OpenTab(1, "http://www.google.com/")
OpenTab(2, "http://www.yahoo.com/")
OpenTab(3, "http://www.autoitscript.com/forum/index.php")
GUISetState()
$backstack[1][1] = "http://www.google.com/"
$backstack[2][1] = "http://www.yahoo.com/"
$backstack[3][1] = "http://www.autoitscript.com/forum/index.php"
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Go
            Navigate(GetTab(), GUICtrlRead($Input))
        Case $Back
            historyback(GetTab())
        Case $Forward
            historyforward(GetTab())
        Case $Stop
            _IEAction($oIE[GetTab()], "stop")
        Case $Refresh
            _IEAction($oIE[GetTab()], "refresh")
        Case $Home
            _IEAction($oIE[GetTab()], "home")
    EndSwitch
    testhistory(GetTab())
    CheckTitle()
    CheckStatusBar()
    Sleep(10)
WEnd
Func CheckTitle()
    $CurrentTitle = _IEPropertyGet($oIE[GetTab()], "title")
    If $CurrentTitle <> $Title2 Then
        WinSetTitle($Form, "", $CurrentTitle & " - " & $Title)
        $Title2 = $CurrentTitle
    EndIf
EndFunc   ;==>CheckTitle

Func CheckStatusBar()
    If _IEPropertyGet($oIE[GetTab()], "busy") And $Status2 <> _IEPropertyGet($oIE[GetTab()], "locationurl") Then
        _GUICtrlStatusBar_SetText($StatusBar, "Opening page " & _IEPropertyGet($oIE[GetTab()], "locationurl") & "...")
        GUICtrlSetState($Stop, $GUI_ENABLE)
        $Status2 = _IEPropertyGet($oIE[GetTab()], "locationurl")
    ElseIf Not _IEPropertyGet($oIE[GetTab()], "busy") And $Status2 <> "" Then
        _GUICtrlStatusBar_SetText($StatusBar, " ")
        GUICtrlSetState($Stop, $GUI_DISABLE)
        $Status2 = ""
    EndIf
EndFunc   ;==>CheckStatusBar
Func OpenTab($oNum, $oLink = "")
    $Tab[$oNum] = GUICtrlCreateTabItem($oNum)
    $oIE[$oNum] = _IECreateEmbedded()
    $Obj[$oNum] = GUICtrlCreateObj($oIE[$oNum], $TabPos1 + 5, $TabPos2 + 25, $TabPos3 - 10, $TabPos4 - 80)
    If $oLink <> "" Then
        Navigate($oNum, $oLink)
    EndIf
EndFunc   ;==>OpenTab
Func Navigate($nNum, $nLink)
    _IENavigate($oIE[$nNum], $nLink, 0)
    $nLink = StringReplace($nLink, "http://", "")
    $nLink = StringReplace($nLink, "www.", "")
    If StringInStr($nLink, "/") Then
        $nLink = StringSplit($nLink, "/")
        $nLink = $nLink[1]
    EndIf
    If StringLen($nLink) > 25 Then $nLink = StringLeft($nLink, 25) & "..."
    GUICtrlSetData($Tab[$nNum], $nLink)
EndFunc   ;==>Navigate

Func GetTab()
    Return _GUICtrlTab_GetCurSel($CreateTab) + 1
EndFunc   ;==>GetTab

Func testhistory($nNum)
    If $backstack[$nNum][$backstack[$nNum][0]] <> _IEPropertyGet($oIE[$nNum], "locationurl") And "" <> _IEPropertyGet($oIE[$nNum], "locationurl") Then
        $backstack[$nNum][0] += 1
        $newurl = _IEPropertyGet($oIE[$nNum], "locationurl")
        If $backstack[$nNum][0] + 1 > UBound($backstack, 2) Then ReDim $backstack[4][$backstack[$nNum][0] + 1]
        If $backstack[$nNum][$backstack[$nNum][0]] <> "" Then
            For $avar = $backstack[$nNum][0] To UBound($backstack, 2) - 1
                $backstack[$nNum][$avar] = ""
            Next
        EndIf
        $backstack[$nNum][$backstack[$nNum][0]] = $newurl
    EndIf
    If $backstack[$nNum][0] > 1 And GUICtrlGetState($Back) <> 80 Then GUICtrlSetState($Back, $GUI_ENABLE)
    If $backstack[$nNum][0] = 1 And GUICtrlGetState($Back) <> 144 Then GUICtrlSetState($Back, $GUI_DISABLE)
    If UBound($backstack, 2) - 1 > $backstack[$nNum][0] Then
        If $backstack[$nNum][$backstack[$nNum][0] + 1] = "" Then
            If GUICtrlGetState($Forward) <> 144 Then GUICtrlSetState($Forward, $GUI_DISABLE)
        Else
            If GUICtrlGetState($Forward) <> 80 Then GUICtrlSetState($Forward, $GUI_ENABLE)
        EndIf
    Else
        If GUICtrlGetState($Forward) <> 144 Then GUICtrlSetState($Forward, $GUI_DISABLE)
    EndIf
EndFunc   ;==>testhistory
Func historyback($nNum)
    GUICtrlSetState($Back, $GUI_DISABLE)
    $backstack[$nNum][0] -= 1
    Navigate($nNum, $backstack[$nNum][$backstack[$nNum][0]])
    While _IEPropertyGet($oIE[$nNum], "locationurl") <> $backstack[$nNum][$backstack[$nNum][0]]
        Sleep(10)
    WEnd
    testhistory($nNum)
EndFunc   ;==>historyback
Func historyforward($nNum)
    GUICtrlSetState($Forward, $GUI_DISABLE)
    $backstack[$nNum][0] += 1
    Navigate($nNum, $backstack[$nNum][$backstack[$nNum][0]])
    While _IEPropertyGet($oIE[$nNum], "locationurl") <> $backstack[$nNum][$backstack[$nNum][0]]
        Sleep(10)
    WEnd
    testhistory($nNum)
EndFunc
Func test()
    _ArrayDisplay($backstack)
EndFunc   ;==>test

Share this post


Link to post
Share on other sites



I'm pretty convinced that this is an issue with the GUI and not IE (between the tab controls and GUICtrlCreateObj). The WebBrowser control is not receiving the proper expose events to tell it to redraw. Another way to see this is that if you partially occlude the problem window with another windo and then remove it you will see only the rectangular area covered and uncovered gets drawn properly.

I believe that a simpler reproducer needs to be created and this needs to be written up as a bug report for the GUI. If you are willing to do this, I would also suggest trying the same things without the Tabs to verify that they are part of the cause.

As a workaround, perhaps you can create another GUI control the size and position of the IE area and flash it over the top after a navigation or tab change and immediately disable it to force the needed occlusion and redraw.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Thanks Dale,

I was thinking it might have something to do with the tabs, as I have never had this problem when dealing with a single embedded IE. I will try the suggested workaround and post my findings.

Thanks again,

Danny

Share this post


Link to post
Share on other sites

Thats the best workaround yet, thanks Dale

#include <GUIConstants.au3>
#include <GuiTab.au3>
#include <IE.au3>
#include <GuiStatusBar.au3>
#include <array.au3>
HotKeySet("!t", "test")
Global $Tab[10], $oIE[10], $Obj[10], $flasher[10]
Global $Title = "My Web Browser", $TabPos1 = 5, $TabPos2 = 35, $TabPos3 = 850, $TabPos4 = 650, $Status = 0, $Title2, $Status2 = "", $frskip = 0
Global $backstack[4][2]
$backstack[1][0] = 1
$backstack[2][0] = 1
$backstack[3][0] = 1


_IEErrorHandlerRegister()
$Form = GUICreate($Title, $TabPos3 + 10, $TabPos4 + 30)
$FileMenu = GUICtrlCreateMenu("File")
$FileOpenTab = GUICtrlCreateMenuItem("New Tab", $FileMenu)
$EditMenu = GUICtrlCreateMenu("Edit")
$StatusBar = _GUICtrlStatusBar_Create($Form)
Local $aParts[1] = [500]
_GUICtrlStatusBar_SetParts($StatusBar, $aParts)
$Input = GUICtrlCreateInput("", 7, 7, 305, 22)
$Go = GUICtrlCreateButton("Go", 320, 5, 35, 25, 0)
$Back = GUICtrlCreateButton("Back", 360, 5, 43, 25, 0)
$Forward = GUICtrlCreateButton("Forward", 408, 5, 59, 25, 0)
$Stop = GUICtrlCreateButton("Stop", 472, 5, 43, 25, 0)
$Refresh = GUICtrlCreateButton("Refresh", 520, 5, 59, 25, 0)
$Home = GUICtrlCreateButton("Home", 584, 5, 43, 25, 0)
$CreateTab = GUICtrlCreateTab($TabPos1, $TabPos2, $TabPos3, $TabPos4 - 50)
GUICtrlSetState($Back, $GUI_DISABLE)
GUICtrlSetState($Forward, $GUI_DISABLE)
OpenTab(1, "http://www.google.com/")
OpenTab(2, "http://www.yahoo.com/")
OpenTab(3, "http://www.autoitscript.com/forum/index.php")
GUISetState()
$backstack[1][1] = "http://www.google.com/"
$backstack[2][1] = "http://www.yahoo.com/"
$backstack[3][1] = "http://www.autoitscript.com/forum/index.php"
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Go
            Navigate(GetTab(), GUICtrlRead($Input))
        Case $Back
            historyback(GetTab())
        Case $Forward
            historyforward(GetTab())
        Case $Stop
            _IEAction($oIE[GetTab()], "stop")
        Case $Refresh
            _IEAction($oIE[GetTab()], "refresh")
        Case $Home
            _IEAction($oIE[GetTab()], "home")
    EndSwitch
    testhistory(GetTab())
    CheckTitle()
    CheckStatusBar()
    Sleep(10)
WEnd
Func CheckTitle()
    $CurrentTitle = _IEPropertyGet($oIE[GetTab()], "title")
    If $CurrentTitle <> $Title2 Then
        WinSetTitle($Form, "", $CurrentTitle & " - " & $Title)
        $Title2 = $CurrentTitle
    EndIf
EndFunc   ;==>CheckTitle

Func CheckStatusBar()
    If _IEPropertyGet($oIE[GetTab()], "busy") And $Status2 <> _IEPropertyGet($oIE[GetTab()], "locationurl") Then
        _GUICtrlStatusBar_SetText($StatusBar, "Opening page " & _IEPropertyGet($oIE[GetTab()], "locationurl") & "...")
        GUICtrlSetState($Stop, $GUI_ENABLE)
        $Status2 = _IEPropertyGet($oIE[GetTab()], "locationurl")
    ElseIf Not _IEPropertyGet($oIE[GetTab()], "busy") And $Status2 <> "" Then
        _GUICtrlStatusBar_SetText($StatusBar, " ")
        GUICtrlSetState($Stop, $GUI_DISABLE)
        $Status2 = ""
    EndIf
EndFunc   ;==>CheckStatusBar
Func OpenTab($oNum, $oLink = "")
    $Tab[$oNum] = GUICtrlCreateTabItem($oNum)
    $oIE[$oNum] = _IECreateEmbedded()
    $Obj[$oNum] = GUICtrlCreateObj($oIE[$oNum], $TabPos1 + 5, $TabPos2 + 25, $TabPos3 - 10, $TabPos4 - 80)
    $flasher[$oNum] = GUICtrlCreateEdit( "", $TabPos1 + 5, $TabPos2 + 25, $TabPos3 - 10, $TabPos4 - 80 )
    GUICtrlSetState( $flasher[$oNum], $GUI_HIDE )
    If $oLink <> "" Then
        Navigate($oNum, $oLink)
    EndIf
EndFunc   ;==>OpenTab
Func Navigate($nNum, $nLink)
    _IENavigate($oIE[$nNum], $nLink, 0)
    $nLink = StringReplace($nLink, "http://", "")
    $nLink = StringReplace($nLink, "www.", "")
    If StringInStr($nLink, "/") Then
        $nLink = StringSplit($nLink, "/")
        $nLink = $nLink[1]
    EndIf
    If StringLen($nLink) > 25 Then $nLink = StringLeft($nLink, 25) & "..."
    GUICtrlSetData($Tab[$nNum], $nLink)
EndFunc   ;==>Navigate

Func GetTab()
    Return _GUICtrlTab_GetCurSel($CreateTab) + 1
EndFunc   ;==>GetTab

Func testhistory($nNum)
    If $backstack[$nNum][$backstack[$nNum][0]] <> _IEPropertyGet($oIE[$nNum], "locationurl") And "" <> _IEPropertyGet($oIE[$nNum], "locationurl") Then
        $backstack[$nNum][0] += 1
        $newurl = _IEPropertyGet($oIE[$nNum], "locationurl")
        If $backstack[$nNum][0] + 1 > UBound($backstack, 2) Then ReDim $backstack[4][$backstack[$nNum][0] + 1]
        If $backstack[$nNum][$backstack[$nNum][0]] <> "" Then
            For $avar = $backstack[$nNum][0] To UBound($backstack, 2) - 1
                $backstack[$nNum][$avar] = ""
            Next
        EndIf
        $backstack[$nNum][$backstack[$nNum][0]] = $newurl
        If $frskip = 0 Then
            flashrefresh($nNum)
        Else
            $frskip = 0
        EndIf
    EndIf
    If $backstack[$nNum][0] > 1 And GUICtrlGetState($Back) <> 80 Then GUICtrlSetState($Back, $GUI_ENABLE)
    If $backstack[$nNum][0] = 1 And GUICtrlGetState($Back) <> 144 Then GUICtrlSetState($Back, $GUI_DISABLE)
    If UBound($backstack, 2) - 1 > $backstack[$nNum][0] Then
        If $backstack[$nNum][$backstack[$nNum][0] + 1] = "" Then
            If GUICtrlGetState($Forward) <> 144 Then GUICtrlSetState($Forward, $GUI_DISABLE)
        Else
            If GUICtrlGetState($Forward) <> 80 Then GUICtrlSetState($Forward, $GUI_ENABLE)
        EndIf
    Else
        If GUICtrlGetState($Forward) <> 144 Then GUICtrlSetState($Forward, $GUI_DISABLE)
    EndIf
EndFunc   ;==>testhistory
Func historyback($nNum)
    GUICtrlSetState($Back, $GUI_DISABLE)
    $backstack[$nNum][0] -= 1
    Navigate($nNum, $backstack[$nNum][$backstack[$nNum][0]])
    While _IEPropertyGet($oIE[$nNum], "locationurl") <> $backstack[$nNum][$backstack[$nNum][0]]
        Sleep(10)
    WEnd
    $frskip = 1
    testhistory($nNum)
    flashrefresh($nNum)
EndFunc   ;==>historyback
Func historyforward($nNum)
    GUICtrlSetState($Forward, $GUI_DISABLE)
    $backstack[$nNum][0] += 1
    Navigate($nNum, $backstack[$nNum][$backstack[$nNum][0]])
    While _IEPropertyGet($oIE[$nNum], "locationurl") <> $backstack[$nNum][$backstack[$nNum][0]]
        Sleep(10)
    WEnd
    $frskip = 1
    testhistory($nNum)
    flashrefresh($nNum)
EndFunc
Func test()
    _ArrayDisplay($backstack)

EndFunc   ;==>test
Func flashrefresh($nNum)
    GUICtrlSetState( $flasher[$nNum], $GUI_SHOW )
    GUICtrlSetState( $flasher[$nNum], $GUI_HIDE )
EndFunc

Share this post


Link to post
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
Sign in to follow this  
Followers 0