horstj Posted August 7, 2012 Share Posted August 7, 2012 Hi All, I am very new to AutoIt and need some help getting my script working. I need to just open a browser to a certain page, input some information, and check to see if it succeeded. The first two things work fine with just Run() and Send(), but then I need to read some text off of the webpage to check for success and the only way I know to do that is _IEBodyReadText() (if there is another way please let me know). Here is the code that I have so far: #include <GUIConstantsEx.au3> #include <IE.au3> Main() Func Main() $mainwindow = GUICreate("User Type", 220, 100) GUICtrlCreateLabel("Will this be a shop user or an office user?", 12, 20) $shopbutton = GUICtrlCreateButton("Shop", 40, 60, 60) $officebutton = GUICtrlCreateButton("Office", 120, 60, 60) GUISwitch($mainwindow) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg(1) Select Case $msg[0] = $shopbutton GUIDelete($mainwindow) ShopUser() ExitLoop Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $mainwindow ExitLoop EndSelect WEnd EndFunc Func ShopUserGUI() $shopwindow = GUICreate("Create Shop User",200,250) $QDBlabel = GUICtrlCreateLabel("Quality DB Information:", 10, 10, 150) guictrlsetfont($QDBlabel, default, 600) GUICtrlCreateLabel("Username:", 20, 33) $QDBusernameIn = GUICtrlCreateInput("", 80, 30) GUICtrlCreateLabel("Password:", 20, 68) $QDBpasswordIn = GUICtrlCreateInput("", 80, 65) GUICtrlCreateLabel("First Name:", 20, 103) $QDBfirstIn = GUICtrlCreateInput("", 80, 100, 100) GUICtrlCreateLabel("Last Name:", 20, 138) $QDBlastIn = GUICtrlCreateInput("", 80, 135, 100) GUICtrlCreateLabel("Last 4 of Social:", 20, 173) $QDBsocialIn = GUICtrlCreateInput("", 120, 170, 40) $shopokbutton = GUICtrlCreateButton("OK", 70, 205, 60) GUISetState(@SW_SHOW, $shopwindow) While 1 $msg2 = GUIGetMsg(1) Select Case $msg2[0] = $shopokbutton $QDBusername = GUICtrlRead($QDBusernameIn) $QDBpassword = GUICtrlRead($QDBpasswordIn) $QDBfirst = GUICtrlRead($QDBfirstIn) $QDBlast = GUICtrlRead($QDBlastIn) $QDBsocial = GUICtrlRead($QDBsocialIn) GUIDelete($shopwindow) CreateQDBUser($QDBusername,$QDBpassword,$QDBfirst,$QDBlast,$QDBsocial) ExitLoop Case $msg2[0] = $GUI_EVENT_CLOSE And $msg2[1] = $shopwindow ExitLoop EndSelect WEnd EndFunc Func CreateQDBUser($QDBusername,$QDBpassword,$QDBfirst,$QDBlast,$QDBsocial) $oIE = _IECreate("http://...") WinWaitActive("http://...") Send("...") WinWaitActive("...") Send("...") $Status = _IEBodyReadText($oIE) EndFunc I removed some of the information in the last function because it had passwords and links to things on our intranet. When I run this with trace lines added it seems to work fine until the $oIE = _IECreate("http://...") command. At this point it actually opens IE to the page I want, but then gives me an error message saying, "C:\Program Files (x86)\AutoIt3\Include\IE.au3 (560) : ==> The requested action with this object has failed.: WEnd WEnd^ ERROR ->08:56:10 AutoIT3.exe ended.rc:1 >Exit code: 1 Time: 11.102" Can anyone tell me why this is not working? Link to comment Share on other sites More sharing options...
JohnOne Posted August 7, 2012 Share Posted August 7, 2012 Can you please first explain what exactly is not working with _IECreate()? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
water Posted August 7, 2012 Share Posted August 7, 2012 @JohnOne You can find the error message at the end of his post. JohnOne 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
DaleHohm Posted August 7, 2012 Share Posted August 7, 2012 (edited) Are you certain that it is the _IECreate or is it the _IEBodyReadText ? If the later, or even if not, add _IELoadWait($oIE) prior to _IEBodyReadText Dale Edited August 7, 2012 by DaleHohm 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...
JohnOne Posted August 7, 2012 Share Posted August 7, 2012 Indeed, try running code with only _IECreate("path") and see if you have an error. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
bogQ Posted August 7, 2012 Share Posted August 7, 2012 (edited) i whud sugest just for fun to try to add infront the line _IEBodyReadText a command _IEAttach* Edited August 7, 2012 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
horstj Posted August 7, 2012 Author Share Posted August 7, 2012 Thanks for all of the responses guys. I should have been more clear about that. I actually have not run the code with the _IEBodyReadText() in it at all. I just added it in right before the post to show what I would like to get done in the long run. So I am sure that the problem is with the _IECreate(), but I am at a loss since it actually does open IE to the page I want and then immediately fails and jumps out of the subroutine. Link to comment Share on other sites More sharing options...
MrMitchell Posted August 7, 2012 Share Posted August 7, 2012 Horstj, What happens when you tried what was suggested below? Indeed, try running code with only _IECreate("path") and see if you have an error. If that fails, what happens when you try: _IECreate("path", 0, 1, 0) Link to comment Share on other sites More sharing options...
Nemon Posted August 7, 2012 Share Posted August 7, 2012 (edited) Hi there!So I've been using it a mega rookie for quite some time and only resently been getting into more normal rookie.That being said I can Co-sign with Horstj about IECreate having an issue, but its not with ALL websites.It only reacts to some that I try to go to.Local $oIE = _IECreate("http://www.google.com")MsgBox(0, "The URL", _IEPropertyGet($oIE, "locationurl"))Works great!but when I try an internal comapny page we use such as:Local $oIE = _IECreate(http://internal.company.webpage)It WILL create the page, but then I get then the error:"C:\Program Files (x86)\AutoIt3\Include\IE.au3 (560) : ==> The requested action with this object has failed.:WEndWEnd^ ERRORpops up and ends the script.#include <IE.au3>_IECreate(http://internal.company.webpage) creates the error. That is the only thing in the script.Hope that kind of helps. Edited August 7, 2012 by Nemon Link to comment Share on other sites More sharing options...
horstj Posted August 7, 2012 Author Share Posted August 7, 2012 Ah thanks Nemon! That is exactly the case for me as well. I did do what was suggested above and tried a script with just the _IECreate("www.autoitscript.com") and when that worked fine I considered that it. However, now when I tried the same thing to the internal webpage I get the same error. So my next question is how I can use _IEBodyReadText() if I don't get the the object variable $oIE for the active IE page from the _IECreate() function. Any help here would be great. Link to comment Share on other sites More sharing options...
Nemon Posted August 7, 2012 Share Posted August 7, 2012 Well I think you could use:$oIE =_IEAttach(http://internal.company.website) But the web page you would have to open manualy...OR just create script #1 with it opening another script and then create the webpage and get the error.Script #2 would be the rest of the script as you wanted just with a winwait and winactivate....rest of the script to start.Remember I did say I was a rookie.But that is what I will prob do if no one figures out what is up with the error. Link to comment Share on other sites More sharing options...
Nemon Posted August 8, 2012 Share Posted August 8, 2012 I was thinking more people would have an idea Link to comment Share on other sites More sharing options...
JohnOne Posted August 8, 2012 Share Posted August 8, 2012 Why not shellexecute your site and try _IEAttatch(). AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
horstj Posted August 8, 2012 Author Share Posted August 8, 2012 Sorry for my naivety, I was not aware of the _IEAttach. I tried it out, but I'm having trouble getting it working. I tried running it using the same window title that works for WinWaitActive(), but I get this error --> IE.au3 V2.4-0 Error from function _IEAttach, $_IEStatus_InvalidValue (Invalid Mode Specified) Any advice here? Link to comment Share on other sites More sharing options...
MrMitchell Posted August 8, 2012 Share Posted August 8, 2012 Same thing is happening with me, and I think I've narrowed it down to the _IELoadWait()... If you call _IECreate() with 0 for the wait flag it's fine. If you then call your own _IELoadWait() it errors out again. Link to comment Share on other sites More sharing options...
bogQ Posted August 8, 2012 Share Posted August 8, 2012 (edited) Any advice here? note that WinWaitActive Success: Returns handle so if $MyWinHwnd = WinWaitActive('somewin') then you can try If IsHWnd($MyWinHwnd) Then _IEAttach ( $MyWinHwnd , "HWND" ) Else MsgBox(0,"","Houston, We've Got a Problem") EndIf to see if it helps Edited August 8, 2012 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
MrMitchell Posted August 8, 2012 Share Posted August 8, 2012 Try this (of course you need to change $site):$oIE = ObjCreate("{D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E}") _IENavigate($oIE, $site) $oIE.visible = 1Reference: http://blogs.msdn.com/b/ieinternals/archive/2011/08/03/internet-explorer-automation-protected-mode-lcie-default-integrity-level-medium.aspxWorked for me, hope it works for you too. Link to comment Share on other sites More sharing options...
horstj Posted August 8, 2012 Author Share Posted August 8, 2012 Thanks bogQ. Returning the handle like that and using it in _IEAttach works perfectly for me! Link to comment Share on other sites More sharing options...
horstj Posted August 8, 2012 Author Share Posted August 8, 2012 I have a new situation now. _IEAttach() seems to work, but when I do _IEBodyReadText() I am not seeing what I expect to see. The situation is that I have a form online that I fill out with user information and submit. When I input a username that already exits I see that same exact form, but with a line of text added directly above it telling me that the username already exists. However, when I get to this page in my script and do _IEBodyReadText(), I only see the information within the form and not the added line of text (which is all I really even want). When I view the script of the page I see the line as the first thing in the body so it seems to me that the aforementioned routine is either only reading the form text or it is still showing me what was on the page right before I submitted the duplicate username. Does anyone have any idea what might be happening here? Link to comment Share on other sites More sharing options...
bogQ Posted August 8, 2012 Share Posted August 8, 2012 (edited) you probably have problems on submiting the page form what i'm trying to say is this when you submit form you do it with Send* command i presume? if so then you need to sleep some time so that page is fully loaded to attach it and read it so add Sleep(10000) before attaching to see if it work just for testing if it's working you then know that that's your problem so if that's your problem there are various methods to get over it first one that i would suggest is using _IEFormSubmit* and _IEFormElementSetValue* instead of Send* commands the other one is putting only _IELoadWait* after _IEAttach() but don't know what it produce needed results if your using Send* Edited August 8, 2012 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. 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