Jump to content
Sign in to follow this  
BillLuvsU

Embedded IE seems pretty buggy.

Recommended Posts

BillLuvsU

The script will crash: to clarify its a hard crash, the process stops responding.

1. whenever you scroll down a page, then switch to another window

2. whenever you select a sorting option when using it to view a local directory

3. whenever it attempts to open a new window through a link

There maybe more but I those are the ones I was able to figure out for sure. This is my first time actually using this UDF library so I might be doing something wrong, but to me at least seems like it might be a problem somewhere deeper.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <ListViewConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <Array.au3>


Const $IE_Home = @ScriptDir & "htmlhome.html"
Const $DB_Path = @ScriptDir & "db"
Const $Max_Phones = 999


Dim $Resources_Phones[$Max_Phones][2];Storage for phone info
                            ;[0] = ListViewItem ID
                            ;[1] = Index Page



$structure = DirGetContents(@ScriptDir & "")
_ArrayDisplay($structure)


#Region ### START Koda GUI section ### Form=
$GUI = GUICreate("GSMdb 0.1", 916, 481, 190, 122)

$Tab = GUICtrlCreateTab(0, 0, 465, 473)
$Resources_Tab = GUICtrlCreateTabItem("Resources")
$Resources_List = GUICtrlCreateList("", 8, 32, 121, 435)
$Resources_ListView = GUICtrlCreateListView("Name|Model|Carrier", 136, 32, 320, 433)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 75)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 75)

GUISwitch($GUI)

$Archives_Tab = GUICtrlCreateTabItem("Archives")
GUICtrlSetState(-1,$GUI_SHOW)
$Archives_List = GUICtrlCreateList("", 8, 32, 121, 435)
$Archives_ListView = GUICtrlCreateListView("Date|Number|Model|MEID", 136, 32, 320, 433)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 60)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 75)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 105)
GUICtrlCreateListViewItem ( "12/12/12|(603)789-4356|SPC6000|0xA000001F23EF3", $Archives_ListView )


GUISwitch($GUI)
GUICtrlCreateTabItem("")

;Create Display Plane
$Display_Home = GUICtrlCreateButton( "Home", 470, 3, 35, 35 )
$Display_Back = GUICtrlCreateButton( "<--", 530, 3, 35, 35 )
$Display_Forward = GUICtrlCreateButton( "-->", 570, 3, 35, 35 )
$Display = GUICreate("Resources_Display", 445, 430, 465, 40, $WS_CHILD + $WS_BORDER, -1, $GUI )
GUISetBkColor ( 0xBBBBBB )
_IEErrorHandlerRegister()
Local $Display_IE = _IECreateEmbedded()
GUICtrlCreateObj($Display_IE, 0, 0, 445, 430)
GUISwitch($GUI)

GUISetState(@SW_SHOW)
GUISetState(@SW_SHOW, $Display)
#EndRegion ### END Koda GUI section ###

_IENavigate($Display_IE, $IE_Home, 0); Temporary "Home Screen"

GUISwitch($GUI)


;Load Workspace
LoadStructure()


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg

        Case $GUI_EVENT_MINIMIZE
            _IENavigate($Display_IE, $IE_Home, 0)

        Case $GUI_EVENT_CLOSE
            Exit

        Case $Archives_Tab


        Case $Resources_Tab


        Case $Display_Back
            _IEAction($Display_IE, "back")

        Case $Display_Forward
            _IEAction($Display_IE, "forward")

        Case $Display_Home
            _IENavigate($Display_IE, $IE_Home, 0)

        Case $Resources_List
            MsgBox(0,"",GUICtrlRead( $Resources_List ) )

        Case $Resources_Phones[0][0]
            _IENavigate($Display_IE, $Resources_Phones[0][1], 0)

    EndSwitch
WEnd




;-------------------------------------------------
;-------------                                      U D F s
;-------------------------------------------------


