fhanna Posted February 10, 2009 Share Posted February 10, 2009 I am having problems reading the text from an IE window. I receive a 0 error return on the attachment but text is not returned; 0. Text is there, displayed and I can right click on the window and display the source. The following is an extract from the code with a couple of pauses. Could someone provide assistance? Thank You. sleep(5000) #include <IE.au3> $oIE = _IEAttach("") sleep(5000) msgbox(0,"",@error) $Text = _IEBodyReadText($oIE) msgbox(0,'',$Text) Link to comment Share on other sites More sharing options...
KaFu Posted February 10, 2009 Share Posted February 10, 2009 You have to identify the instance of IE to attach to. If you've got only one open use #include <IE.au3> $oIE = _IEAttach ("", "instance", 1) $Text = _IEBodyReadText($oIE) msgbox(0,'',$Text) otherwise read _IEAttach() help to identify Browser, maybe winlist() will help you too... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
fhanna Posted February 12, 2009 Author Share Posted February 12, 2009 Thank you for your reponse and that did work. However, and after reading the _IEAttach documentation I am still having problems accomplishing what I want. I woudl not know what instance of a brower I want to attach to. I need to read the source of the currently displayed browser window that has focus. Simply utilizing the _IEReadBodyText does not return the source so attempted via an _IEAttach to the current window. How do I retrieve the text from the currently displayed window. I have discovered utilizing a part of the wildow title will retrieve it but most titles have the url as the window title and will not work. Long story short. Request assistance in retrieving text from currently displayed window without reference to the title or instance. Thanks again. Link to comment Share on other sites More sharing options...
DaleHohm Posted February 12, 2009 Share Posted February 12, 2009 You can use WinGetHandle("[active]") to get the handle of the active window, then pass that to _IEAttach() 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...
fhanna Posted February 18, 2009 Author Share Posted February 18, 2009 Thank you for your input. I still cannot get the text. I have tried the WinGetHandle then Attach with the same results. I have tried a _IEPropertyGet for the url and will not return. If using a partial win title (if the http address is not the title) I can retrieve the text as with the instance. If using the current window to attach to I receive a 0 @error on the attach but a 3 for the _IEBodyReadText. Please advise and thank you. Link to comment Share on other sites More sharing options...
DaleHohm Posted February 18, 2009 Share Posted February 18, 2009 You'll want to run your code from SciTe, at least when you are testing with IE.au3 -- a lot of diagnostics written to the console. the 3 is $_IEStatus_InvalidDataType which means the first parameter passed is not an object. 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...
fhanna Posted February 18, 2009 Author Share Posted February 18, 2009 I'm really stumped!!! To keep it simple I created a simple .html page with the text: This is a test Opended with IE and ran the following: sleep(5000) #include <ie.au3> $oIE = _ieattach("") sleep(2000) $text = _iebodyreadtext($oie) msgbox(0,"",$text) and received the following: >"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Temp\test.au3" --> IE.au3 V2.4-0 Warning from function _IEAttach, $_IEStatus_NoMatch --> IE.au3 V2.4-0 Error from function _IEBodyReadText, $_IEStatus_InvalidDataType >Exit code: 0 Time: 8.601 I have also tried with wingethandle Thanks again. Link to comment Share on other sites More sharing options...
Envoi Posted February 18, 2009 Share Posted February 18, 2009 I'm really stumped!!! To keep it simple I created a simple .html page with the text: This is a testOpended with IE and ran the following:sleep(5000)#include <ie.au3>$oIE = _ieattach("")sleep(2000)$text = _iebodyreadtext($oie)msgbox(0,"",$text)and received the following:>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Temp\test.au3" --> IE.au3 V2.4-0 Warning from function _IEAttach, $_IEStatus_NoMatch--> IE.au3 V2.4-0 Error from function _IEBodyReadText, $_IEStatus_InvalidDataType>Exit code: 0 Time: 8.601...How simple is this test page? Did you at least put <body> tags in it? If not, _IEBodyReadText will have no tag to get the .innertext from. Link to comment Share on other sites More sharing options...
DaleHohm Posted February 18, 2009 Share Posted February 18, 2009 What makes you think you should pass "" to _IEAttach? 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...
fhanna Posted February 18, 2009 Author Share Posted February 18, 2009 I appreciate yo sticking with me on this. It is my assumption (good or bad) that a null "" would represent the currently focused window. I have used this quite extensively in my application and appears to work fine; maybe just luck. When a 0 @error return code is received the reason for this assumption. When trying the wingethandle I get exactly the same results. I will be happy with any coding that will attach to the currently focused window without knowing the instance or other info. Is this possible and/or am I taking the right approach? Thank you again. Fred Link to comment Share on other sites More sharing options...
fhanna Posted February 18, 2009 Author Share Posted February 18, 2009 I appreciate yo sticking with me on this. It is my assumption (good or bad) that a null "" would represent the currently focused window. I have used this quite extensively in my application and appears to work fine; maybe just luck. When a 0 @error return code is received the reason for this assumption. When trying the wingethandle I get exactly the same results. I will be happy with any coding that will attach to the currently focused window without knowing the instance or other info. Is this possible and/or am I taking the right approach? Thank you again. Fred BTW: Is this the correct code for the wingethandle and attach? $handle = wingethandle("[active]") $oie = _ieattach($handle) In both cases 0 is returned for @error Link to comment Share on other sites More sharing options...
KaFu Posted February 18, 2009 Share Posted February 18, 2009 Read Help-File: _IEAttach ( $s_string [, $s_mode = "Title" [, $i_instance = 1]] ) Thus $handle = wingethandle("[ACTIVE]") $oie = _ieattach($handle, "HWND") would be correct (without testing). OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
fhanna Posted February 19, 2009 Author Share Posted February 19, 2009 Thank you both, Dale and Kafu. Dale was correct and KaFu confirmed my error. I honestly do read the documentation but without an exact sample can be confusing for me. Again, I want to thank both of you and I will use the WinGetHandle routine. Fred 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