Jump to content

Silverlight, Cannot find Controls


 Share

Recommended Posts

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • Developers

3.3.8.1 doesn't have the build in function, beta has.

Check out the Helpfile for more info.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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).

Link to comment
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
 Share

×
×
  • Create New...