Func LoadStructure( )

    ;Reference loading
    $contents = DirGetContents( $DB_Path & "reference" )
    For $i = 1 To $contents[0];Brands
        GUICtrlSetData( $Resources_List, $contents[$i] )

        $Phones = DirGetContents( $DB_Path & "reference" & $contents[$i] & "" )
        If $Phones[0] > 0 Then
            For $x=1 To $Phones[0];Phones
                $id = GetNewPhoneID( )
                $Resources_Phones[$id][0] = GUICtrlCreateListViewItem( StringReplace( $Phones[$x], ";", "|" ), $Resources_ListView )
                $Resources_Phones[$id][1] = $DB_Path & "reference" & $contents[$i] & "" & $Phones[$x] & "index.html"
            Next
        EndIf

    Next

EndFunc


Func DirGetContents( $dir )
    Local $return[2]
    $return[0] = 0
    $search = FileFindFirstFile( $dir & "*" )
    If $search = -1 Then
        FileClose( $search )
        Return $return
    EndIf

    While 1
        Local $file = FileFindNextFile($search)
        If @error Then
            FileClose( $search )
            Return $return
        EndIf

        $return[0] += 1
        ReDim $return[$return[0] + 1]
        $return[$return[0]] = $file
    WEnd
EndFunc

Func GetNewPhoneID( )
    For $i = 0 To $Max_Phones - 1
        If $Resources_Phones[$i][0] = 0 Then Return $i
    Next
    MsgBox(42,"Error","Phone array size exceded, recompile with higher $Max_Phones")
    Exit
EndFunc

And the webpage I'm trying to load with it.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
body {
    background-color: #333;
}
body,td,th {
    color: #06F;
}
</style>
</head>

<body link="#00FFFF" vlink="#00FFFF" alink="#0066FF">
<p><img src="../../../../html/images/banner.png" width="400" height="114" /></p>
<p>Cheat Sheet</p><table width="400" height="91" border="1">
  <tr>
    <td width="106" height="25">Data Editing</td>
    <td width="278"><strong>##3282#</strong></td>
  </tr>
  <tr>
    <td>Diag Mode</td>
    <td><strong>##3424#</strong></td>
  </tr>
  <tr>
    <td>Recovery Boot</td>
    <td>Vol. Down + Power</td>
  </tr>
</table>
</p>
<p>Guides</p>
<table width="400" height="89" border="1">
  <tr>
    <td width="58" height="23"><strong>Subject</strong></td>
    <td width="252"><strong>Name</strong></td>
    <td width="81"><strong>Specification</strong></td>
  </tr>
  <tr>
    <td>Flashing</td>
    <td><a href="guidestest1.png" target="_new">HTC Evo To Boost Mobile Guide</a></td>
    <td>CDMA 2.7</td>
  </tr>
</table>
<p>&nbsp;</p>
<p>Files</p>
<p><iframe src="files" width="400" height="300"></iframe> </p>
</body>
</html>

Any help would be appreciated. Also I'm attaching a link to the full project in case you want to see the buggy-ness in action.

http://www.mediafire.com/?77cs9gfogsbe3io

Edited by BillLuvsU

