Jump to content
Sign in to follow this  
MacBain00

_IEAttach Issues

Recommended Posts

MacBain00

hi guys,

I'm currently trying to set up an automated query/export feature for our ticketing system and am stuck at one point. A pop-up window opens up in order for me to export the data. I'm having trouble getting AutoIT to attach to this window, fill in the appropriate information, and submitting the form. If I can get this one last step, I'll be done except for some minor issues I'll get back to. I'm having a problem with _IEAttach. I can attach to the window, but I can't find the form. AutoIT returns no match found even though the source code does show it there. My code for that is below:

WinActivate("Export - Microsoft Internet Explorer")
$oIE = _IEAttach("Export")
$o_form = _IEFormGetObjByName($oIE, "SWEForm3_0"); locate the form
$oButton = _IEFormElementGetObjByName($o_form, "Next"); get the submit button reference     
_IEFormElementRadioSelect($o_form, "Comma Separated Text File", "s_3_1_104_0", 1, "byValue")
_IEFormSubmit($o_form)

Basically am I missing something? should I be declaring another variable? Source code for pop-up window is below:

<HTML  OT='PopupWindow'><head>
&lt;script language="javascript" src="19221/scripts/swecommon.js"></script> 
&lt;script language="javascript" src="19221/scripts/swecmn_hi.js"></script> 
&lt;script language="javascript" src="19221/scripts/swecmn_li.js"></script> 
<title>Export</title><link href="files/main.css" rel="stylesheet"/></head><body bgcolor="#dedede" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">&lt;script>
 if (typeof(top.EventHandler)!='undefined' && top.EventHandler!=null) this.EventHandler = top.EventHandler;
else if (opener != null && opener.top.PopupEventHandler != null && typeof(opener.top.PopupEventHandler)!='undefined')
this.EventHandler = opener.top.PopupEventHandler;
function HandleKeyUp(e) {
 if(!document.all) event=e;
 if( typeof(EventHandler)!='undefined' && EventHandler !=null ) EventHandler(this, event);
return false;}
if(!document.all) document.captureEvents(Event.KEYUP);
this.document.onkeyup = HandleKeyUp;
</script>
<link href="files/main.css" rel="stylesheet"/><form name="SWEForm3_0" method="post" action="/service_enu/start.swe" >
<table width="100%" cellspacing="0" cellpadding="0" border="0" align="center"><tr valign="top"><td class="AppletStylePopup"><table class="AppletBack" valign="top" width="100%" cellpadding="0" cellspacing="0" border="0"><tr valign="top"><td><table class="AppletBack" cellpadding="4" cellspacing="0" border="0"><tr><td></td></tr></table><table width="100%" class="AppletBack" border="0" cellspacing="2" cellpadding="1" align="center"></table><table  class="AppletBack" border="0" cellpadding="0"  cellspacing="0"><tr valign="top"><td><table border="0" cellspacing="2" cellpadding="1" align="center"><tr valign="top"><td class="scLabelRight" nowrap>Rows to Export:</td><td class="scField" width="100%"><table cellpadding="0" cellspacing="0" border="0"><tr><td class="scField" ><nobr><input type="radio" checked name='s_3_1_102_0' value='All Rows In Current Query'  id='s_3_1_102_0' tabindex=997 >All Rows In Current Query<br><input type="radio" name='s_3_1_102_0' value='Only Current Row'  id='s_3_1_102_0' tabindex=997 >Only Current Row<br></nobr></td><td> </td></tr></table></td></tr><tr valign="top"><td class="scLabelRight" nowrap>Columns To Export:</td><td class="scField" width="100%"><table cellpadding="0" cellspacing="0" border="0"><tr><td class="scField" ><nobr><input type="radio" name='s_3_1_103_0' value='All'  id='s_3_1_103_0' tabindex=997 >All<br><input type="radio" checked name='s_3_1_103_0' value='Visible Columns'  id='s_3_1_103_0' tabindex=997 >Visible Columns<br></nobr></td><td> </td></tr></table></td></tr><tr valign="top"><td class="scLabelRight" nowrap>Output Format:</td><td class="scField" width="100%"><table cellpadding="0" cellspacing="0" border="0"><tr><td class="scField" ><nobr><input type="radio" checked name='s_3_1_104_0' value='Tab Delimited Text File'  id='s_3_1_104_0' tabindex=997 >Tab Delimited Text File<br><input type="radio" name='s_3_1_104_0' value='Comma Separated Text File'  id='s_3_1_104_0' tabindex=997 >Comma Separated Text File<br><input type="radio" name='s_3_1_104_0' value='HTML'  id='s_3_1_104_0' tabindex=997 >HTML<br><input type="radio" name='s_3_1_104_0' value='Text File With Delimiter:'  id='s_3_1_104_0' tabindex=997 >Text File With Delimiter:<br></nobr></td><td> </td><td class="scField"  valign="bottom"><nobr><input type="text" name='s_3_1_105_0' value=''  style="width:30" id='s_3_1_105_0' tabindex=997  maxlength="32"></nobr></td><td> </td></tr></table></td></tr></table></td><td><table border="0" cellspacing="2" cellpadding="1"></table></td></tr></table><table class="AppletBack" border="0" cellspacing="2" cellpadding="1" align="center"></table></td></tr></table></td></tr><tr><td><table width="100%" cellpadding="2" cellspacing="0" border="0" class="AppletStylePopup"><tr class="appletbttm"><td width="100%"><img src="images/spacer.gif" valign="top" width="10" height="20" alt=""></td><td nowrap></td><td nowrap><span class="minibuttonOn"><a href='java script:void(0)' onclick='SWESubmitForm(document.SWEForm3_0,s_0,"s_3_1_106_0",""); return false;'  tabindex=997  id='s_3_1_106_0'>Next</a></span></td><td nowrap><span class="minibuttonOn"><a href='java script:void(0)' onclick='SWESubmitForm(document.SWEForm3_0,s_1,"s_3_1_107_0",""); return false;'  tabindex=997  id='s_3_1_107_0'>Close</a></span></td><td><img src="images/spacer.gif" valign="top" width="10" height="20" alt=""></td></tr></table></td></tr></table><span id='s_2'></span></form>

