i_like_penguins Posted November 3, 2017 Share Posted November 3, 2017 (edited) I am trying to automate printing some reports from within Sql Server Reporting Services and having a bit of a problem getting the IE controls to work. I could try and just tab through things, but I have had mixed results with that in the past. The first issue is that the SSRS site is in the intranet zone, so as soon as IE launches it kicks out a client disconnect error. I can get around that with _IEAttach, but that is being strange. I put a sleep between launching IE and the _IEAttach, but for some goofy reason _IEAttach is executing before the sleep command. I also cannot seem to get the _IEFormElementGetObjByName bits to match right. Errors: --> IE.au3 T3.0-2 Error from function _IELoadWait, $_IESTATUS_ClientDisconnected (-2147417848, Browser has been deleted prior to operation.) --> IE.au3 T3.0-2 Error from function _IEFormElementGetObjByName, $_IESTATUS_InvalidObjectType --> IE.au3 T3.0-2 Error from function _IEFormElementGetObjByName, $_IESTATUS_InvalidDataType here is my code: Func Print($MONumber) Local $oIE, $oForm, $oFromMO $oIE = _IECreate("http://<restofurl>") Sleep(100) $oIE = _IEAttach("byMOwithPB") Sleep(5000) $oIE = _IEAttach("byMOwithPB") $oForm = _IEFormElementGetObjByName($oIE,"ui_form") $oFromMO = _IEFormElementGetObjByName($oForm,"ctl32$ctl04$ctl03$txtValue") Exit ; kill the loop so i don't end up with dozens of IE windows open EndFunc here is the html for the page. I think I removed all the identifying info. The text before the field I want to enter stuff into is "From MO Number:" expandcollapse popup//<![CDATA[ Sys.WebForms.PageRequestManager._initialize('ctl04', document.getElementById('ui_form')); Sys.WebForms.PageRequestManager.getInstance()._updateControls(['tNavigationCorrector$ctl00','fctl32$ReportViewer','fctl32$DocMap','fctl32$ctl09$ReportArea'], ['NavigationCorrector'], ['ctl32$ctl09$ReportControl$ctl00'], 0); //]]> </script> <span><noscript><table width="100%" class="msrs-normal"> <tr> <td valign="top" height="30" colspan="4" class="msrs-validationerror"><img src="/Reports/images/blank.gif" height="1" width="24" border="0" /><img src="/Reports/images/line_err1.gif" height="16" width="16" alt="Error" /><img src="/Reports/images/blank.gif" height="1" width="12" border="0" />This page might not function correctly because either your browser does not support scripts or active scripting is disabled.</td> </tr> </table> </noscript><table width="100%" class="msrs-normal" cellpadding="0" cellspacing="0" height="100%"> <tr> <td valign="top"><div> <table class="msrs-topBreadcrumb" cellpadding="0" cellspacing="0" border="0" width="100%"> <tr> <td><span><div> <a href="/Reports/Pages/Folder.aspx">Home</a> > <a href="/Reports/Pages/Folder.aspx?ItemPath=%2fD">D</a> > <a href="/Reports/Pages/Folder.aspx?ItemPath=%2fD%2fD">D</a> > <a href="/Reports/Pages/Folder.aspx?ItemPath=%2fD">Manufacturing</a> > <a href="/Reports/Pages/Report.aspx?ItemPath=%2fD&SelectedTabId=PropertiesTab&SelectedSubTabId=GenericPropertiesTab">d</a> </div></span></td> <td align="right"><span><a href="/Reports/Pages/Folder.aspx">Home</a> | <a href="/Reports/Pages/Subscriptions.aspx">My Subscriptions</a> | <a href="http://go.microsoft.com/fwlink/?LinkID=301614" target="MicrosoftReportingServicesHelp">Help</a></span></td> </tr> </table> </div></td> </tr> <tr height="100%"> <td valign="top"><table width="100%" class="msrs-contentFrame" cellpadding="0" cellspacing="0" height="100%"> <tr> <td valign="top" height="100%"><table width="100%" class="msrs-normal" cellpadding="0" cellspacing="0" height="100%"> <tr> <td valign="top" height="100%"><span><span id="ctl31_ctl00" style="display:none;"></span><script> $addHandler(window, 'beforeunload', function() {Sys.WebForms.PageRequestManager.getInstance().abortPostBack();}); Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function(sender, args) { if (args.get_error() !== null) { var label = $get('ctl31_ctl00'); label.style.display = ''; label.innerText = args.get_error().message; label.textContent = label.innerText; } }); Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(function(sender, args) {$get('ctl31_ctl00').style.display = 'none';}); </script></span><div id="NavigationCorrector" style="display:none;"> <input type="hidden" name="NavigationCorrector$ScrollPosition" id="NavigationCorrector_ScrollPosition" /><input type="hidden" name="NavigationCorrector$ViewState" id="NavigationCorrector_ViewState" /><input type="hidden" name="NavigationCorrector$PageState" id="NavigationCorrector_PageState" /><div id="NavigationCorrector_ctl00"> <input type="hidden" name="NavigationCorrector$NewViewState" id="NavigationCorrector_NewViewState" /> </div> </div><noscript> Your browser does not support scripts or has been configured not to allow scripts. </noscript><div id="ctl32_ReportViewer"> <div id="ctl32" onclick="if ($get('ctl32_ctl04') != null && $get('ctl32_ctl04').control != null) $get('ctl32_ctl04').control.HideActiveDropDown();" onactivate="if ($get('ctl32_ctl04') != null && $get('ctl32_ctl04').control != null) $get('ctl32_ctl04').control.HideActiveDropDown();" style="height:100%;width:100%;"> <div id="ctl32_HttpHandlerMissingErrorMessage" style="border-color:Red;border-width:2px;border-style:Solid;padding:10px;display:none;overflow:auto;font-size:.85em;"> <h2> Report Viewer Configuration Error </h2><p>The Report Viewer Web Control HTTP Handler has not been registered in the application's web.config file. Add <add verb="*" path="Reserved.ReportViewerWebControl.axd" type = "Microsoft.Reporting.WebForms.HttpHandler, ReportingServicesWebUserInterface, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" /> to the system.web/httpHandlers section of the web.config file, or add <add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, ReportingServicesWebUserInterface, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" /> to the system.webServer/handlers section for Internet Information Services 7 or later.</p> </div><span id="ctl32_ctl03"><input type="hidden" name="ctl32$ctl03$ctl00" id="ctl32_ctl03_ctl00" /><input type="hidden" name="ctl32$ctl03$ctl01" id="ctl32_ctl03_ctl01" /></span><input type="hidden" name="ctl32$ctl10" id="ctl32_ctl10" /><input type="hidden" name="ctl32$ctl11" id="ctl32_ctl11" /><div id="ctl32_AsyncWait" style="background-color:White;opacity:0.7;position:absolute;display:none;filter:alpha(opacity=70);"> </div><div id="ctl32_AsyncWait_Wait" class="WaitControlBackground" style="display:none;position:absolute;"> <table height="100%"> <tr> <td width="32px" height="32px"><img src="/Reports/Reserved.ReportViewerWebControl.axd?OpType=Resource&Version=12.0.5556.0&Name=Microsoft.Reporting.WebForms.Icons.SpinningWheel.gif" alt="Loading..." style="height:32px;width:32px;border-width:0px;" /></td><td class="WaitInfoCell"><span class="WaitText">Loading...</span><div class="CancelLinkDiv"> <a class="CancelLinkText" href="javascript:$get('ctl32_AsyncWait').control._cancelCurrentPostback();">Cancel</a> </div></td> </tr> </table> </div><input type="hidden" name="ctl32$AsyncWait$HiddenCancelField" id="ctl32_AsyncWait_HiddenCancelField" value="False" /><table cellpadding="0" cellspacing="0" id="ctl32_fixedTable" style="table-layout:fixed;width:100%;height:100%;"> <tr class="MenuBarBkGnd"> <td style="display:none;width:25%;"></td><td style="display:none;width:6px;"></td><td style="width:100%;"></td> </tr><tr id="ParametersRowctl32"> <td colspan="3"><div id="ctl32_ctl04" style="width:100%;overflow-x:auto;overflow-y:hidden;"> <div onclick="if ($get('ctl32_ctl04') != null && $get('ctl32_ctl04').control != null) $get('ctl32_ctl04').control.HideActiveDropDown();" onactivate="if ($get('ctl32_ctl04') != null && $get('ctl32_ctl04').control != null) $get('ctl32_ctl04').control.HideActiveDropDown();"> <table cellpadding="0" cellspacing="0" width="100%" id="ParameterTable_ctl32_ctl04" name="ParameterTable_ctl32_ctl04" class="ParametersFrame ParamsGrid MenuBarBkGnd"> <tr> <td width="100%" height="100%"><table id="ParametersGridctl32_ctl04"> <tr IsParameterRow="true"> <td class="ParamLabelCell"><label for="ctl32_ctl04_ctl03_txtValue"><span>From MO Number:</span></label></td><td class="ParamEntryCell" style="padding-right:0px;"><div id="ctl32_ctl04_ctl03"> <input name="ctl32$ctl04$ctl03$txtValue" type="text" size="30" onchange="javascript:setTimeout('__doPostBack(\'ctl32$ctl04$ctl03$txtValue\',\'\')', 0)" onkeypress="if (WebForm_TextBoxKeyHandler(event) == false) return false;" id="ctl32_ctl04_ctl03_txtValue" disabled="disabled" class="DisabledTextBox" /> </div></td><td class="InterParamPadding"></td><td class="ParamLabelCell"><label for="ctl32_ctl04_ctl05_txtValue"><span disabled="disabled">To MO Number:</span></label></td><td class="ParamEntryCell" style="padding-right:0px;"><div id="ctl32_ctl04_ctl05"> <input name="ctl32$ctl04$ctl05$txtValue" type="text" size="30" id="ctl32_ctl04_ctl05_txtValue" disabled="disabled" class="DisabledTextBox" /> </div></td> Thanks. Edited November 3, 2017 by Melba23 Amended title: "explorer" not "exploder"!!! Link to comment Share on other sites More sharing options...
SkysLastChance Posted November 3, 2017 Share Posted November 3, 2017 Try going to the setting in IE. (The gear icon in most cases.) Internet Options -> Secrurity Tab -> Make sure that "Enable Proctected Mode" is unchecked. You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott Link to comment Share on other sites More sharing options...
i_like_penguins Posted November 3, 2017 Author Share Posted November 3, 2017 Protected mode is unchecked. Link to comment Share on other sites More sharing options...
i_like_penguins Posted November 3, 2017 Author Share Posted November 3, 2017 I figured it out. This: $oForm = _IEFormElementGetObjByName($oIE,"ui_form") $oFromMO = _IEFormElementGetObjByName($oForm,"ctl32$ctl04$ctl03$txtValue") should be this: $oForm = _IEFormGetObjByName($oIE,"ui_form") $oFromMO = _IEFormElementGetObjByName($oForm,"ctl32$ctl04$ctl03$txtValue") SkysLastChance 1 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