Sign in to follow this  
Followers 0
ivan

Assign object to existing IExplorer window

14 posts in this topic

#1 ·  Posted (edited)

This message wasn't really clear so I edited it.

I'm new to objects and I know how to solve my problem checking the PID of the active browser window and then retreiving the text on the address bar contol of that window, which works fine, but I'd really like to get a grip on the new functions of the beta version. I really don't want to be left behind with these new functions, and I think the best way to learn is to try things out... I just don't like getting stuck.

What I need is to get the object of an existing Internet Explorer window, for which I already have a corresponding handle and PID.

I am creating a little client side app that stores user intranet sessions on an e-learning site and at the end it should provide users with a report of their activity (it also stores info on open office, so that's why the app is not a server side script).

Thanks in advance

ivan

Edited by ivan

Share this post


Link to post
Share on other sites



I have a function in IE.au3 (see my sig) called _IEAttach() which allows you to get an object reference to an existing IE window based on Title, URL, text or HTML...

Dale

This message wasn't really clear so I edited it.

I'm new to objects and I know how to solve my problem checking the PID of the active browser window and then retreiving the text on the address bar contol of that window, which works fine, but I'd really like to get a grip on the new functions of the beta version. I really don't want to be left behind with these new functions, and I think the best way to learn is to try things out... I just don't like getting stuck.

What I need is to get the object of an existing Internet Explorer window, for which I already have a corresponding handle and PID.

I am creating a little client side app that stores user intranet sessions on an e-learning site and at the end it should provide users with a report of their activity (it also stores info on open office, so that's why the app is not a server side script).

Thanks in advance

ivan


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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks dale.

I downloaded your udf, it looks great. I have also checked the _IEGetProperty function and I want to use _IEAttach in conjunction like so:

$oBrowser=_IEAttach($UrlHandle, "url")

$PropAddress=_IEGetProperty($oBrowser, "addressbar")

where $UrlHandle is a valid URL

However $PropAddress holds a -1 value indicating that there is an error, instead of the text held in the address bar. Am I getting it all wrong?

Thanks again

Edited by ivan

Share this post


Link to post
Share on other sites

Sorry, AddressBar is a property representing whether the ddressbar is displayed or not, not the value of the URL (documentation... someday).

If the attach was successful, the current URL would be $oBrowser.document.location

There are SO MANY properties for the DOM I don't expect to implement all of them... MSDN documents them all however...

Dale

Thanks dale.

I downloaded your udf, it looks great. I have also checked the _IEGetProperty function and I want to use _IEAttach in conjunction like so:

$oBrowser=_IEAttach($UrlHandle, "url")

$PropAddress=_IEGetProperty($oBrowser, "addressbar")

where $UrlHandle is a valid URL

However $PropAddress holds a -1 value indicating that there is an error, instead of the text held in the address bar. Am I getting it all wrong?

Thanks again


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

Share this post


Link to post
Share on other sites

You star!

I hadn't realized these functions actually referred to the document object. It's been a while since I last looked at the DOM and the one I have must be out of date. I'll download it rightaway and see what else i can do with your udf.

By the way, I think you've done an excellent job. I've been asking about documentation of non standard udf libraries, but it seems they are spread accross the forums. Yours is definitely going in my includde directory which is a real mess now, between standard and non standard udfs, besides the ones i've been trying to develop.

I started indexing and documenting the udfs i use regularly and i'll throw a note on yours. If and when I believe it's complete and worth sharing, I'll pm you a copy. At the moment it's just a set of notes on what they do but little is kept on examples for use.

Share this post


Link to post
Share on other sites

By the way, can you please give me a hint on how to get the object of a specific browser window identified either by a window handle or a PID.

This is just in case more than one browser window is open. What I do is list the processes, retreive the pids and match the window handles.

_IEAttach will retreive the object reference to the first browser window with matching url, but not all of them, if they happen to exist.

I'm sorry for being such a drag.

Thanks again

Share this post


Link to post
Share on other sites

Asking the question the way that you did made me realize that there is a simple answer to this. I'll have it in the next release, but if you want it now you can add the following case criteria to _IEAttach in T1.4 You then be able to use _IEAttach( $hMyHandle, "hwnd") to get a reference to an existing window by handle. A modified version of this will appear in the next release.

Case $s_mode = "hwnd"
    If _IEGetProperty($o_window, "hwnd") = String( $s_string) Then
            SetError(0)
            Return $o_window
    EndIf

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

Share this post


Link to post
Share on other sites

Thanks for your reply Dale.

I couldn't reply on Saturday because my Internet account got cut off, sorry.

I hope my question phrasing didn't sound rude and if it did I appologise. The last thing I want is to offend anyone in the forum, let alone people who make such great tools like you, and who out of their own will provide help to others like me.

Thanks.

IVAN

Share this post


Link to post
Share on other sites

Absolutely no offense. I meant I had been asked that question before in a more complicated from. I realized when reading your question that there was a simple way to address the issue (although it does not address modal dialogs that do not appear in the shell window collection).

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

Share this post


Link to post
Share on other sites

Asking the question the way that you did made me realize that there is a simple answer to this. I'll have it in the next release, but if you want it now you can add the following case criteria to _IEAttach in T1.4 You then be able to use _IEAttach( $hMyHandle, "hwnd") to get a reference to an existing window by handle. A modified version of this will appear in the next release.

Case $s_mode = "hwnd"
    If _IEGetProperty($o_window, "hwnd") = String( $s_string) Then
            SetError(0)
            Return $o_window
    EndIf

Dale

As per usual, I spend as much time as it takes to suss something out before bothering anyone with questions, but this time I feel rather useless. I hope it's only my mistake and not that the modification is not creating the object reference.

I ammended _IEAttach in T1.4 as you suggested. Literally, I added:

Case $s_mode = "hwnd"
    If _IEGetProperty($o_window, "hwnd") = String( $s_string) Then
            SetError(0)
            Return $o_window
    EndIf

just before the case else statement in _IEAttach. I am also using Autoit v3.1.1.87.

However, in my code when I do

$oBrowser=_IEAttach($WinHandle, "hwnd")
if not isobj($oBrowser) then
msgbox(0, "DebugMe", "please, please go away")
endif

I get the damn message box, implying it's not an object.

Am I doing something wrong?

I'd really appreciate it if any of you guys in the know can give me a hand.

Cheers.

IVAN

Share this post


Link to post
Share on other sites

Where are you getting $WinHandle ?? It needs to be the handle of an IE Browser window that you have obtained with the AutoIt WinGetHandle function.

Dale

However, in my code when I do

$oBrowser=_IEAttach($WinHandle, "hwnd")
if not isobj($oBrowser) then
msgbox(0, "DebugMe", "please, please go away")
endif

I get the damn message box, implying it's not an object.

Am I doing something wrong?

I'd really appreciate it if any of you guys in the know can give me a hand.

Cheers.

IVAN


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

Share this post


Link to post
Share on other sites

It works fine on a simple test like this

; I open a page http://localhost/test.php first

; then I run my script which has the line of code

$WinHandle=WinGetHandle ( "test - Microsoft Internet Explorer")

But when I use it within my code, I don't get the corresponding object. I'll try it again tonight, and I hope I'll find the problem, which I am sure must have something to do with my code.

If I find the solution, I'll post it below. You have been really helpful and I really appreciate it.

Thanks

IVAN

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

I had been coding for a few days and didn't bother to restart my computer, that's all. It works absolutely fine, I've tested it about 100 times in different parts of my code, different machines and no problem whatsoever. Sometimes it's best to take things easy.

Again Dale, thanks for all your help and support. If you ever happen to come to Ecuador I´ll buy a beer and show you around.

Edited by ivan

Share this post


Link to post
Share on other sites

Glad it's working. I'll file that Ecuador invite away for future reference - thanks :-)


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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0