Jump to content
Sign in to follow this  
Regency

Invaild object error, using IE

Recommended Posts

Regency

So this is what i get from my coding... i mean, it should work unless i missed something.. I mean.. what it does, is open a ie window, open a gui embedded and show a picture in it, i wrote something about the image, hit save and start, and it should do the fuctions that are throwing errors.. anyone got any ideas?

#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <WindowsConstants.au3>
#AutoIt3Wrapper_Run_Debug_Mode=Y
Global $Url = "tmnx.net"
Global $A1 = ""
Global $P1 = ""
Global $tmnx = ""




_IEErrorHandlerRegister ()

$oIE = _IECreateEmbedded ()
GUICreate("Embedded Web control Test", 450, 300, _
        (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _
        $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$Desired = GUICtrlCreateGroup("Enter Captcha Answer",8,225,425,49)
$username = GUICtrlCreateInput("", 16, 241, 114, 21)
$savename = GUICtrlCreateButton("Save", 168, 241, 75, 25, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GUIActiveX = GUICtrlCreateObj($oIE, 10, 10, 400, 200)
$User = GUICtrlCreateLabel("", 8, 352, 250, 17) ; This is 
$Make = GUICtrlCreateButton("Start", 300, 241, 75, 25, 0)
GUISetState()       ;Show GUI

$Tmnx = _iecreate($Url,0,1,1,0)
_IELoadWait($Tmnx)
$oImg = _IEImgGetCollection($Tmnx,0)
$sInfo = $oImg.src
_IENavigate ($oIE,$oimg.src)

While 1
   $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $savename
            $name1 = GUICtrlRead($username)
            GUICtrlSetData($User, $name1)
        Case $msg = $Make
           Relog()
           GUIDelete()
           Exit
   EndSelect
WEnd

Func Relog()
    _IEAction($tmnx,"focus")
    $oUser = _IEGetObjByName($Tmnx, "Login1$UserName")
    _IEFormElementSetValue($oUser, $A1)
    $oPass = _IEGetObjByName($Tmnx, "Login1$Password")
    _IEFormElementSetValue($oPass, $p1)
    $oLogIn = _IEGetObjByName($Tmnx, "Login1$LoginLinkButton")
    $oCap = _IEGetObjByName($Tmnx, "recaptcha_response_field")
    _IEFormElementSetValue($oPass, $name1)
    _IEAction($oLogIn, "click")
EndFunc

0050: 0-0:  _IEAction($tmnx,"focus")
--> IE.au3 V2.4-0 Error from function _IEAction, $_IEStatus_InvalidObjectType
0051: 4-1:   $oUser = _IEGetObjByName($Tmnx, "Login1$UserName")
--> IE.au3 V2.4-0 Warning from function _IEGetObjByName, $_IEStatus_NoMatch (Name: Login1$UserName, Index: 0)
0052: 7-0:   _IEFormElementSetValue($oUser, $A1)
--> IE.au3 V2.4-0 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType
0053: 3-1:   $oPass = _IEGetObjByName($Tmnx, "Login1$Password")
--> IE.au3 V2.4-0 Warning from function _IEGetObjByName, $_IEStatus_NoMatch (Name: Login1$Password, Index: 0)
0054: 7-0:   _IEFormElementSetValue($oPass, $p1)
--> IE.au3 V2.4-0 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType
0055: 3-1:   $oLogIn = _IEGetObjByName($Tmnx, "Login1$LoginLinkButton")
--> IE.au3 V2.4-0 Warning from function _IEGetObjByName, $_IEStatus_NoMatch (Name: Login1$LoginLinkButton, Index: 0)
0056: 7-0:   $oCap = _IEGetObjByName($Tmnx, "recaptcha_response_field")
0057: 0-1:   _IEFormElementSetValue($oPass, $name1)
--> IE.au3 V2.4-0 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType
0058: 3-1:   _IEAction($oLogIn, "click")
--> IE.au3 V2.4-0 Error from function _IEAction, $_IEStatus_InvalidDataType
0059: 3-1: EndFunc
0044: 3-1:         GUIDelete()
0045: 0-0:         Exit

Share this post


Link to post
Share on other sites
dbzfanatic

I really doubt that any code on your page has Login1$username. Change your code for it and try again. What are you trying to do with the _IEGetObjByName there? Are you trying to set the data of the field with it?

Share this post


Link to post
Share on other sites
DaleHohm

Suggest you try DebugBar...

It shows me the form: <FORM id=form1 name=form1 action=login.aspx method=post>

Username: <INPUT class=TextBox2 id=txtUsername style="WIDTH: 100px; BACKGROUND-COLOR: black" name=txtUsername>

and Password: <INPUT class=TextBox2 id=txtPassword style="WIDTH: 100px; BACKGROUND-COLOR: black" type=password value="" name=txtPassword>

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
dbzfanatic

Suggest you try DebugBar...

It shows me the form: <FORM id=form1 name=form1 action=login.aspx method=post>

Username: <INPUT class=TextBox2 id=txtUsername style="WIDTH: 100px; BACKGROUND-COLOR: black" name=txtUsername>

and Password: <INPUT class=TextBox2 id=txtPassword style="WIDTH: 100px; BACKGROUND-COLOR: black" type=password value="" name=txtPassword>

Dale

Dale's the resident expert so you should use his advice. You got it straight from the horse's mouth...err...gorilla's mouth.

Share this post


Link to post
Share on other sites
PsaltyDS

Also, taking the first error first:

0050: 0-0:  _IEAction($tmnx,"focus")
--> IE.au3 V2.4-0 Error from function _IEAction, $_IEStatus_InvalidObjectType
_IEAction() with "focus" is not appropriate for the IE application object. It is intended to put focus on elements, not the window.

If you want to activate the window object, use:

$hIE = _IEPropertyGet($tmnx, "hwnd")
WinActivate($hIE)

:P


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

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.