faiz Posted May 17, 2012 Share Posted May 17, 2012 Hi, I am trying out AutoIt to access a program called Pipesim. According to the authors: "PIPESIM has been designed with "Openness" in mind. Therefore key modules can be "driven" from 3rd party applications, for example, Microsoft Excel, VB, C++, and so on." one of the calls/commands i make is .GetNameList () From the documentation of Pipesim: GetNameList (ObjectType As Long, pNameArray, Count As Long) OLE/COM Object viewer gives this information about this method: void GetNameList( [in] long ObjectType, [out] VARIANT* pNameArray, [out] long* Count); My AutoIt script uses this as : $p.GetNameList(7, $list, $count) $list returns are an array with index 0 to 26 (matches the $count with returns 27). Elements $list[1] to [26] do contains the proper string values (e.g. 'RB-136H') but element [0] contains a left pointing arrow (seems to be line feed since when I copied it from the output of ConsoleWrite and pasted it here it takes me to a new line with no visible character). Another Get method ( for which OLE/COM Object viewer says ): VARIANT_BOOL GetPropertyStringAtObjectIndex( [in] BSTR ObjectName, [in] BSTR ParentName, [in] BSTR PropName, [out] BSTR* pValue, [in] long Index); It returns pValue with a value of '??\' Are these limitations of AutoIt w.r.t. COM or am I doing something wrong? Thanks for any insight into this. This will really decide if we adopt AutoIt as our chosen scripting solution of choice. It has given us an extremely good impression otherwise. The functions work fine with Excel/VBA but have problems with VBScript. Regards, Faiz Link to comment Share on other sites More sharing options...
water Posted May 20, 2012 Share Posted May 20, 2012 (edited) I think $list[0] has a different data type. Is the data you get in elements $list[1] to [26] complete or is there some data missing? You could try to determine the datatype of element $list[0] by using the following functions:ConsoleWrite("IsArray: " & IsArray($list[0]) & @CRLF) ConsoleWrite("IsObj: " & IsObj($list[0]) & @CRLF) ConsoleWrite("IsPtr: " & IsPtr($list[0]) & @CRLF) Edited May 20, 2012 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
faiz Posted June 21, 2012 Author Share Posted June 21, 2012 water: thanks for replying. Sorry for coming back so late. :-(I "ConsoleWrite" the count, the value of each element and then the code you suggested and get this:count = 27list(0) list(1) RB-136Hlist(2) RB-104Vlist(3) RB-138Hlist(4) RB-154Hlist(5) RB-266Hlist(6) RB-265Vlist(7) RB-267Hlist(8) RB-268Hlist(9) RB-208Hlist(10) RB-93Hlist(11) RB-17Vlist(12) RB-209Hlist(13) RB-210Hlist(14) RB-225Hlist(15) RB-233Vlist(16) RB-226HSTlist(17) RB-307Hlist(18) RB-308Hlist(19) RB-207Hlist(20) RB-202Hlist(21) RB-92Vlist(22) RB-311HSTlist(23) RB-115list(24) RB-84Vlist(25) RB-309Hlist(26) RB-203HIsArray: 0IsObj: 0IsPtr: 0I the data from elements $list[1] to [26] is correct but I am missing the first data (which I expected to be in [0]). Thanks for any pointers/help. Really appreciate it. Link to comment Share on other sites More sharing options...
faiz Posted June 21, 2012 Author Share Posted June 21, 2012 (edited) The list gave a character that looks like a left pointing arrow but what I copied from my console output and pasted it into this post it was (is) not visible. I then also tried: ConsoleWrite("VarType: " & VarGetType($list[0]) & @CRLF) and got: VarType: String Edited June 21, 2012 by faiz Link to comment Share on other sites More sharing options...
water Posted June 21, 2012 Share Posted June 21, 2012 ← (left arrow) is the character representation for 27. So it's the number of elements in the array. So the array seems to be a one-based array having the number of elements in element[0] and starting data with element[1]. What do you get if you access elements 27 and 28 of your array? ConsoleWrite($list[27]) & @CRLF) ; Should give you a correct output ConsoleWrite($list[28]) & @CRLF) ; Should return an error My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
faiz Posted June 21, 2012 Author Share Posted June 21, 2012 Hi! Earlier I tried to run the loop from 0 to $count instead of $count - 1. It returned an error.After your suggestion I get :ConsoleWrite("27" & $list[27] & @CRLF)ConsoleWrite("27" & ^ ERROR Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded. Link to comment Share on other sites More sharing options...
water Posted June 21, 2012 Share Posted June 21, 2012 Strange Element[0] contains the number of returned records = 27. They would be stored in Element[1] to Element[27]. But you can only access up to Element[26]. Could you query another object type (now you query type 7) so we can see what changes? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted June 21, 2012 Share Posted June 21, 2012 (edited) My AutoIt script uses this as : $p.GetNameList(7, $list, $count)How do you create $p? Like this? ; Declare Network Model Object $NetModel = CreateObject("NET32COM.INETMODEL") ; Load model into Object $NetModel.OpenModel($ModelInput) Edited June 21, 2012 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
faiz Posted June 21, 2012 Author Share Posted June 21, 2012 (edited) Dim $m, $list, $count $m = "e:....trunk.bpn" $p = ObjCreate("Net32COM.INetModel") $p.OpenModel($m) $p.GetNameList(7, $list, $count) ConsoleWrite("count = " & $count & @LF) for $i = 0 to $count - 1 ConsoleWrite("list(" & $i & ") " & $list[$i] & @LF) next ConsoleWrite("IsArray: " & IsArray($list[0]) & @CRLF) ConsoleWrite("IsObj: " & IsObj($list[0]) & @CRLF) ConsoleWrite("IsPtr: " & IsPtr($list[0]) & @CRLF) ConsoleWrite("VarType: " & VarGetType($list[0]) & @CRLF) ConsoleWrite("27" & $list[27] & @CRLF) ; Should give you a correct output ConsoleWrite("28" & $list[28] & @CRLF) ; Should return an errorCOmplete code is like this: Edited June 21, 2012 by faiz Link to comment Share on other sites More sharing options...
water Posted June 21, 2012 Share Posted June 21, 2012 One thing to try. When you define $list as you do now it is just a string. Let's define it as an array and see what happens: Global $m, $list[100], $count $m = "e:....trunk.bpn" $p = ObjCreate("Net32COM.INetModel") ConsoleWrite(@error & @CRLF) $p.OpenModel($m) ConsoleWrite(@error & @CRLF) $p.GetNameList(7, $list, $count) ConsoleWrite(@error & @CRLF) ConsoleWrite("count = " & $count & @LF) for $i = 0 to $count - 1 ConsoleWrite("list(" & $i & ") " & $list[$i] & @LF) next My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
faiz Posted June 21, 2012 Author Share Posted June 21, 2012 Error Subscript used with non-Array variable (in the ConsoleWrite line in the for loop) Link to comment Share on other sites More sharing options...
water Posted June 22, 2012 Share Posted June 22, 2012 And what's the output of all the ConsoleWrites? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted June 22, 2012 Share Posted June 22, 2012 (edited) Another idea: When searching the Web I found the following VB script. If you get this running then it is an AutoIt problem else I think it could be a Pipesim bug.In this PDF you can find another (larger) example. Edited June 22, 2012 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
faiz Posted June 22, 2012 Author Share Posted June 22, 2012 To your earlier question: there is no output (except the count output before the loop) since it hits the error. The VB Script & PDF are part of my history with this. The PDF contains Excel/VBA example, and it works for me too. In fact that is the solution we used and I left this forum for over a month! The VB Script is from a colleague and it does not work. This triggered an interest in an alternative and I googled and found AutoIt! AutoIt was better than VBScript since gave a Type Mismatch on the call which AutoIt does execute it and return everything, except the first element of the list. I suspect it is the way arguments are handled in AutoIt specially when using with calls to COM objects. I can get some insight from an expert like you. Link to comment Share on other sites More sharing options...
water Posted June 22, 2012 Share Posted June 22, 2012 (edited) I forgot to ask. Which version of AutoIt do you use? Could you please run this line of code?ConsoleWrite(@AutoItVersion & @CRLF)Unfortunately I'm not very familiar with VBA and the AutoIt data structures. So I'm slowly running out of ideas Edited June 22, 2012 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
faiz Posted June 22, 2012 Author Share Posted June 22, 2012 3.3.8.1 Actually just mow i was going to see if there is a new version... Link to comment Share on other sites More sharing options...
water Posted June 22, 2012 Share Posted June 22, 2012 There is a new beta (3.3.9.4) available here. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
faiz Posted June 22, 2012 Author Share Posted June 22, 2012 SAme result. :-( Link to comment Share on other sites More sharing options...
water Posted June 22, 2012 Share Posted June 22, 2012 (edited) The code you posted misses a COM error handler. Let's try this: Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Global $m, $list[100], $count $m = "e:....trunk.bpn" $p = ObjCreate("Net32COM.INetModel") $p.OpenModel($m) $p.GetNameList(7, $list, $count) ConsoleWrite("count = " & $count & @LF) For $i = 0 to $count - 1 ConsoleWrite("list(" & $i & ") " & $list[$i] & @LF) Next ConsoleWrite("27" & $list[27] & @CRLF) ; Should give you a correct output Exit Func _ErrFunc($oError) ConsoleWrite("err.number is: " & @TAB & $oError.number & @CRLF & _ "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ "err.description is: " & @TAB & $oError.description & @CRLF & _ "err.source is: " & @TAB & $oError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ "err.retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF) EndFunc ;==>_ErrFunc Edited June 22, 2012 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
faiz Posted June 22, 2012 Author Share Posted June 22, 2012 I do not get any error reporting. Only the same error as before when the code refers to $list[27] 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