AJB

"Error: Variable must be of type object" on new machine

4 posts in this topic

Hello,

I've been using autoit for about a year now and overall it's been great despite my limited understanding of all of its features. I have several scripts that run on virtual machines that have been running smoothly for several months without any issues. Recently, I had to create new virtual machines and migrate my scripts over and now I am getting errors that I can't seem to repeat, but seem to happen at least once a day with all of my executables that were flawless before.

The error that I keep getting is:

Autoit Error

Line [this number varies per script] (File "[path to my executable]"); Error: variable must be of type object.

I  never received this error before until I moved everything to the new VMs, and when I rerun my scripts after clearing the error everything seems to work and run fine until hours later or sometimes the next day. I am assuming that that the root cause may be in some kind of settings on the VM itself since it is happening nearly across the board, but I have no idea where to even look. These are running on Windows 7, which is what they were running on before I had any errors.

The only consistent include used in these scripts is  IE.au3

Has anyone run into a similar problem or can maybe point me in the right direction. I am at the point of pulling hair out trying to resolve this. I have even rewritten and re-compiled the scripts to see if somehow the executables got corrupted, but that didn't help.

Thank you.

Share this post


Link to post
Share on other sites

@AJB the error is telling you exactly what is wrong - you're calling a variable that is not an object. Unfortunately, more than that is impossible if you do not post your script.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hello,

 I have a similar problem but I received this error when moved from Windows 7 / IE7 / 32bit to Windows 7 / IE11 / 64 bit machine.

The script selects one of  4 dropdown options in the loop and randomly the third or fourth gets this error when in FireBug you can see all of them and if

_IEFormElementOptionSelect() is not called, Console write will print all of them

Here is the code:

$oForm = _IEFormGetObjByName($oIE, "myform")
$tp = _IEFormElementGetObjByName($oForm, "target")
If @error = "0" Then
    $cc = 0
    _IEAction($tp, "focus")
    For $t In $tp
        $cc = $cc + 1
        ConsoleWrite("count: " & $cc & @CRLF)


        If $cc = 1 Then
            ConsoleWrite(_IEPropertyGet($t, "outerhtml") & @CRLF)
            ConsoleWrite("innerText: " & $t.innerText & @CRLF)
            ;If ($t.innerText) <> "" Then
            ConsoleWrite("innerText: " & $t.innerText & @CRLF)
            _IEFormElementOptionSelect($tp, "Coldstore", 1, "byText")
            ;EndIf
            Sleep(1000)
        ElseIf $cc = 2 Then
            ConsoleWrite(_IEPropertyGet($t, "outerhtml") & @CRLF)
            ConsoleWrite("innerText: " & $t.innerText & @CRLF)
            ;If ($t.innerText) <> "" Then
            ConsoleWrite("innerText: " & $t.innerText & @CRLF)
            _IEFormElementOptionSelect($tp, "Windows File Share/SMB", 1, "byText")
            ;EndIf
            Sleep(1000)
        ElseIf $cc = 3 Then
            ConsoleWrite(_IEPropertyGet($t, "outerhtml") & @CRLF)
            ConsoleWrite("innerText: " & $t.innerText & @CRLF)
            ;If ($t.innerText) <> "" Then
            ConsoleWrite("innerText: " & $t.innerText & @CRLF)
            _IEFormElementOptionSelect($tp, "Internal SD card", 1, "byText")
            ;EndIf
            Sleep(1000)
        ElseIf $cc = 4 Then
            ConsoleWrite(_IEPropertyGet($t, "outerhtml") & @CRLF)
            ConsoleWrite("innerText: " & $t.innerText & @CRLF)
            ;If $t.innerText <> "" Then
            ConsoleWrite("innerText: " & $t.innerText & @CRLF)
            _IEFormElementOptionSelect($tp, "none", 1, "byText")
            ;EndIf

        EndIf
    Next
EndIf

Output:

count: 1
<option value="coldstore">Coldstore
innerText: Coldstore
innerText: Coldstore
count: 2
--> IE.au3 T3.0-1 Error from function _IEPropertyGet, $_IESTATUS_InvalidObjectType
0
innerText:
innerText:
"C:\Program Files (x86)\AutoIt3\Include\IE.au3" (1115) : ==> Variable must be of type "Object".:
For $oItem In $oItems
For $oItem In $oItems^ ERROR