Hopefully another pair of eyes can see what I might not be seeing.


-Work Smarter, Not Harder, Use More AutoIT

Share this post


Link to post
Share on other sites
DaleHohm

What is output to the SciTe console when you run this?

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
MacBain00

What is output to the SciTe console when you run this?

Dale

--> IE.au3 Warning from function _IEAttach, $_IEStatus_NoMatch

--> IE.au3 Error from function _IEFormGetObjByName, $_IEStatus_InvalidDataType

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

--> IE.au3 Error from function _IEFormSubmit, $_IEStatus_InvalidDataType

>Exit code: 0 Time: 17.559


-Work Smarter, Not Harder, Use More AutoIT

Share this post


Link to post
Share on other sites
DaleHohm

So as you can see, the _IEAttach is NOT finding the window contrary to what you said in first post.

Suggest you try

$oIE = _IEAttach("Export", "DialogBox")

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
MacBain00

Sorry about that...i actually gave you the wrong output...

--> IE.au3 Warning from function _IEGetObjByName, $_IEStatus_NoMatch

--> IE.au3 Error from function _IEFormSubmit, $_IEStatus_InvalidDataType

basically it finds the export...then it doens't find the form object.....i've tried all the different IEGet"types"


-Work Smarter, Not Harder, Use More AutoIT

Share this post


Link to post
Share on other sites
jlei

i found a lot of IE functions do not compensate for machine/display lag. basically the time the machien takes to draw the window versus the status output that IE sends.

i cant explain it other than, your internet is faster than your machine

so what I have done is add a few sleep seconds to compensate for display/machine lag. its not the best solution but it works.

i found this issue with IEloadwait also, have many, many problems finding out the exact time for the script to continue.

Share this post


Link to post
Share on other sites
MacBain00

i found a lot of IE functions do not compensate for machine/display lag. basically the time the machien takes to draw the window versus the status output that IE sends.

i cant explain it other than, your internet is faster than your machine

so what I have done is add a few sleep seconds to compensate for display/machine lag. its not the best solution but it works.

i found this issue with IEloadwait also, have many, many problems finding out the exact time for the script to continue.

I've tried adding a 5 second sleep in case of lag between window loading and what not. But still same issue.


-Work Smarter, Not Harder, Use More AutoIT

Share this post


Link to post
Share on other sites
jlei

$oIE = _IEAttach("Test")

If @error <> 0 Then
    Sleep(2000)
    $oIE = _IEAttach("Test")
    _IELoadWait($oIE)

this is what I did and works for me all the time now. i think part of the problem is that you cant call a loadwait on a window you cant even get a reference to yet

Edited by jlei

Share this post


Link to post
Share on other sites
DaleHohm

Sorry about that...i actually gave you the wrong output...

--> IE.au3 Warning from function _IEGetObjByName, $_IEStatus_NoMatch

--> IE.au3 Error from function _IEFormSubmit, $_IEStatus_InvalidDataType

basically it finds the export...then it doens't find the form object.....i've tried all the different IEGet"types"

The SciTe output references __IEGetObjByName, but this command does not appear in the script you posted. Are you sure you have posted the right output?

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
MacBain00

I wish this was a just a sleep issue...unforunately it is not. Still not finding the form even though I believe it's pointed to the right spot.

--> IE.au3 Warning from function _IEGetObjByName, $_IEStatus_NoMatch

--> IE.au3 Error from function _IEFormSubmit, $_IEStatus_InvalidDataType


