Jump to content
Sign in to follow this  
redrum

Silverlight, Cannot find Controls

Recommended Posts

redrum

Hello,

Could you give me some direction on this please.  I'm using stock chart program "TC2000",  available on website TC2000.com.  This application can be run in browser, or downloaded and run outside a browser.  I've tried to use AutoIt Window Info Tool, SPY++, UISPY and ManagedSpy to find controls but have not been sucessful.  Also, have gone through all threads pulled up by Silverlight search on the Forum.

I have a very simple script to write, which will read the "Active Chart Symbol" from the screen.  Is there a way to get the controls for the data window for the symbol, so I can use it in an AutoIt script?  I have tried the in-browser and out-of-browser versions of this program and cannot view any control info.  I am successful in sending characters to the program to do various types of control with hot keys.

Thanks,

Doug

 

Share this post


Link to post
Share on other sites
redrum

Thanks for the quick response.  This is looking a little overwhelming right now, but I'm working toward understanding how to try this approach.  Have downloaded the files so far, and am studying the links - likely some questions later.  Once I can succeed in getting controls I'm off and running.

Share this post


Link to post
Share on other sites
redrum

Trying to run SimpleSpy, but getting an undefined function error on this statement:

$UIA_CodeArray = FileReadToArray($hFileOpen)

Could you help with this issue please?

Share this post


Link to post
Share on other sites
redrum

Thanks,

Have SimpleSpy working now and showing control information in my Silverlight application.  I will now try and understand this info and try to read a data field on the screen with AutoIt script.

Regards,

Doug

Share this post


Link to post
Share on other sites
redrum

post-55107-0-66451400-1408762458_thumb.pActiveSymbol_HON_Info.txt

Hello,

I'm making good progress on this, and it appears that this approach will allow me to read/write to data fields on the chart screen of TC2000 program.  Attached is a screen shot of the chart.  I put the cursor on the "active chart symbol", which in this case is "HON" in yellow, and ran SimpleSpy.  I copied the controls information retrieved by SimpleSpy into a Notepad document, which I have attached for reference.

Presently I am studying the examples, but am having a difficult time understanding them.  I need to understand how to create the AutoIt code to access the active symbol using the controls.  Can anyone provide some additional direction such as information/links to study to help me code this?  Once I can understand how to code the retrieval of the active symbol, there are many other controls on this charting program that I plan to implement.

Thanks in advance

Doug

Share this post


Link to post
Share on other sites
junkew

so in your attachment the spy gave the code. did you try to run that?

;*** Standard code ***
#include "UIAWrappers.au3"
AutoItSetOption("MustDeclareVars", 1)

Local $oP4=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=TC2000 ® Beta 12.4.5235.25989;controltype:=UIA_WindowControlTypeId;class:=Afx:00F30000:0", $treescope_children)  
_UIA_Action($oP4,"setfocus")
Local $oP3=_UIA_getObjectByFindAll($oP4, "Title:=;controltype:=UIA_PaneControlTypeId;class:=Shell Embedding", $treescope_children)  
_UIA_Action($oP3,"setfocus")
Local $oP2=_UIA_getObjectByFindAll($oP3, "Title:=;controltype:=UIA_PaneControlTypeId;class:=Shell DocObject View", $treescope_children) 
_UIA_Action($oP2,"setfocus")
Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=file://C:\Users\Doug\AppData\Local\Microsoft\Silverlight\OutOfBrowser\1350570325.www.tc2000.com\index.html;controltype:=UIA_PaneControlTypeId;class:=Internet Explorer_Server", $treescope_children)   
_UIA_Action($oP1,"setfocus")
Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=Silverlight Control;controltype:=UIA_WindowControlTypeId;class:=MicrosoftSilverlight", $treescope_children)    
_UIA_Action($oP0,"setfocus")
;~ First find the object in the parent before you can do something
;~$oUIElement=_UIA_getObjectByFindAll("HON.mainwindow", "title:=HON;ControlType:=UIA_TextControlTypeId", $treescope_subtree)
Local $oUIElement=_UIA_getObjectByFindAll($oP0, "title:=HON;ControlType:=UIA_TextControlTypeId", $treescope_subtree)
_UIA_action($oUIElement,"click")

I updated recently the first post on iuiautomation with some directions but above code as given by spy should give you a quickstart and after that it comes on how to make your code clean and maintainable which is different in the examples. The latest examples give more maintainable source but if its just a quick script above should be fine as a starting point.

Share this post