You can see that I commented check for an empty string.

If I uncomment it, I won't receive the error "Variable must be of type "Object".:" but I won't be able to select all options in loop in the dropdown.

The output will be with the 2 options available and 2 empty strings:

count: 1
<option value="coldstore" selected="">Coldstore
innerText: Coldstore
innerText: Coldstore
count: 2
<option value="wfs">Windows File Share/SMB
innerText: Windows File Share/SMB
innerText: Windows File Share/SMB
count: 3
--> IE.au3 T3.0-1 Error from function _IEPropertyGet, $_IESTATUS_InvalidObjectType
0
innerText:
count: 4
--> IE.au3 T3.0-1 Error from function _IEPropertyGet, $_IESTATUS_InvalidObjectType
0
innerText:

Any help will be appreciated!!!!!!

Edited by Melba23
Added code tags

Share this post


Link to post
Share on other sites

seeker0718,

Welcome to the AutoIt forums.

When you post code please use Code tags - see here how to do it.  Then you get a scrolling box and syntax colouring as you can see above now I have added the tags.

M23

 


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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

  • Similar Content

    • Robdog1955
      By Robdog1955
      I'm trying to click a button on a web page. I have added a couple of MsgBox lines to allow me to watch what happens on the page. As you can see the first half of my script enters data into text boxes on the page. I have no problem there. I just cannot click on the region buttons. The "set focus" line causes an outline to appear around the EU button and the "click button" line causes the "Pick a Region" text to disappear. Here is the code I have so far.
      #include <IE.au3> Local $oIE = _IECreate("http://questchecker.com/") Local $iQuestID = "123456" Local $sCharacterName = "CharacterName" Local $colForms = _IEFormGetCollection($oIE) $iCount = 0 For $oForm In $colForms $oFormElements = _IEFormElementGetCollection($oForm) For $oFormElement In $oFormElements $iCount = $iCount + 1 Local $sTagName = StringLower($oFormElement.tagName) Local $sElementType = $oFormElement.type Local $sElementName = $oFormElement.name Switch $iCount Case 6 _IEFormElementSetValue($oFormElement, "MyRealm", 0) ; realm Case 7 _IEFormElementSetValue($oFormElement, $sCharacterName, 0) Case 8 _IEFormElementSetValue($oFormElement, $iQuestID, 0) EndSwitch Next Next Local $oButtons = _IEGetObjByName($oIE, "questForm") For $oButton In $oButtons If _IEFormElementGetValue($oButton) = "US" Then MsgBox(0, "", "Click Okay to set focus") _IEAction($oButton, "focus") MsgBox(0, "", "Click Okay to click button") _IEAction($oButton, "click") ExitLoop EndIf Next MsgBox(0, "", "Click Okay to quit") _IEQuit($oIE) Exit  
    • Dent
      By Dent
      As the title says. I open IE11 and navigate to a page with the following HTML5 file upload container in Capture0.JPG
      I want to click Add Files but I haven't been able to. Here's the code that handles the Add Files button in Capture.JPG
      _IEGetObjectById and then using _IEAction to click it doesn't work. I can't give access to the actual page unfortunately because it's password protected.
      All suggestions welcome.


    • Kevin Finnegan
      By Kevin Finnegan
      Hi all,
      Long time lurker and now forum poster! I'm writing a relatively simple backup script for my firm that automates the copy, compression and organization of Leaver's data on one of our secured NAS systems. I personally found the best method to do this so far was to use 7zG.exe (GUI version of 7Zip which can use command-line too) and it functions quite well!
      I would like to retrieve more info on whether any warnings or errors happen in 7Zip during the backup, but I can't quite get my head around the syntax and switches for reading out, it seems any adjustment I make to the RunWait call's string seems to break the backup or give unexpected repercussions! Hopefully its something silly I'm doing as I don't code very often.
      Here is the working version:
      ; Compress the directories one by one in the zip using the listfile.... Local $iPID = RunWait(@ScriptDir & "\bin\7zG.exe a -mx" & $compressionQuality & " -v" & $compressSplitFileSize & " -wc:\temp " _ & $backupToLocation & "\" & $userDirectory & ".7z @bin\listfile.txt -x@bin\excludefile.txt", "", @SW_SHOWDEFAULT, $STDOUT_CHILD) Ultimately I would love to switch entirely to 7za.exe (standalone) so that I can read the progress percentage, current file being uploaded and any warnings or errors could be processed and output to the AutoIT script's GUI I've created rather than jumping in and out of two applications per se.
       
    • milos83
      By milos83
      I have one script that creates _IECreateEmbedded and another script that does _IEAttach.
      I do this because when autoit is doing something, the Embedded IE starts stalling (eg jquery progress animation)
      But there is a new problem.
      When IE is having its own process (like in the example above) any _IE command is slow (in the script that Attaches).
      Here is a comparison of when its in separate and when its in same process:
      Separate process _IETagNameGetCollection : 5000ms
      Separate process _IEAction: 850ms
      Same process _IETagNameGetCollection : 1ms
      Same proccess _IEAction: 135ms
       
      If I try to attach to an embedded IE that is done in c#, I get lightning fast results.
      As you can see, _IE functions work very slow when the embedded IE we are attaching to is made in Autoit.
       
      I did a test and if I empty the WHILE loop in IE process I get these results(but the cpu is at 30% as expected):
      Separate process _IETagNameGetCollection : 33ms
      Separate process _IEAction: 13ms
       
      It slows down if you put anything (like GUIGetMsg) in the WHILE loop.
       
      How do I fix this?
       
      Create IE:
      #include <GUIConstantsEx.au3> #include <IE.au3> #include <WindowsConstants.au3> Local $oIE = _IECreateEmbedded() GUICreate("My Embedded Web control Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) GUICtrlCreateObj($oIE, 10, 40, 600, 360) GUISetState(@SW_SHOW) ;Show GUI _IENavigate($oIE, "http://www.autoitscript.com") $timer = TimerInit() $oLink = _IETagNameGetCollection($oIE, "a", 3) ;takes 1ms ConsoleWrite(TimerDiff($timer) & @CRLF) $timer = TimerInit() _IEAction($oLink, "click") ;takes 135ms ConsoleWrite(TimerDiff($timer) & @CRLF) While 1 Local $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd  
      Attach to IE:
      #include <IE.au3> Local $oIE = _IEAttach("My Embedded Web control Test", "embedded") $timer = TimerInit() $oLink = _IETagNameGetCollection($oIE, "a", 3) ; 5000ms ConsoleWrite(TimerDiff($timer) & @CRLF) $timer = TimerInit() _IEAction($oLink, "click") ; 850ms ConsoleWrite(TimerDiff($timer) & @CRLF)  
       
      attach.au3
      create.au3
    • nassausky
      By nassausky
      Hi all,
       
      Anyone have any idea how to close all open tabs except a specific one I manually open.  Assuming I don't know what is open in all the tabs except just the one I want to keep open.
       
      I didn't want to use sendkeys and I was trying to use the following code to list the title (or url) of the 3 open tabs and  after I got that part working I would just close the other 2. This sample only displays the title of the first open tab
      #include <IE.au3> Const $ie_new_in_tab = 0x0800 $oIE = _IECreate("https://www.autoitscript.com") __IENavigate($oIE, "https://www.autoitscript.com/forum/", 1, $ie_new_in_tab) ;(obj,url,wait,param) __IENavigate($oIE, "https://www.google.com/", 1, $ie_new_in_tab) ;(obj,url,wait,param) Local $aIE[1] $aIE[0] = 0 Local $i = 1, $oIE While 1     $oIE = _IEAttach("", "instance", $i)     If @error = $_IEStatus_NoMatch Then ExitLoop     ConsoleWrite(_IEPropertyGet($oIE, "title") & @CRLF)     ReDim $aIE[$i + 1]     $aIE[$i] = $oIE ;each item holds object     $aIE[0] = $i ;first item holds count     $i += 1 WEnd MsgBox($MB_SYSTEMMODAL, "Browsers Found", "Number of browser instances in the array: " & $aIE[0]) ; This doesn't return the list of tabs in the console just the first tab  
      Thanks for any and all help