Jump to content
Sign in to follow this  
kizsdet

need help with IE.au3 function and GUI

Recommended Posts

kizsdet

#include <IE.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>


$Form1 = GUICreate("Form1", 255, 181, 192, 124)
$Input1 = GUICtrlCreateInput("", 32, 24, 177, 21)
$Input2 = GUICtrlCreateInput("", 32, 56, 177, 21)
$button1 = GUICtrlCreateButton("test", 20, 100, 40, 20)
GUISetState(@SW_SHOW)

While 1
    $aMsg = GUIGetMsg(1) ; Use advanced parameter to get array
    Switch $aMsg[1] ; check which GUI sent the message
        Case $Form1
            Switch $aMsg[0] ; Now check for the messages for $gui1
                Case $GUI_EVENT_CLOSE
                    ExitLoop
                Case $button1
                    $oIE = _IE_Example ("basic")
                    $oDiv = _IEGetObjById ($oIE, "line1")
                    ControlSetText("Form1", "", "Edit1", _IEPropertyGet($oDiv, "innertext"))
                EndSwitch

    EndSwitch
WEnd

this code displays a gui then when i press the button it will load the page and get the value and set it to the gui.

but why my button get hung when i close the IE page while loading is not yet done.

how can i handle this error? need help..thanks in advance..

Share this post


Link to post
Share on other sites
PsaltyDS

Of course you are not using _IE_Example() in real time, which loads too fast for this to be an issue.

Probably your actual script is hung in _IELoadWait() which is called internally by things like _IECreate() unless you set $f_wait = 0. The default timeout is like five minutes, which is not really hung but seems like it.

:mellow:

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
kizsdet

thanks for the reply. but what if i embedded the page in the gui..just like what we have in the help file..is there a way to forcibly close the gui without the page being loaded completely? i tried to stop it first by using IEAction 'stop' and use the _IEQuit but it doesnt seem to work..

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

_IEErrorHandlerRegister ()

$oIE = _IECreateEmbedded ()
GUICreate("Embedded Web control Test", 640, 580, _
        (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _
        $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
$GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 600, 360)
$GUI_Button_Back = GUICtrlCreateButton("Back", 10, 420, 100, 30)
$GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 420, 100, 30)
$GUI_Button_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30)
$GUI_Button_Stop = GUICtrlCreateButton("Stop", 340, 420, 100, 30)

GUISetState()       ;Show GUI

_IENavigate ($oIE, "http://www.autoitscript.com")

; Waiting for user to close the window
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GUI_Button_Home
            _IENavigate ($oIE, "http://www.autoitscript.com")
        Case $msg = $GUI_Button_Back
            _IEAction ($oIE, "back")
        Case $msg = $GUI_Button_Forward
            _IEAction ($oIE, "forward")
        Case $msg = $GUI_Button_Stop
            _IEAction ($oIE, "stop")
    EndSelect
WEnd

GUIDelete()

Exit

Share this post


Link to post
Share on other sites
Thatsgreat2345

Well you have a few ways, you can either write/copy _IELoadWait and make it check if the close button has been hit which I don't really recommend, or find a way to use GUIRegisterMsg to grab the event went the close button is pressed. I know it is possible but as I didn't write the code to do this I'm not at liberty to post it.

I also am questioning why you exitloop, then do a guidelete then exit. I fail to see why you don't just exit.

Edit:

http://www.autoitscript.com/forum/index.php?showtopic=55759

Zedna showed the exact way here of how to check if exit was pressed.

He has SC_CLOSE just returning, but just pop an exit there and it should all work regardless of a website navigating.

Edited by Thatsgreat2345

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  

×