Link to post
Share on other sites
redrum

I was not sure what the code statements in SimpleSpy were for.  Also, I tried Ctrl-R, and could not figure out what it is doing.  Does it store the code in a file?  Maybe I missed some instructions somewhere.

Yes, I will go back and study the first post, as I have larger plans for automation of this program and want it maintainable.  A week ago I didn't think it was possible to even interact with controls on this, so many thanks for your work developing this capability and your support.

Share this post


Link to post
Share on other sites
redrum

Working my way through some examples, and running into the same error as when I try to run the example code on my TC2000 application.  I run ex4, the clock example w/notepad and get error message on console.

Attached files for reference:

- ex4 Example Script (with button names edited)

- Screenshot of Calculator and Notepad windows that opened when ex4 script executed

 -Text file of the console error message

I think this is some setup issue I have that is affecting any example I run.  Could you help please?

Also Question:  Is there a description of these new UI automation commands that I can use for understanding?

Thanks,

Doug

ex4_calculator.au3

post-55107-0-18733400-1408810307_thumb.p

ex4_errorMsg.txt

Share this post


Link to post
Share on other sites
redrum

Sorry, I figured out the error message issue I had with ex4 in prior post - I used the button labels instead of the button titles when editing them for language!  I have ex4 running correctly now.

Now, just wondering if there is descriptions of the new UI automation commands.

Share this post


Link to post
Share on other sites
redrum

Making progress on script to read active symbol from TC2000 screen shot as previously provided.  I believe I have successfully gotten the active symbol element, which is a text display.  Attached are 3 files:  the controls from SimpleSpy (copied into a Word file), a script which is WIP, and a text file with the console display results of the last run of the script.

I have 2 specific questions at this point: 1- I don't know how to extract the symbol text from the element (and I'm not 100% sure I have the correct element).   2- How do I use the "dump all" statement and where does the data go to.  Will this dump give me info on how to extract the symbol text and assign it to a variable?

Requesting a quick look at this and would appreciate any advice for moving forward.

Thanks again,

Doug

ActiveSymbol_HON_Info.doc

TC2000_ActSym_StdCode.au3

ActSym script console results.txt

Share this post


Link to post
Share on other sites
junkew

I think you came close. 

Question 0 how to be sure if you have right object

  • Make sure you have all information retrieved with the spy and your object highlights
  • Then in your script use setfocus if proper area highlights you can be sure
  • Use _UIA_dumpThemAll an compare the information with the spyinformation
    BoundingRectangle, Title, ControlType, Name  are properties to almost uniquely identify your control

 

 Question 1

get one single property

_UIA_getPropertyValue($UIA_oDesktop, $UIA_NamePropertyId)
  • check Local $UIA_propertiesSupportedArray[117][2] in UIAWrappers.au3 for all properties
    All property values are dumped with simple spy so you can see which ones you want to use
  • Ctrl+R is not yet doing anything in simplespy

 

Question 2

Check in log.txt file which shows you all information.

syntax _UIA_DumpThemAll(<ObjectReference> <treescope>)

.

 

  • You are in the right direction so maybe look not yet at below (could be confusing)

 

Alternative syntax (when you come to the more advanced examples) which is with more magic behind the scenes.

You can follow what happens in log.txt 

AutoItSetOption("MustDeclareVars", 1)

;~ Make descriptive GUI references for the technical definition and put them in the reference runtime table
local $UID_TC2000[5][2] = [ _
["mainwindow","Title:=TC2000 ® Beta 12.4.5235.25989;controltype:=UIA_WindowControlTypeId"], _
["oP3","Title:=;controltype:=UIA_PaneControlTypeId;class:=Shell Embedding"], _
["oP2","Title:=;controltype:=UIA_PaneControlTypeId;class:=Shell DocObject View"], _
["oP1","Title:=file://C:\Users\Doug\AppData\Local\Microsoft\Silverlight\OutOfBrowser\1350570325.www.tc2000.com\index.html;controltype:=UIA_PaneControlTypeId;class:=Internet Explorer_Server"], _
["oP0","Title:=Silverlight Control;controltype:=UIA_WindowControlTypeId;class:=MicrosoftSilverlight"] _
]
_UIA_setVarsFromArray($UID_TC2000,"TC2000.")

;~ Put a script in an array / could also be loaded from a script file
local $script[50][10]= [ _
["tc2000.mainwindow", "setfocus"], _
["tc2000.oP3","setfocus"], _
["tc2000.oP2","setfocus"], _
["tc2000.oP1","setfocus"], _
["tc2000.oP0","setfocus"]_
]
_UIA_launchScript($script)


