Sign in to follow this  
Followers 0
jrumbaug

IE automation failing to get forms from a frame

9 posts in this topic

An IE program that I have been using for over a year has started failing. I have traced the problem to this code snipet.  

The errors happens when I try to get a FORM object from a FRAME object. The message box reports that the $oFrame is an object, but the  error says [  Variable must be of type "Object" ]

Local $iNumFrames

$oFrames = _IEFrameGetCollection ($oIE)
$iNumFrames = @extended
For $i = 0 to ($iNumFrames - 1)
            $oFrame = _IEFrameGetCollection ($oIE, $i )
            msgBox(1,  " var type " & VarGetType( $oFrame) ,  @error )
            $oForms  = _IEFormGetCollection ($oFrame)
Next

The reported errors are:

"C:\Program Files\AutoIt3\Include\IE.au3" (903) : ==> Variable must be of type "Object".:

Return SetError($_IEStatus_Success, $oTemp.forms.length, $oTemp.forms)

Return SetError($_IEStatus_Success, $oTemp^ ERROR

->11:15:29 AutoIt3.exe ended.rc:1

+>11:15:29 AutoIt3Wrapper Finished..

>Exit code: 1    Time: 17.812

 

Thank you in advance for suggestions.

Jim Rumbaugh

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

maybe instead of $oTemp.forms.length

try

$oTemp.frames.length

As you said it yourself, its a frame not a form. :)

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

You are about the 3rd or 4th person to complain about frames no longer working. You may want to review some of the recent threads. I believe someone may have identified an update from MS that is causing this issue.

1 person likes this

Share this post


Link to post
Share on other sites

I remember reading that too Dan, do you remember the post or the actual update they removed?  Really wish I had that environment to test in.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

This >thread is the one where they identified the problematic update.

Share this post


Link to post
Share on other sites

This >thread is the one where they identified the problematic update.

Indeed, kb3025390 update seems to be an issue for any and all automation products out there.

Thanks


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Thank you for pointing me to the other thread. My problem was also solved by what I read:

"Thanks everyone for extremely helpful responses, the problem is "solved" by uninstalling KB3025390 IE update."

The only insight I can add that may help a workaround for use WITH the update:

one program worked that began with:
$oIE = _IECreateEmbedded ()
The program that began with this had the errors:
$oIE = _IECreate ("http://www.hhcwv.com/")
Edited by jrumbaug

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

although marked answered.

interesting just tried it from Excel VBA to see if there is something not revealed (on my system KB3025390 is installed)

Sub test()
    Dim shW As New SHDocVw.ShellWindows
    Dim myIE As InternetExplorer
    Dim myDoc As HTMLDocument
    
    
    Debug.Print shW.Count
    
    Set myIE = shW.Item(0)
    Debug.Print myIE.Name
 
Set myDoc = myIE.document
    
    Debug.Print myIE.LocationURL
    Debug.Print myDoc.frames.Length
    Debug.Print myDoc.parentWindow.frames.Length
    Debug.Print myDoc.forms.Length
End Sub
 
  

    

output

1 
Internet Explorer
http://www.hhcwv.com/
 3
 3 
 0
so the frames are returned properly and as vba is telling there are 0 forms its correct you do not get an object

 

maybe rewrite in IE.AU3 (at least you will not get the error as you had)

; #FUNCTION# ====================================================================================================================
; Author ........: Dale Hohm
; ===============================================================================================================================
Func _IEDocGetObj(ByRef $oObject)
    If Not IsObj($oObject) Then
        __IEConsoleWriteError("Error", "_IEDocGetObj", "$_IESTATUS_InvalidDataType")
        Return SetError($_IESTATUS_InvalidDataType, 1, 0)
    EndIf
    ;
    If __IEIsObjType($oObject, "document") Then
        Return SetError($_IESTATUS_Success, 0, $oObject)
    EndIf

    local $oTemp
    $oTemp=$oObject.document

    If __IEIsObjType($oTemp, "document") Then
        Return SetError($_IESTATUS_Success, 0, $oTemp)
    Else
        Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
    EndIf

EndFunc   ;==>_IEDocGetObj
or write this

$oForms  = _IEFormGetCollection ($oDoc)
but for sure this patch of microsoft gives problems

 

http://stackoverflow.com/questions/27566985/browser-execscript-stopped-working-after-updating-windows

So far I do not have problems with IUIAutomation framework references and simplespy in examples section running against IE.

Edited by junkew

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

execScript was to be deprecated in IE - 11, I made note of this in IEJS.au3.

http://msdn.microsoft.com/en-us/library/ie/ms536420%28v=vs.85%29.aspx

Edit:

Not that anyone would know I made note, I meant to add that I have a work around for it.

Edit2:

Ok, time for bed, I don't have a work around for KB3025390, my work around is for execScript deprecation.

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

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

  • Similar Content

    • suckinsyn
      By suckinsyn
      Hey there, folks. I have expanded my previous sms script (link here) to the point that it can be used by anyone without a problem. 
      Currently, as said in topic, it's working only with Polish numbers - I do not have enough knowledge about foreign country services that allow to send free text msgs, so if anyone could provide me some info, I would be glad. 
      Picture of GUI:

      Dane = sms details, such as Numer odbiorcy, which is target number starting with siec (first three numbers as they are representing the provider) and ending with last six numbers. You can use only numbers there. Nadawca and Tresc are the sender name and the text itself. Sender name is max 12 afaik (cba to check source) and text is max 60 letters long.
      By pressing 'Zatwierdz' script checks if number is valid. If it is, button to send sms is enabled, if not, it's disabled. You can chose to send 1 sms or to send x amount of them, theres 2 buttons.
      Timer on right side is not yet done. Any ideas to help me out doing it would be cool, although I've though of using variable to declare how much script would have to wait, something like this:
      Sleep($some_variable_from_checkbox) If I can't make it like that, any ideas, as said, would be nice.
      Here's the code of the app:
      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=C:\Users\qwe\Desktop\(32 bit)SMS Lite 1.2.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <IE.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("SMS lite 1.2", 275, 460, 263, 315) $Group1 = GUICtrlCreateGroup(" Error log ", 8, 232, 257, 41) $error_label = GUICtrlCreateLabel("Wybrana siec: X", 25, 250, 119, 17) $error_label2 = GUICtrlCreateLabel("Poprawny numer: X", 135, 250, 119, 17) GUICtrlSetFont($error_label, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor($error_label, 0xce0000) GUICtrlSetFont($error_label2, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor($error_label2, 0xce0000) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("Dane", 8, 8, 257, 217) $Input1 = GUICtrlCreateInput("", 76, 48, 49, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER)) GUICtrlSetLimit($Input1, 6) $OK = GUICtrlCreateButton("Zatwierdz", 32, 200, 83, 17) $Label8 = GUICtrlCreateLabel("Numer odbiorcy", 32, 30, 90, 17) $Label10 = GUICtrlCreateLabel("Nadawca:", 40, 70, 53, 17) $Input2 = GUICtrlCreateInput("", 24, 88, 100, 21) GUICtrlSetLimit($Input2, 15) $Label11 = GUICtrlCreateLabel("Tresc:", 48, 110, 34, 17) $Input3 = GUICtrlCreateInput("Wpisz tutaj tresc SMS. Maksymalnie mozesz uzyc 60 znakow.", 24, 128, 97, 68, $ES_MULTILINE) GUICtrlSetLimit($Input3, 60) $Combo1 = GUICtrlCreateCombo("siec", 24, 48, 49, 25) $Pic1 = GUICtrlCreatePic("C:\Users\qwe\Desktop\SKULL ICON.gif", 136, 32, 115, 167) $Label9 = GUICtrlCreateLabel("## BY BRODATY ##", 141, 200, 107, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group4 = GUICtrlCreateGroup(" Wysylanie SMS ", 8, 280, 257, 169) $Label4 = GUICtrlCreateLabel("Dzienny limit SMS'ow wynosi 30.", 54, 392, 157, 17) $Label5 = GUICtrlCreateLabel("Chcesz wiecej? Daj znac, dogadamy sie.", 32, 408, 197, 17) $Group3 = GUICtrlCreateGroup("", 24, 377, 225, 7) GUICtrlCreateGroup("", -99, -99, 1, 1) $Label6 = GUICtrlCreateLabel("suckinsyn@gmail.com", 72, 424, 109, 17) $Checkbox1 = GUICtrlCreateCheckbox("wyslij za 10 minut", 136, 312, 105, 17) $Checkbox2 = GUICtrlCreateCheckbox("wyslij za 30 minut", 136, 328, 105, 17) $Checkbox3 = GUICtrlCreateCheckbox("wyznacz sam czas", 136, 344, 113, 17) $Group5 = GUICtrlCreateGroup(" Timer (dodatek) ", 125, 292, 130, 78) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button1 = GUICtrlCreateButton("Wyslij 1 SMS", 24, 304, 91, 25) $Button2 = GUICtrlCreateButton("1 do 30 SMS'ow", 24, 348, 91, 25) $Label1 = GUICtrlCreateLabel("lub sam wybierz ilosc", 18, 331, 102, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;---------------------------------------------------------;---------------------------------------------------------;---------------------------------------------------------;------------------------------------------------- GUICtrlSetState($Button1, $GUI_DISABLE) GUICtrlSetState($Button2, $GUI_DISABLE) GUICtrlSetState($Checkbox1, $GUI_DISABLE) GUICtrlSetState($Checkbox2, $GUI_DISABLE) GUICtrlSetState($Checkbox3, $GUI_DISABLE) Dane() Func Dane() GUICtrlSetData($Combo1, "500|501|502|503|504|505|506|507|508|509|510|511|512|513|514|515|516|517|518|519|530|531|532|533|534|535|536|537|538|539|600|601|602|603|604|605|606|607|608|609|660|661|662|663|664|665|666|667|668|669|690|691|692|693|694|695|696|697|698|699|721|722|723|724|725|726|727|728|729|730|731|732|733|739|780|781|782|783|784|785|786|787|788|789|790|791|792|793|794|795|796|797|798|799|880|881|882|883|884|885|886|887|888|889", "0") Local $sComboRead = "" While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $OK $sNR_1 = GUICtrlRead($Combo1) $sNR_2 = GUICtrlRead($Input1) if $sNR_1 = "siec" then GUICtrlSetData($error_label,"Wybrana siec: X") GUICtrlSetFont($error_label, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor($error_label, 0xce0000) Else GUICtrlSetData($error_label,"Wybrana siec: V") GUICtrlSetFont($error_label, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor($error_label, 0x4bcc00) EndIf if stringlen(GUICtrlRead($Input1))<6 Then GUICtrlSetData($error_label2,"Poprawny numer: X") GUICtrlSetFont($error_label2, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor($error_label2, 0xce0000) Else GUICtrlSetData($error_label2,"Poprawny numer: V") GUICtrlSetFont($error_label2, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor($error_label2, 0x4bcc00) EndIf $tes1 = GUICtrlRead($error_label) if $tes1 = "Wybrana siec: V" Then $zgoda1 = 1 Else $zgoda1 = 0 EndIf $tes2 = GUICtrlRead($error_label2) if $tes2 = "Poprawny numer: V" Then $zgoda2 = 1 Else $zgoda2 = 0 EndIf If $zgoda1 = 1 AND $zgoda2 = 1 Then GUICtrlSetState($Button1, $GUI_ENABLE) GUICtrlSetState($Button2, $GUI_ENABLE) Else GUICtrlSetState($Button1, $GUI_DISABLE) GUICtrlSetState($Button2, $GUI_DISABLE) EndIf Case $Button1 ; wysyłanie jednego SMS $numer_1 = GUICtrlRead($Combo1) $numer_2 = GUICtrlRead($Input1) $nadawca = GUICtrlRead($Input2) $tresc = GUICtrlRead($Input3) Global $oIE = _IECreate("sms.priv.pl", 0, 0) $oSelect = _IEGetObjByName($oIE, "siec") ;select first thing to change _IEFormElementOptionSelect($oSelect, $numer_1, 1, "byText") ;set the data $oObj = _IEGetObjByName($oIE,"number2") ;select second thing to change _IEPropertySet($oObj,"innertext", $numer_2) ;set the data $oObj = _IEGetObjByName($oIE,"tresc") ;select third thing to change _IEPropertySet($oObj,"innertext", $tresc) ;set the data $oObj = _IEGetObjByName($oIE,"od") ;select fourth thing to change _IEPropertySet($oObj,"innertext", $nadawca) ;set the data $oForm = _IEGetObjByName($oIE, "bramka") ;find the send button $oObj = _IEFormSubmit($oForm) ;send sms Sleep(2000) _IEQuit($oIE) Case $Button2 ; wysyłanie wielu SMS $numer_1 = GUICtrlRead($Combo1) $numer_2 = GUICtrlRead($Input1) $nadawca = GUICtrlRead($Input2) $tresc = GUICtrlRead($Input3) Global $oIE = _IECreate("sms.priv.pl", 0, 0) $number = inputbox("Ilosc SMS","Wpisz liczbe od 1 do 30. Pamietaj, dziennie z Twojego IP moze byc wyslane tylko 30 sms. Aby zniesc ten limit skontaktuj sie ze mna przez maila.","",50,100) For $I = 1 to $number ;repeat $number of times $oSelect = _IEGetObjByName($oIE, "siec") ;select first thing to change _IEFormElementOptionSelect($oSelect, $numer_1, 1, "byText") ;set the data $oObj = _IEGetObjByName($oIE,"number2") ;select second thing to change _IEPropertySet($oObj,"innertext", $numer_2) ;set the data $oObj = _IEGetObjByName($oIE,"tresc") ;select third thing to change _IEPropertySet($oObj,"innertext", $tresc) ;set the data $oObj = _IEGetObjByName($oIE,"od") ;select fourth thing to change _IEPropertySet($oObj,"innertext", $nadawca) ;set the data $oForm = _IEGetObjByName($oIE, "bramka") ;find the send button $oObj = _IEFormSubmit($oForm) ;send sms Sleep(2000) Next _IEQuit($oIE) EndSwitch WEnd EndFunc ;---------------------------------------------------------;---------------------------------------------------------;---------------------------------------------------------;------------------------------------------------- While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd I am almost sure that there is better way to do some things I've done, but I can't describe how happy I am that this actually works.
      I also have few ideas how to make the GUI better by using TABS, are they good option? I couldn't find how to make menu with switchable forms.