Jump to content
Sign in to follow this  
Dudinin

How to get object variable of opened window?..

Recommended Posts

Dudinin

Hi guys! Please help :)! I need to fill forms on IE-window which opened by click by link. Well, to fill form "form" on http://somesite.some I can use this script:

#include <IE.au3>
$oIE = _IECreate ("http://somesite.some")
$oForm = _IEFormGetCollection ($oIE, 1)
_IEFormElementSetValue (_IEFormElementGetObjByName($oForm, "form"), "Form")

But how can I fill form on window opened by _IELinkClickByText ($oIE, "text_OF_link", 0, 1)? I need to know object variable of this window... The example of the script I want:

#include <IE.au3>
_IECreate ("http://somesite.some")
_IELinkClickByText ($oIE, "link_text", 0, 1)
$oIE = <object variable of opened window from link "link_text">
$oForm = _IEFormGetCollection ($oIE, 1)
_IEFormElementSetValue (_IEFormElementGetObjByName($oForm, "form"), "Form")
Edited by Dudinin

Share this post


Link to post
Share on other sites
PsaltyDS

If it's another instance of IE, use _IEAttach() to get a reference to it.

:)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Dudinin

If it's another instance of IE, use _IEAttach() to get a reference to it. :)

I try:

$oIE = _IECreate("http://somesite.some")
_IELinkClickByText ($oIE, "Text Of Link")
$oIE_new = _IEAttach("Title of window OR URL, nevertheless...", "URL") ;I tried almost all variants
$oForm_new = _IEFormGetCollection ($oIE_new, 0)
;$oForm_new = _IEFormGetObjByName ($oIE_new, "name of form", 0)
$oSelect = _IEFormElementGetObjByName($oForm_new, "login")
_IEFormElementSetValue ($oSelect, "filltext")

but there is an error:

--> IE.au3 V2.4-0 Warning from function _IEFormGetCollection, $_IEStatus_NoMatch

--> IE.au3 V2.4-0 Error from function _IEFormElementGetObjByName, $_IEStatus_InvalidDataType

--> IE.au3 V2.4-0 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType

AutoIt Window info tool said this (Control tab):

Class Internet Explorer_Server

Instance 1

ClassnameNN Internet Explorer_Server1

etc.

Follow manual it means this window can be attached by _IEAttach, but I can't do this.

P.S. How to create tab in IE instead of window? And how to open link in new tab instead of window? ;)

Share this post


Link to post
Share on other sites
DaleHohm

_IEFormGetCollection, $_IEStatus_NoMatch

Try ConsoleWrite(_IEDocReadHTML($oIE_new) & @CRLF)

to see if the document in the attached IE instance contains what you think it does (hint: watch for frames).

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
Dudinin

The problem have been solved by add Sleep(1000) (if value lesser than 1000, it's not work properly):

$oIE = _IECreate("http://somesite.some")
_IELinkClickByText ($oIE, "Text Of Link")
$oIE_new = _IEAttach("Title of window OR URL, nevertheless...", "URL") ;I tried almost all variants
;$oForm_new = _IEFormGetCollection ($oIE_new, 0)
$oForm_new = _IEFormGetObjByName ($oIE_new, "name of form", 0)
Sleep(1000)
$oSelect = _IEFormElementGetObjByName($oForm_new, "login")
_IEFormElementSetValue ($oSelect, "filltext")

I try to use _IELoadWait instead of Sleep (parameter of _IELinkClickByText is default - "Wait for page load to complete before returning", but nevertheless...) but it's not work properly too. May be because of strange structure of the page...

Somebody know how to create tab in IE instead of window =)? Do the AutoIt have ability to work with tabs?

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  

×