Exit Posted January 12, 2012 Share Posted January 12, 2012 (edited) I want to automate a speedtest to run hidden in intervalls for logging purposes. During development, I showed the browser window and all went perfect. But when I made the browser hidden, the results where wrong. It seems that the OK button was not pressed when hidden. Here is a reproducer. You'll see the difference. #include <IE.au3> _GetSpeed(1) MsgBox(262144, "", "wait 20 seconds to see next messagebox ... ", 3) _GetSpeed(0) Exit 0 Func _GetSpeed($visible = 1) Local $URL, $oIE, $handle, $string, $object, $download, $upload, $ping, $downloadtext, $uploadtext, $pingtext $URL = 'http://speedtest-1.superkabel.de/de/?kdg=1&rtaffi=n&rtlp100=n"]http://speedtest-1.superkabel.de/de/?kdg=1&rtaffi=n&rtlp100=n[/url]' $oIE = _IECreate($URL, 0, $visible) WinWait("Speedtest Kabel Deutschland", "", 10) $handle = WinGetHandle("[last]", "") Sleep(2000) $download = _IEGetObjById($oIE, "resultSpeedDl") $upload = _IEGetObjById($oIE, "resultSpeedUp") $ping = _IEGetObjById($oIE, "resultPing") $object = _IEGetObjById($oIE, "radar") _IEAction($object, "focus") ControlSend($handle, "", "[CLASSNN:Internet Explorer_Server1]", "{TAB}{Enter}") ; this loop never ends in invisible mode, therefore 15 seconds sleep ; While "N/A" = _IEPropertyGet($ping, "innertext"); ; Sleep(500) ; WEnd Sleep(15000) $downloadtext = _IEPropertyGet($download, "innertext") $uploadtext = _IEPropertyGet($upload, "innertext") $pingtext = _IEPropertyGet($ping, "innertext") $string = $downloadtext & " " & $uploadtext & " " & $pingtext & @LF ConsoleWrite(@LF & "*********** String ***********" & @LF & $string & @LF) MsgBox(262144, "", $string & @LF & "Close IE Window ? " & @LF, 0) _IEQuit($oIE) EndFunc ;==>_GetSpeed Can you help me to get the results even when browser window is hidden? TIA forumer100 Edit; Typo in URL. Edited January 21, 2012 by forumer100 App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Exit Posted January 14, 2012 Author Share Posted January 14, 2012 I found that the following statement returns 1 (sucess) when visible and 0 (failure) when hidden. ControlSend($handle, "", "[CLASSNN:Internet Explorer_Server1]", "{TAB}{Enter}") Can anybody explain why this error occurs ? TIA forumer100 App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
DaleHohm Posted January 17, 2012 Share Posted January 17, 2012 Instead of $oIE = _IECreate($URL, 0, $visible) WinWait("Speedtest Kabel Deutschland", "", 10) $handle = WinGetHandle("[last]", "") use $oIE = _IECreate($URL, 0, $visible) $handle = _IEPropertyGet($oIE, "hwnd") 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 Link to comment Share on other sites More sharing options...
Exit Posted January 17, 2012 Author Share Posted January 17, 2012 @Dalemany thanks. Works perfect. (Even as I don't know why?)Think of IE as an API... or as Dale's baby Again many thanks.Forumer100 App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
DaleHohm Posted January 18, 2012 Share Posted January 18, 2012 "hwnd" is a window handle... same as you get with WinGetHandle You could have also used $handle = WinGetHandle("Speedtest Kabel Deutschland", "") and, BTW, you shouldn't need the WinWait sine _IECreate waits until the window is created and the navigation is complete. 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 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