[center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

Share this post


Link to post
Share on other sites
DaleHohm

First,when an application stops responding it is called a hang, not a hard crash.

You should try your webbrowser work in a full browser to see if it is the same as when you have it embedded. If not, then try the alternatives to _IECreateEmbedded() in my sig (may be a good idea anyway).

If the app is hanging, you need to figure out what code is hanging. If the app is crashing, you need to provide the console error messages.

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
BillLuvsU

Hey Dale, I'm actually trying out IECreatePseudoEmbedded atm, getting weird errors when I switched it out into my script though.

>Running:(3.3.8.1):C:Program Files (x86)AutoIt3autoit3.exe "C:UsersBillDesktopAutoItGsmDBGSMdb.au3" 
--> IE.au3 V2.4-0 Error from function _IENavigate, $_IEStatus_InvalidObjectType
--> IE.au3 V2.4-0 Error from function _IEAction, $_IEStatus_InvalidObjectType
+>18:36:35 AutoIT3.exe ended.rc:0
>Exit code: 0   Time: 8.346

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <ListViewConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <Array.au3>
#include <WinAPI.au3>
#include <Constants.au3>


Const $IE_Home = @ScriptDir & "htmlhome.html"
Const $DB_Path = @ScriptDir & "db"
Const $Max_Phones = 999


Dim $Resources_Phones[$Max_Phones][2];Storage for phone info
                            ;[0] = ListViewItem ID
                            ;[1] = Index Page



$structure = DirGetContents(@ScriptDir & "")
_ArrayDisplay($structure)


#Region ### START Koda GUI section ### Form=
$GUI = GUICreate("GSMdb 0.1", 916, 481, 190, 122)

$Tab = GUICtrlCreateTab(0, 0, 465, 473)
$Resources_Tab = GUICtrlCreateTabItem("Resources")
$Resources_List = GUICtrlCreateList("", 8, 32, 121, 435)
$Resources_ListView = GUICtrlCreateListView("Name|Model|Carrier", 136, 32, 320, 433)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 75)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 75)

GUISwitch($GUI)

$Archives_Tab = GUICtrlCreateTabItem("Archives")
GUICtrlSetState(-1,$GUI_SHOW)
$Archives_List = GUICtrlCreateList("", 8, 32, 121, 435)
$Archives_ListView = GUICtrlCreateListView("Date|Number|Model|MEID", 136, 32, 320, 433)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 60)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 75)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 105)
GUICtrlCreateListViewItem ( "12/12/12|(603)789-4356|SPC6000|0xA000001F23EF3", $Archives_ListView )


GUISwitch($GUI)
GUICtrlCreateTabItem("")

;Create Display Plane
$Display_Home = GUICtrlCreateButton( "Home", 470, 3, 35, 35 )
$Display_Back = GUICtrlCreateButton( "<--", 530, 3, 35, 35 )
$Display_Forward = GUICtrlCreateButton( "-->", 570, 3, 35, 35 )
$Display = GUICreate("Resources_Display", 445, 430, 465, 40, $WS_CHILD + $WS_BORDER, -1, $GUI )
GUISetBkColor ( 0xBBBBBB )
;_IEErrorHandlerRegister()
;Local $Display_IE = _IECreateEmbedded()
;GUICtrlCreateObj($Display_IE, 0, 0, 445, 430)
$Display_IE = IECreatePseudoEmbedded(0, 0, 445, 430, $Display)
GUISwitch($GUI)

GUISetState(@SW_SHOW)
GUISetState(@SW_SHOW, $Display)
#EndRegion ### END Koda GUI section ###

_IENavigate($Display_IE, $IE_Home, 0); Temporary "Home Screen"

GUISwitch($GUI)


;Load Workspace
LoadStructure()


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg

        Case $GUI_EVENT_MINIMIZE
            _IENavigate($Display_IE, $IE_Home, 0)

        Case $GUI_EVENT_CLOSE
            _IEQuit($Display_IE)
            Exit

        Case $Archives_Tab


        Case $Resources_Tab


        Case $Display_Back
            _IEAction($Display_IE, "back")

        Case $Display_Forward
            _IEAction($Display_IE, "forward")

        Case $Display_Home
            _IENavigate($Display_IE, $IE_Home, 0)

        Case $Resources_List
            MsgBox(0,"",GUICtrlRead( $Resources_List ) )

        Case $Resources_Phones[0][0]
            _IENavigate($Display_IE, $Resources_Phones[0][1], 0)

    EndSwitch
WEnd




;-------------------------------------------------
;-------------                                      U D F s
;-------------------------------------------------


