Sign in to follow this  
Followers 0
horstj

_IECreate() not working

22 posts in this topic

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?

Share this post


Link to post
Share on other sites



@JohnOne

You can find the error message at the end of his post.

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

i whud sugest just for fun to try to add infront the line _IEBodyReadText a command _IEAttach*

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
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.

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

#9 ·  Posted (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.:

WEnd

WEnd^ ERROR

pops 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 by Nemon

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

I was thinking more people would have an idea :(

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#16 ·  Posted (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 by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
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.

 

Share this post


Link to post
Share on other sites

Thanks bogQ. Returning the handle like that and using it in _IEAttach works perfectly for me!

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

#20 ·  Posted (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 by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
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.

 

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