-Work Smarter, Not Harder, Use More AutoIT

Share this post


Link to post
Share on other sites
jlei

he is probably working with code after he gets the attach. i actually have similar issues, sometimes the object fails to grab when the ID clearly matches...

for me, it has something to do with popups and loadwait only though.

can i ask what loadwait generally checks for browser completion status?

Share this post


Link to post
Share on other sites
jlei

I added some MsgBox's as stop points before any screen changes on the popup, this way i can stop the script and check the log window.

I did notice it would pause at the wrong points, basically the script wasnt waiting long enough before continuing on and the script was trying to grab objects too early (screens ahead).

the popup is one of those IE windows that does NOT have a bottom status bar or a top menu navigation ( i dont know what you call that tho and how it might affect _IELoadWait)

Edited by jlei

Share this post


Link to post
Share on other sites
big_daddy

I wish this was a just a sleep issue...unforunately it is not. Still not finding the form even though I believe it's pointed to the right spot.

--> IE.au3 Warning from function _IEGetObjByName, $_IEStatus_NoMatch

--> IE.au3 Error from function _IEFormSubmit, $_IEStatus_InvalidDataType

You need to read Dale's last post more carefully. If you want any help at all you need to post the exact code you are using and the output you get from that code.

Share this post


Link to post
Share on other sites
MacBain00

You need to read Dale's last post more carefully. If you want any help at all you need to post the exact code you are using and the output you get from that code.

Dale's post came while I was typing up a response to the post before that so I didn't even realize he responded til after I saw you had responded. I apologize about that. Looks like i screwed up the initial post. I have 3 files that are doing almost the same thing just setup differently, so pasted wrong code & output. Using the html source code in the first post...my code should be:

WinActivate("Export - Microsoft Internet Explorer")
Sleep(5000);gives window time to come up and load
$o_IE = _IEAttach("Export");attach to window with this title
$form = _IEGetObjByName($o_IE, "SWEForm3_0");needs an object to search through
;_IEFormElementRadioSelect($form, "Comma Separated Text File", "s_3_1_104_0", 1, "byValue") <-- radio value that needs to be selected...
_IEFormSubmit($form) <-- submit form

results:

--> IE.au3 Warning from function _IEGetObjByName, $_IEStatus_NoMatch

--> IE.au3 Error from function _IEFormSubmit, $_IEStatus_InvalidDataType

>Exit code: 0 Time: 12.599


-Work Smarter, Not Harder, Use More AutoIT

Share this post


Link to post
Share on other sites
DaleHohm

I'd suggest that you either are not attaching to what you think you are or there is a frame involved that you are not accounting for.

I suggest that you use IE.au3 to get the dynamic source and make certain it is what you think it is:

ConsoleWrite(_IEDocReadHTML($o_IE) & @CR)

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
MacBain00

I'd suggest that you either are not attaching to what you think you are or there is a frame involved that you are not accounting for.

I suggest that you use IE.au3 to get the dynamic source and make certain it is what you think it is:

ConsoleWrite(_IEDocReadHTML($o_IE) & @CR)

Dale

Thanks Dale. That did help me. Now my question is how can I open a window but it pointing to a frame. How would I get the embedded info that i get when I right-click -> view source of the document.

From ConsoleWrite

<HTML OT="SiebWebPopupWindow"><HEAD><TITLE>Export</TITLE>
<script>
function loadPopup() {
_sweapp.S_CmdMgr.Initialize(top.opener.top._swe._sweapp.S_App,true);
}
</SCRIPT>

<script language=javascript src="19221/scripts/swecommon.js"></SCRIPT>
</HEAD><FRAMESET border=0 frameSpacing=0 rows=100%,* frameBorder=0 onload=loadPopup()><FRAME name=_swepopcontent 

marginWidth=0 marginHeight=0 

src="/service_enu/start.swe?SWECmd=GetCachedFrame&amp;SWEC=34&amp;SWEFrame=top._sweclient._swecontent._sweview._swetmp&amp

;SWESP=1" frameBorder=Yes noResize scrolling=no OT="_swepopcontent Frame"><FRAME title="" name=_sweapp marginWidth=0 

marginHeight=0 src="?SWECmd=GetCachedFrame&amp;SWEC=34&amp;SWEFrame=_sweapp" frameBorder=Yes noResize 

scrolling=no></FRAMESET></HTML>

If someone notices something that I dont...it would be appreciated. I'll be working on this for some time until somethign clicks. thanks again for all the help guys. You have no idea how much I appreciate it.


-Work Smarter, Not Harder, Use More AutoIT

Share this post


Link to post
Share on other sites
DaleHohm

$oFrame = _IEFrameGetObjByName($oIE, "_swepopcontent")

It is possible that that frame could have other embedded frames however - so you'll just have to tear it appart and study it.

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

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  

×