Local $oUIElement=_UIA_Action("tc2000.oP0","getobject")
_UIA_DumpThemAll($oUIElement, $TreeScope_Subtree)
Edited by junkew

Share this post


Link to post
Share on other sites
redrum

Thanks, working on it - "Title" of the element is actually the Active Symbol I want to retrieve, so can't use title in finding element (it changes).  Tried adding bounding rectangle and no object resulted.  So far, have not isolated the correct element.  Did a dump of the parent and am studying - probably will need to use some kind of index access to the element if nothing else works.

Will continue.

Share this post


Link to post
Share on other sites
junkew

I do not know what you exactly mean with the Active Symbol element. If you can highlight it with the spy you can automate it.

But as you cannot find by title/name you probably have to use a treewalker to get details of your elements.

_UIA_DumpThemAll is having one example but could be you need other way of treewalking.

Share this post


Link to post
Share on other sites
redrum

Hello,

I think I am going to have to figure out how to use the automationid info in order to isolate the elements I want. I did a dump of the P0 element, and almost everything I am interested in is under P0, basically the entire chart.  Looking at the dump, I see that there is so much commonality in the controls, that the ONLY item that seems to be unique between the elements is the automationid.  I suppose that is because this entire chart screen is full of places to click on for different displays and results.

Attached is the P0 dump in a MS Word doc.  Is there any other way of selecting an element in this dump of P0?

I'm continuing to read/study to find out how to use the automationid for a parameter in the _UIA_getObjectByFindAll controls string.  I tried "$UIA_AutomationIdPropertyId:=theText" and it did not produce an object.

 

 

Dump P0.doc

Share this post


Link to post
Share on other sites
redrum

Wow, looks like we posted at the same time.  The "Active Symbol"  is the stock symbol being displayed on the chart - in this case, in the dump, it is "HON" which is Honeywell.

Share this post


Link to post
Share on other sites
junkew

maybe indexrelative is an option which gives you the n-th element after another element

title:=DAILY Position;indexrelative:=8

For me its real hard to understand what you try to accomplish as I do not have the application you are working on

