musahi0128 Posted December 2, 2013 Posted December 2, 2013 Ok, I have a html file with content below stored in C:: <html> <a href="file:///C:/loop-it.htm" target="_blank">Loop opening this page</a> </html> I then create a script bellow : #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> #NoTrayIcon Opt("GUIOnEventMode", 1) Global $url = "file:///C:/loop-it.htm" $oIE = _IECreateEmbedded() GUICreate("Embedded Web control Test", 769, 513, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "_CLOSEClicked") GUICtrlCreateObj($oIE, 0, 0, 768, 457) ObjEvent($oIE, "IEEvent_", "DWebBrowserEvents2") _IENavigate($oIE, $url) GUISetState(@SW_SHOW) Func _IEEvent_NewWindow3() MsgBox(0, "", "NewWindow2") EndFunc Func _CLOSEClicked() exit EndFunc While 1 Sleep(500) WEnd When i click the link, THE SCRIPT CRASHED. I'm new to AutoIt, I already read the help file but i can't find the answer. Please help with this!!!
LarsJ Posted December 2, 2013 Posted December 2, 2013 Are you sure that DWebBrowserEvents2 is supported? Have you tried with DWebBrowserEvents? Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions
musahi0128 Posted December 2, 2013 Author Posted December 2, 2013 (edited) Yes i have. I use DWebBrowserEvents2 to to create a function that enable / disable button in case the page not loaded: Global $NavError = 0 Func IEEvent_NavigateError($pdisp, $url, $tf, $status, $cancel) Global $NavError = 1 EndFunc Func _NavErrorHandle() If $NavError = 1 then GUICtrlSetState($HidenBtn, $GUI_SHOW) Else _PageGetFormObj() _PageFillForm() _BtnEnable() EndIf EndFunc I can't get the _NavErrorHandle() to work unless i use DWebBrowserEvents2. When I use DWebBrowserEvents, i can't get correct $NavError value because the event is not listed here and supported. Here is the project i working on : expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <IE.au3> #NoTrayIcon #Region 0 Opt("GUIOnEventMode", 1) $Form0 = GUICreate("Indonesia Wifi - @wifi.id Login Automation", 769, 533, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "_CLOSEClicked") $oIE = _IECreateEmbedded() $EmbedPage0 = GUICtrlCreateObj($oIE, 0, 0, 768, 457) ObjEvent($oIE, "IEEvent_", "DWebBrowserEvents2") $SpeedyAccountBtn = GUICtrlCreateButton("Change Account", 456, 464, 144, 42) GUICtrlSetFont(-1, 9, 800, 0, "Verdana") GUICtrlSetState($SpeedyAccountBtn, $GUI_DISABLE) GUICtrlSetOnEvent($SpeedyAccountBtn, "_NoSpeedyBtn") $SubmitBtn = GUICtrlCreateButton("Submit", 616, 464, 144, 42) GUICtrlSetFont(-1, 9, 800, 0, "Verdana") GUICtrlSetState($SubmitBtn, $GUI_DISABLE) GUICtrlSetOnEvent($SubmitBtn, "_SubmitBtn") $HidenBtn = GUICtrlCreateButton("Try Again", 456, 464, 144, 42) GUICtrlSetFont(-1, 9, 800, 0, "Verdana") GUICtrlSetState($HidenBtn, $GUI_HIDE) GUICtrlSetOnEvent($HidenBtn, "_HidenBtn") $Label0 = GUICtrlCreateLabel("INDONESIA WIFI - @wifi.id Login Automation 1.0", 8, 464, 432, 22) & GUICtrlSetFont(-1, 12, 800, 0, "Verdana") $Label1 = GUICtrlCreateLabel("By musahi0128", 8, 488, 180, 17) GUISetState(@SW_SHOW) #EndRegion 0 Global $url = "file:///C:/loop-it.htm" ;Global $url = "http://welcome.indonesiawifi.net/wifi.id/speedy/?switch_url=http://1.1.1.1/login.html" Global $file = FileOpenDialog("Select file for account information", @MyDocumentsDir, "All types (*)", 1 + 2) Global $NavError = 0 _Start() #Region 1 Func _Start() _NoSpeedy() _IENavigate($oIE, $url) _NavErrorHandle() EndFunc Func IEEvent_NavigateError($pdisp, $url, $tf, $status, $cancel) Global $NavError = 1 EndFunc Func _NavErrorHandle() If $NavError = 1 then GUICtrlSetState($HidenBtn, $GUI_SHOW) Else _PageGetFormObj() _PageFillForm() _BtnEnable() EndIf EndFunc Func _PageGetFormObj() Global $oQuery = _IEGetObjByName($oIE, "username") Global $oQueryPass = _IEGetObjByName($oIE, "password") Global $oSubmit = _IEGetObjByName($oIE, "Submit") EndFunc Func _PageFillForm() _IEAction($oQuery, "focus") _IEFormElementSetValue($oQuery, $noSpeedy) _IEFormElementSetValue($oQueryPass, "123") EndFunc Func _PageSubmitForm() _IEAction($oSubmit, "focus") _IEAction($oSubmit, "click") EndFunc Func _NoSpeedy() Local $fileOpen = FileOpen($file, 0) $lineRead = FileReadLine($fileOpen) $lineRead = $lineRead + "@telkom.net" FileClose($fileOpen) Local $fileOpen = FileOpen($file, 1) FileWriteLine($fileOpen, $lineRead) FileClose($fileOpen) _FileWriteToLine($file, 1, "", 1) Global $noSpeedy = $lineRead EndFunc Func _NoSpeedyBtn() _NoSpeedy() _PageGetFormObj() _PageFillForm() EndFunc Func _SubmitBtn() _PageGetFormObj() _PageSubmitForm() EndFunc Func _HidenBtn() GUICtrlSetState($HidenBtn, $GUI_HIDE) _Start() EndFunc Func _BtnEnable() GUICtrlSetState($SpeedyAccountBtn, $GUI_ENABLE) GUICtrlSetState($SubmitBtn, $GUI_ENABLE) EndFunc Func _CLOSEClicked() exit EndFunc #EndRegion 1 While 1 Sleep(500) WEnd Any idea?? Edited December 2, 2013 by musahi0128
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