junkew Posted August 4, 2014 Share Posted August 4, 2014 (edited) Hi, Any suggestions/directions on thoughts on below. Defect or by design? I am working on my UIAWrappers as is in example section but ran into this issue $obj2 is just another objectexpandcollapse popup#include "UIAWrappers.au3" ;~ Reproducer script, not for functional purposes just to reproduce issue $dic=ObjCreate("Scripting.Dictionary") ;~ $obj2=ObjCreate("Scripting.Dictionary") $obj2=ObjCreate("word.application") $obj2.visible=true $dic.add("o1",$obj2) $retrievedObj=$dic("o1") if isobj($retrievedObj) Then consolewrite("Yes, first time its an object" & @CRLF) Else consolewrite("No, first time its NOT an object" & @CRLF) EndIf $dic("o1")=$obj2 $retrievedObj=$dic("o1") if isobj($retrievedObj) Then consolewrite("Yes, 2nd time its an object" & @CRLF) Else consolewrite("No, 2nd time its NOT an object" & @CRLF) EndIf $dic.add("o2",$UIA_oDesktop) $retrievedObj=$dic("o2") if isobj($retrievedObj) Then consolewrite("Yes, 3rd time its an object" & @CRLF) Else consolewrite("No, 3rd time its NOT an object" & @CRLF) EndIf $dic("o2")=$UIA_oDesktop $retrievedObj=$dic("o2") if isobj($retrievedObj) Then consolewrite("Yes, 4th time its an object" & @CRLF) Else consolewrite("No, 4th time its NOT an object" & @CRLF) EndIf ExitWhen I run above I get this as output where I do not understand when using = as assignment suddenly its not an object anymore>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\Elwin\Documents\UIA\testme.au3" /UserParams +>23:24:00 Starting AutoIt3Wrapper v.2.1.0.33 Environment(Language:0413 Keyboard:00020409 OS:WIN_7/Service Pack 1 CPU:X64 OS:X64) >Running AU3Check (3.3.12.0) from:C:\Program Files (x86)\AutoIt3 +>23:24:00 AU3Check ended.rc:0 >Running:(3.3.12.0):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\Elwin\Documents\UIA\testme.au3" --> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop Yes, first time its an object No, 2nd time its NOT an object Yes, 3rd time its an object No, 4th time its NOT an object +>23:24:01 AutoIT3.exe ended.rc:0 >Exit code: 0 Time: 2.018Only difference is that $UIA_Desktop is created with function ObjCreateInterfaceI have now worked around this in _UIA_setVar by removing first from dictionary and then re addingI think in the past in AutoIT (I think in version before december 2013) all 4 above would give Yes. Below is to reproduce only with Word.Application (weird thing when I use scripting.dictionary as obj2 it works correctly);~ Reproducer script, not for functional purposes just to reproduce issue $dic=ObjCreate("Scripting.Dictionary") ;~ $obj2=ObjCreate("Scripting.Dictionary") $obj2=ObjCreate("word.application") $obj2.visible=true $dic.add("o1",$obj2) $retrievedObj=$dic("o1") if isobj($retrievedObj) Then consolewrite("Yes, first time its an object" & @CRLF) Else consolewrite("No, first time its NOT an object" & @CRLF) EndIf $dic("o1")=$obj2 $retrievedObj=$dic("o1") if isobj($retrievedObj) Then consolewrite("Yes, 2nd time its an object" & @CRLF) Else consolewrite("No, 2nd time its NOT an object" & @CRLF) EndIf Edited August 4, 2014 by junkew FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Administrators Jon Posted August 4, 2014 Administrators Share Posted August 4, 2014 With the 2nd script on 3.3.8.1 I get a Yes and then a No. So, are you sure this has changed? That version is from Dec 2011. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
junkew Posted August 5, 2014 Author Share Posted August 5, 2014 (edited) No unfortunately I am not sure.Do you agree that it should logically be a 4 times yes?I am working on the UIAWrapper stuff and somewhere in december/january my logic was broken but all the time I thought I was making a logic error myself and just last week I investigated further and was able to reproduce with a sample script making life easier that its not in my UIAWrapper logic.At least my functional expectation is that I should get back 4 times yes (for 2nd script 2 times yes)the silly thing is that when i set $obj2 to this object I do get 4 times yes which is similar to word.application object that gives a one time no.$obj2=ObjCreate("Scripting.Dictionary") Edited August 5, 2014 by junkew FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Administrators Jon Posted August 5, 2014 Administrators Share Posted August 5, 2014 I don't know if the property assignment is supposed to work that way or not. I'm only concerned at the moment if something that was working is no longer working. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
junkew Posted August 5, 2014 Author Share Posted August 5, 2014 in VBA it works that way (so 2 times yes) http://msdn.microsoft.com/en-us/library/x4k5wbx4(v=vs.84).aspx states A Dictionary object is the equivalent of a PERL associative array. Items can be any form of data, and are stored in the array. Each item is associated with a unique key. The key is used to retrieve an individual item and is usually an integer or a string, but can be anything except an array. and a page with many examples of assignments in VBAhttp://www.snb-vba.eu/VBA_Dictionary_en.html reproducer in VBA Sub reproduce() Set dic = CreateObject("Scripting.Dictionary") ' obj2=createobject("Scripting.Dictionary") Set obj2 = CreateObject("word.application") obj2.Visible = True dic.Add "o1", obj2 Set retrievedObj = dic("o1") If IsObject(retrievedObj) Then Debug.Print "Yes, first time its an object" & vbCrLf Else Debug.Print "No, first time its NOT an object" & vbCrLf End If Set dic("o1") = obj2 Set retrievedObj = dic("o1") If IsObject(retrievedObj) Then Debug.Print "Yes, 2nd time its an object" & vbCrLf Else Debug.Print "No, 2nd time its NOT an object" & vbCrLf End If End Sub output in VBA Excel 2010 Yes, first time its an object Yes, 2nd time its an object FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Administrators Jon Posted August 5, 2014 Administrators Share Posted August 5, 2014 I found a piece in the code that makes this work. I'll try it in the next beta, to see if it has unintended consequences. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
junkew Posted August 5, 2014 Author Share Posted August 5, 2014 ok. thx FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets 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