And I do not put all properties in the log.txt dump (that would be to much for an overkill).

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  

  • Similar Content

    • Suhotro
      By Suhotro
      We need to automate Silverlight Application. Can we use AutoIT for the same? If yes then how?
    • Nessie
      By Nessie
      Here is another UDF . With this UDF now you can check if a specified browser/software is installed an you are also able to get what version is in used.

      Supported Software: Internet Explorer, Mozilla Firefox, Mozilla Thunderbird, Google Chrome, Opera, Safari, Java and Silverlight.

      Changelog

      v.1.2.0 (08/05/2013) Fixed Huge code improvements ;Thnks to guinness for the suggestion Fixed Wrong return value if path ends with a backslash ;===================================================== v.1.1.0 (06/04/2013) Added _NavInfo_GetFirefoxLocation Added _NavInfo_GetThunderbirdLocation Added _NavInfo_GetChromeLocation Added _NavInfo_GetOperaLocation Added _NavInfo_GetSafariLocation Added _NavInfo_GetJavaLocation ;===================================================== v.1.0.1 (16/03/2013) Fixed _NavInfo_IsOperaInstalled Thanks to guinness for bug report Added _NavInfo_GetDefaultBrowser Added _NavInfo_GetIEVersion ;===================================================== v.1.0.0 (16/03/2013) Initial Release
      Here is the current function:

      ;_NavInfo_GetDefaultBrowser ;_NavInfo_GetIEVersion ;_NavInfo_IsFirefoxInstalled ;_NavInfo_GetFirefoxVersion ;_NavInfo_IsThunderbirdInstalled ;_NavInfo_GetThunderbirdVersion ;_NavInfo_IsChromeInstalled ;_NavInfo_GetChromeVersion ;_NavInfo_IsOperaInstalled ;_NavInfo_GetOperaVersion ;_NavInfo_IsSafariInstalled ;_NavInfo_GetSafariVersion ;_NavInfo_IsJavaInstalled ;_NavInfo_GetJavaVersion ;_NavInfo_IsSilverlightInstalled ;_NavInfo_GetSilverlightVersion
      Some example:

      #include "NavInfo.au3" $Default_Browser = _NavInfo_GetDefaultBrowser() If Not @error Then MsgBox(0, "Default Browser", $Default_Browser) EndIf $IE_Version = _NavInfo_GetIEVersion() If Not @error Then MsgBox(0, "Internet Explorer", "Internet Explorer version: " & $IE_Version) EndIf $Is_Firefox = _NavInfo_IsFirefoxInstalled() If $Is_Firefox Then MsgBox(0, "Ok!", "Firefox is installed") Else MsgBox(0, "Ops", "Firefox is not installed on this system") EndIf $Firefox_Version = _NavInfo_GetFirefoxVersion() If Not @error Then MsgBox(0, "Firefox Version", "Firefox Version: " & $Firefox_Version[0] & @CRLF & "Firefox Language: " & $Firefox_Version[1]) EndIf If $Is_Firefox Then $Firefox_Location = _NavInfo_GetFirefoxLocation() MsgBox(0, "Ok!", "The firefox location is: " & $Firefox_Location) EndIf $Is_Thunderbird = _NavInfo_IsThunderbirdInstalled() If $Is_Thunderbird Then MsgBox(0, "Ok!", "Thunderbird is installed") Else MsgBox(0, "Ops", "Thunderbird is not installed on this system") EndIf $Thunderbird_Version = _NavInfo_GetThunderbirdVersion() If Not @error Then MsgBox(0, "Thunderbird Version", "Thunderbird Version: " & $Thunderbird_Version[0] & @CRLF & "Thunderbird Language: " & $Thunderbird_Version[1]) EndIf If $Is_Thunderbird Then $Thunderbird_Location = _NavInfo_GetThunderbirdLocation() MsgBox(0, "Ok!", "The Thunderbird location is: " & $Thunderbird_Location) EndIf $Is_Chrome = _NavInfo_IsChromeInstalled() If $Is_Chrome Then MsgBox(0, "Ok!", "Chrome is installed") Else MsgBox(0, "Ops", "Chrome is not installed on this system") EndIf $Chrome_Version = _NavInfo_GetChromeVersion() If Not @error Then MsgBox(0, "Chrome Version", "Chrome Version: " & $Chrome_Version) EndIf If $Is_Chrome Then $Chrome_Location = _NavInfo_GetChromeLocation() MsgBox(0, "Ok!", "The Chrome location is: " & $Chrome_Location) EndIf $Is_Opera = _NavInfo_IsOperaInstalled() If $Is_Opera Then MsgBox(0, "Ok!", "Opera is installed") Else MsgBox(0, "Ops", "Opera is not installed on this system") EndIf $Opera_Version = _NavInfo_GetOperaVersion() If Not @error Then MsgBox(0, "Opera Version", "Opera version: " & $Opera_Version) EndIf If $Is_Opera Then $Opera_Location = _NavInfo_GetOperaLocation() MsgBox(0, "Ok!", "The Opera location is: " & $Opera_Location) EndIf $Is_Safari = _NavInfo_IsSafariInstalled() If $Is_Safari Then MsgBox(0, "Ok!", "Safari is installed") Else MsgBox(0, "Ops", "Safari is not installed on this system") EndIf $Safari_Version = _NavInfo_GetSafariVersion() If Not @error Then MsgBox(0, "Safari Version", "Safari Version: " & $Safari_Version) EndIf If $Is_Safari Then $Safari_Location = _NavInfo_GetSafariLocation() MsgBox(0, "Ok!", "The Safari location is: " & $Safari_Location) EndIf $Is_Java = _NavInfo_IsJavaInstalled() If $Is_Java Then MsgBox(0, "Ok!", "Java is installed") Else MsgBox(0, "Ops", "Java is not installed on this system") EndIf $Java_Version = _NavInfo_GetJavaVersion() If Not @error Then MsgBox(0, "Java Version", "Java version: " & $Java_Version) EndIf If $Is_Java Then $Java_Location = _NavInfo_GetJavaLocation() MsgBox(0, "Ok!", "The Java location is: " & $Java_Location) EndIf $Is_Silverlight = _NavInfo_IsSilverlightInstalled() If $Is_Silverlight Then MsgBox(0, "Ok!", "Silverlight is installed") Else MsgBox(0, "Ops", "Silverlight is not installed on this system") EndIf $Silverlight_Version = _NavInfo_GetSilverlightVersion() If Not @error Then MsgBox(0, "Silverlight Version", "Silverlight Version: " & $Silverlight_Version) EndIf
      Previous download: 48
      Hi!
      NavInfo v.1.2.0.rar
×