JohnBailey Posted October 5, 2007 Posted October 5, 2007 Anyone know why the following script does not update the LV and show an accurate Progress expandcollapse popup#include <GUIConstants.au3> #include <GuiListView.au3> Global $LVTOWATCH Opt("GUIOnEventMode", 1) Opt("TrayIconDebug",1) $ParentWin = GUICreate("IE Object Info", 885, 516, 193, 125) $LV_Main = GUICtrlCreateListView("URL|Interface Name|Description|ProgID|DLL|Filename of Toolbox|Visible", 20, 18, 839, 286) GUICtrlSendMsg(-1, 0x101E, 0, 160) GUICtrlSendMsg(-1, 0x101E, 1, 200) GUICtrlSendMsg(-1, 0x101E, 2, 125) GUICtrlSendMsg(-1, 0x101E, 3, 75) GUICtrlSendMsg(-1, 0x101E, 4, 75) GUICtrlSendMsg(-1, 0x101E, 5, 150) GUICtrlSendMsg(-1, 0x101E, 6, 50) $LaunchNewIE = GUICtrlCreateButton("Launch", 135, 465, 114, 25, 0) $url_IN = GUICtrlCreateInput("http:\\www.google.com", 259, 466, 502, 21) $CloseBTN = GUICtrlCreateButton("Close", 783, 308, 75, 25, 0) $Radio1 = GUICtrlCreateRadio("Show", 715, 313, 55, 17) $Radio2 = GUICtrlCreateRadio("Hide", 655, 313, 52, 17) GUISetState(@SW_SHOW) $LVTOWATCH=$LV_Main GUISetOnEvent($GUI_EVENT_CLOSE,'_GUIEvents') GUICtrlSetOnEvent($LaunchNewIE,'Button') While 1 Sleep(100) WEnd Global $percent,$wait Func Button() Switch @GUI_CtrlId Case $LaunchNewIE $oInternet = ObjCreate("InternetExplorer.Application") $oInternet.Navigate(GUICtrlRead($url_IN)); Opening a web page that contains a form $oInternet.visible = 1 $wait=0 ProgressOn(GUICtrlRead($url_IN), "Loading page...") $SinkObject=ObjEvent($oInternet,"IEEvent_","DWebBrowserEvents2"); Assign events to UDFs While $wait=0 Sleep(10) WEnd GUICtrlCreateListViewItem(GUICtrlRead($url_IN)&'|'& _ ObjName($oInternet) &'|'& _ ObjName($oInternet,2)&'|'& _ ObjName($oInternet,3)&'|'& _ ObjName($oInternet,4)&'|'& _ ObjName($oInternet,5)&'|'& _ 1, _ $LV_Main _ ) ;=====end EndSwitch EndFunc Func IEEvent_ProgressChange($Progress,$ProgressMax) $percent = Int( ($Progress * 100) / $ProgressMax ) If $percent >= 0 And $percent <= 100 Then ProgressSet ( $percent , $percent & " percent to go." , "loading web page" ) Else $wait=1 ProgressOff() EndIf EndFunc Func _GUIEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE Terminate() EndSelect EndFunc ;==>_GUIEvents Func OnAutoItExit() ConsoleWrite('CLOSED via Exit'&@CRLF) EndFunc Func Terminate() ConsoleWrite('CLOSED via Terminate'&@CRLF) Exit EndFunc A decision is a powerful thing
JBeef Posted October 5, 2007 Posted October 5, 2007 ObjEvent wrong? IEEvent_ vs IEEvent_ProgressChange ~Jap
JohnBailey Posted October 5, 2007 Author Posted October 5, 2007 ObjEvent wrong? IEEvent_ vs IEEvent_ProgressChange ~JapWOW! thanks I didn't even see that! I thought I copied and pasted that directly from the help. Goodness thank you A decision is a powerful thing
JohnBailey Posted October 5, 2007 Author Posted October 5, 2007 ObjEvent wrong? IEEvent_ vs IEEvent_ProgressChange ~Jap Actually, the help file is working great ProgressOn("Example", "Loading page...") $oIE=ObjCreate("InternetExplorer.Application.1") ; Create Internet Explorer application $SinkObject=ObjEvent($oIE,"IEEvent_","DWebBrowserEvents2"); Assign events to UDFs starting with IEEvent_ ; Do some browsing activities $oIE.Visible=1 ;$oIE.RegisterAsDropTarget = 1 ;$oIE.RegisterAsBrowser = 1 $oIE.Navigate( "http://www.AutoItScript.com/" ) Global $wait = 1 While $wait = 1 Sleep(10) WEnd ;sleep(3000) ; Give it time to load the web page $SinkObject=0 ; Stop IE Events $oIE.Quit ; Quit IE $oIE=0 exit ; one of many Internet Explorer Event Functions Func IEEvent_ProgressChange($Progress,$ProgressMax) $percent = Int( ($Progress * 100) / $ProgressMax ) If $percent >= 0 And $percent <= 100 Then ProgressSet ( $percent , $percent & " percent to go." , "loading web page" ) Else $wait=0 EndIf EndFunc So why is my code wrong? A decision is a powerful thing
JohnBailey Posted October 5, 2007 Author Posted October 5, 2007 the following works: expandcollapse popupFunc Button() Switch @GUI_CtrlId Case $LaunchNewIE Global $wait=1 ProgressOn(GUICtrlRead($url_IN), "Loading page...") $oInternet=ObjCreate("InternetExplorer.Application.1") ; Create Internet Explorer application $SinkObject=ObjEvent($oInternet,"IEEvent_","DWebBrowserEvents2"); Assign events to UDFs starting with IEEvent_ $oInternet.visible = 1 $oInternet.Navigate(GUICtrlRead($url_IN)); Opening a web page that contains a form While $wait=1 Sleep(50) WEnd GUICtrlCreateListViewItem(GUICtrlRead($url_IN)&'|'& _ ObjName($oInternet) &'|'& _ ObjName($oInternet,2)&'|'& _ ObjName($oInternet,3)&'|'& _ ObjName($oInternet,4)&'|'& _ ObjName($oInternet,5)&'|'& _ 1, _ $LV_Main _ ) ;=====end $IEArray[Ubound($IEArray)-1]=$oInternet ReDim $IEArray[Ubound($IEArray)+1] Case $CloseBTN Local $currentIndex = _GUICtrlListViewGetCurSel($LV_Main) $IEArray[$currentIndex].Quit() _GUICtrlListViewDeleteItem($LV_Main,$currentIndex) GUiCtrlSetState($Radio1,$GUI_UNCHECKED) GUiCtrlSetState($Radio2,$GUI_UNCHECKED) Case $Radio1 Local $currentIndex = _GUICtrlListViewGetCurSel($LV_Main) $IEArray[$currentIndex].Visible=1 Case $Radio2 Local $currentIndex = _GUICtrlListViewGetCurSel($LV_Main) $IEArray[$currentIndex].Visible=0 EndSwitch EndFunc Func IEEvent_ProgressChange($Progress,$ProgressMax) $percent = Int( ($Progress * 100) / $ProgressMax ) If $percent >= 0 And $percent <= 100 Then ProgressSet ( $percent , $percent & " percent to go." , "loading web page" ) Else $wait=0 ProgressOff() EndIf EndFunc A decision is a powerful thing
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