Func LoadStructure( )

    ;Reference loading
    $contents = DirGetContents( $DB_Path & "reference" )
    For $i = 1 To $contents[0];Brands
        GUICtrlSetData( $Resources_List, $contents[$i] )

        $Phones = DirGetContents( $DB_Path & "reference" & $contents[$i] & "" )
        If $Phones[0] > 0 Then
            For $x=1 To $Phones[0];Phones
                $id = GetNewPhoneID( )
                $Resources_Phones[$id][0] = GUICtrlCreateListViewItem( StringReplace( $Phones[$x], ";", "|" ), $Resources_ListView )
                $Resources_Phones[$id][1] = $DB_Path & "reference" & $contents[$i] & "" & $Phones[$x] & "index.html"
            Next
        EndIf

    Next

EndFunc


Func DirGetContents( $dir )
    Local $return[2]
    $return[0] = 0
    $search = FileFindFirstFile( $dir & "*" )
    If $search = -1 Then
        FileClose( $search )
        Return $return
    EndIf

    While 1
        Local $file = FileFindNextFile($search)
        If @error Then
            FileClose( $search )
            Return $return
        EndIf

        $return[0] += 1
        ReDim $return[$return[0] + 1]
        $return[$return[0]] = $file
    WEnd
EndFunc

Func GetNewPhoneID( )
    For $i = 0 To $Max_Phones - 1
        If $Resources_Phones[$i][0] = 0 Then Return $i
    Next
    MsgBox(42,"Error","Phone array size exceded, recompile with higher $Max_Phones")
    Exit
EndFunc








Func IECreatePseudoEmbedded($i_Left, $i_Top, $i_Width, $i_Height, $h_Parent, $f_ShowWin = False, $i_Timeout = 30000)

   Local Const $i_Random = Random(10001, 99999, 1)
   Local $i_PID, $o_IE, $h_HWND, $h_Timer = TimerInit()

   $i_PID = Run(@ProgramFilesDir & "Internet Exploreriexplore.exe -k " & "about:blank-" & $i_Random, "", @SW_HIDE)

   $f_ErrorNotify = _IEErrorNotify()
   _IEErrorNotify(False)

   While Not IsObj($o_IE)
     $o_IE = _IEAttach("about:blank-" & $i_Random, "URL")
     If TimerDiff($h_Timer) > $i_Timeout Then
        _IEErrorNotify($f_ErrorNotify)
        Return SetError(1, 0, 0)
     EndIf
     Sleep(200)
   WEnd

   _IEErrorNotify($f_ErrorNotify)

   $h_HWND = _IEPropertyGet($o_IE, "hwnd")

   _WinAPI_SetParent($h_HWND, $h_Parent)
   _WinAPI_MoveWindow($h_HWND, $i_Left, $i_Top, $i_Width, $i_Height, True)
   _WinAPI_SetWindowLong($h_HWND, $GWL_STYLE, $WS_POPUP + $WS_VISIBLE)

   If $f_ShowWin Then
     WinSetState($h_HWND, "", @SW_SHOW)
   EndIf

   Return $o_IE

EndFunc   ;==>IECreatePseudoEmbedded

Edit: I think i should mention that the first _IENavigate works fine. After that something seems to be screwing up the object but I just can't figure it out.

Edit2: Ok, this one really just confused the hell out of me. If I comment out the line:

LoadStructure()

Then the script crashes right after it loads the page. But you can see that it loads the page just fine before it decides to crash.

>Running:(3.3.8.1):C:Program Files (x86)AutoIt3autoit3.exe "C:UsersBillDesktopAutoItGsmDBGSMdb.au3" 
C:\Program Files (x86)\AutoIt3\Include\IE.au3 (314) : ==> The requested action with this object has failed.:
$o_object.navigate($s_Url)
$o_object.navigate($s_Url)^ ERROR
->18:50:21 AutoIT3.exe ended.rc:1

I need to go to work, I'll check back here when I get there.

Edited by BillLuvsU

[center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

Share this post


Link to post
Share on other sites
BillLuvsU

For reference purposes, UAC was the culprit. Added a #RequireAdmin and it works fine now.


[center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

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  

×