Sign in to follow this  
Followers 0
AcidCorps

Script freezing at _IEBodyReadHtml

3 posts in this topic

I'm working on the following script:

#include <GUIConstants.au3>
#include <EzSkin.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <ProgressConstants.au3>
#include <File.au3>
#include <IE.au3>
#include <INet.au3>


$IniEmail = IniRead('User.dat', 'User', 'EMail', '')
$IniPassword = IniRead('User.dat', 'User', 'Pass', '')

;Creating GUI + Title Bar
$ExitButtonIcon = @ScriptDir & '\EzSkin\Standard1.bmp'
$MinButtonIcon = @ScriptDir & '\EzSkin\Standard2.bmp'
$EzGUI = EzSkinGUICreate('', 400, 200)
GUICtrlCreateLabel('LacWare - Myspace Hidden Section Disabler', 25, 7, 300, 15)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Exit = GUICtrlCreateButton('X', 366, 7, 13, 13, $BS_BITMAP)
GUICtrlSetImage(-1, $ExitButtonIcon)
$Minimize = GUICtrlCreateButton('_', 353, 7, 13, 13, $BS_BITMAP)
GUICtrlSetImage(-1, $MinButtonIcon)

;Creating Controls
GUICtrlCreateLabel('Profile to show sections:', 25, 25, 115, 15)
$GProfile = GUICtrlCreateInput('www.myspace.com/LacWare', 145, 25, 230, 15)
GUICtrlCreateLabel('Your Email (for private profiles):', 25, 45, 145, 15)
$GEmail = GUICtrlCreateInput($IniEmail, 175, 45, 200, 15)
GUICtrlCreateLabel('Your Password:', 95, 65, 75, 15)
$GPassword = GUICtrlCreateInput($IniPassword, 175, 65, 200, 15, $ES_PASSWORD)
$GRememberMe = GUICtrlCreateCheckbox('Remember Me', 90, 90, 85, 15)
$GRememberPass = GUICtrlCreateCheckbox('Remember Password', 190, 90, 120, 15)
$DisableSections = EzSkinButton('Disable Sections', 140, 120, 120, 15)

;Creating Progress
Global $ProgressBar = GUICtrlCreateProgress(25, 155, 350, 20, $PBS_SMOOTH)
Global $ProgressLabel = GUICtrlCreateLabel('', 25, 155, 350, 20, $SS_CENTER)
GUICtrlSetFont(-1, 13, 650)
GUICtrlSetColor(-1, 0xA52A2A)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUISetState()

;Loop GUI
While 1
    EzSkinOver()
    $msg = GUIGetMsg()
    Select
        Case $msg = $Exit
            Exit
        Case $msg = $Minimize
            GUISetState(@SW_MINIMIZE)
        Case $msg = $DisableSections
            _SetProgress(0, 'Reading GUI controls')
            $Profile = GUICtrlRead($GProfile)
            $Email = GUICtrlRead($GEmail)
            $Password = GUICtrlRead($GPassword)
            $RememberMe = GUICtrlRead($GRememberMe)
            $RememberPass = GUICtrlRead($GRememberPass)
            If GuiCtrlRead($GRememberMe) = $GUI_CHECKED Then IniWrite('User.dat', 'User', 'EMail', $Email)
            If GuiCtrlRead($GRememberPass) = $GUI_CHECKED Then IniWrite('User.dat', 'User', 'Pass', $Password)
            _SetProgress(2, 'Naming temporary file for output')
            $Temp = _TempFile(@TempDir, '~mhsd', '.html', Random(10, 15, 1))
            If Not StringInStr($Profile, 'myspace') Then _SetProgress(0, 'Error: Invalid myspace URL')
            _SetProgress(25, 'Reading ' & $Profile)
            $oIE = _IECreate($Profile, 0, 1)
            $oBody = _IEBodyReadText($oIE)
            If StringInStr($oBody, 'This profile is set to private. This user must add you as a friend to see his/her profile.') Then
                _SetProgress(35, 'Private profile... logging in to myspace')
                _IENavigate($oIE, 'www.myspace.com')
                If StringInStr($oBody, 'You are logged in.') Then
                    _SetProgress(0, 'Error: You must add this user to see his/her profile')
                Else
                    If $Email = '' Or $Password = '' Then
                        _SetProgress(0, 'Error: Private profile, please provide user data')
                    Else
                        $oForm = _IEFormGetCollection($oIE, 1)
                        $oUser = _IEFormElementGetCollection($oForm, 2)
                        $oPass = _IEFormElementGetCollection($oForm, 3)
                        $oSubmit = _IEFormElementGetCollection($oForm, 4)
                        _IEFormElementSetValue($oUser, $Email)
                        _IEFormElementSetValue($oPass, $Password)
                        _IEFormSubmit($oForm)
                        _IELoadWait($oIE)
                        _IENavigate($oIE, $Profile)
                        _SetProgress(50, 'Reading ' & $Profile & ' html')
                        $oBody = _IEBodyReadHTML($oIE)
                    EndIf
                EndIf
            Else
            _SetProgress(50, 'Reading ' & $Profile & ' html')
            $oBody = _IEBodyReadHTML($oIE)
            $oBody = StringReplace($oBody, 'display:none', 'display:inline')
            _SetProgress(70, 'Writing temporary file')
            $Html = $oBody
            FileWrite($Temp, $Html)
            _SetProgress(90, 'Opening temporary file in default browser')
            If StringInStr($Temp, ' ') Then
                Run(@ComSpec & ' /c start "' & $Temp & '"')
            Else
                Run(@ComSpec & ' /c start ' & $Temp)
            EndIf
            _SetProgress(100, 'All done...')
            EndIf
        EndSelect
WEnd


Func _SetProgress($iPercent, $iText = Default)
    GUICtrlSetData($ProgressBar, $iPercent)
    If $iText <> Default Then GUICtrlSetData($ProgressLabel, $iText)
EndFunc   ;==>_SetProgressoÝ÷ Ù8^±Êâ¦Ø¬i¸­nè ÊËbV§vwvËhmç%y©ÞvêZ+mæî¶Ø^¦ºé¢ßÙ¡jø§¸ ÙèÂ+-«péⶭ²ÚºÚ"µÍBBWÔÙ]ÙÜÜÊ
L   ÌÎNÔXY[È    ÌÎNÈ [È ÌÍÔÙ[[È ÌÎNÈ[    ÌÎNÊBBBIÌÍÛÐÙHHÒQPÙTXYS
    ÌÍÛÒQJBBBIÌÍÛÐÙHHÝ[ÔXÙJ ÌÍÛÐÙK ÌÎNÙÜ^NÛIÌÎNË   ÌÎNÙÜ^N[[IÌÎNÊ

it completely freezes up no matter what i do, i also tried (just for the hell of it) using _INetGetSource, and it still froze there. any ideas?

Share this post


Link to post
Share on other sites



Can' think of a good reason for a hang... _IEBodyReadHTML actually performas a pretty simple function:

Return $o_object.document.body.innerHTML

Throw an error? perhaps Hang? I wouldn't expect it

Suggest you add _IEErrorHandlerRegister() to your script and also SciTe Debug Mode (see my sig) so you can see more about what is really happening.

If that doen's do it, see if you can create a reproducer.

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

I rewrote the script using that as an example, got it really cleaned up and it worked like a charm, can't figure out why that was happening but it's not now so all is good, thank you for your response though

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