kizsdet Posted June 10, 2010 Share Posted June 10, 2010 #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.. Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 10, 2010 Share Posted June 10, 2010 (edited) 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. Edited June 10, 2010 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 Link to comment Share on other sites More sharing options...
kizsdet Posted June 12, 2010 Author Share Posted June 12, 2010 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.. expandcollapse popup#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 Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted June 12, 2010 Share Posted June 12, 2010 (edited) 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 June 12, 2010 by Thatsgreat2345 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now