Getting / ussing full path to find controls in UIA and White - ui-automation

I'm using Microsoft UI automation + White framework. Is it possible to get a full path from to the control from the top parent, and then use it to find an element? For example, use UI spy to get the full path, and then somehow get the control by the taken path?
Thanks

I use the unmanaged version of MSUIA and don't use white, but something like this should do what you are asking. Pass in an element.
CUIAutomation auto = new CUIAutomation();
var desktop = auto.GetRootElement();
var walker = GetRawTreeWalker();
while (true)
{
element = walker.GetParentElement(element);
if (auto.CompareElements(desktop, element) == 1)
{
break;
}
winPath = AppendWinPathPart(winPath, element);
}
AppendWinPathPart is a call to a method that builds something like a path in string form that I use in my automation. It is much like XPath for MSUIA.

I have done something in the past similar to what it sounds like you're trying to do. Unfortunately, it's not necessarily all that easy to do.
I essentially built my own simplified version of UI Spy that used some code similar to what's in the answer from #chrismead above to build a '\' delimited path of automation IDs (unfortunately, as you may have already discovered, AutomationIDs can be unreliable, so for the sake of robustness I also had to add the capability to identify AutomationElements by things like name, position among siblings, or position relative to parent).
Then, I had code in another application that could take those paths as input in order to locate those specific AutomationElements and interact with them.

Related

Flutter build runner ElementVisitor get path

I am working with Code-Generation and trying to get the path of the Annotated-File.
I would need it inside the visitFieldElement:
#override
dynamic visitFieldElement(FieldElement element) {
// Get path here
}
I tried couple of different things: element.source, elenment.librarySource, element.location.
But non of them is giving me the exact path relativ from lib/.
I know I can simply extract it from e.g the element.location but I thought there must be a cleaner way to get this done.
It should be possible since the builder itself is printing out the path:
Any idea? Let me know if you need any more info!
If you have an element to use via visiting children,
then I believe you do have the "buildStep" variable,
it contains the "path" variable and I think that is what you are looking for.

jsTree: How to *set* opened/selected node by path (not ID)?

So, I can get the full path of a selected node like so (thanks to #ggrandes for that one):
.on('changed.jstree', function (e, data) {
var path = data.instance.get_path(data.node,'/');
console.log('Selected: ' + path);
})
What I now need, is to set select/open a node according to a given path.
All the solutions I've found so far refer to some mysterious ID, which appears to simply assume that the data in question has IDs. My problem is that I don't. It's simply a recursive JSON dict/array describing a directory layout. All I have with each node, is its name and a list of its children (and their names and children and so forth).
So, what I need is something like:
data.instance.set_path('/some/arbitrary/path');
Is it possible to do this with jsTree in some reasonable way?
I ended up creating a full path of every item on the server-side and using that as an ID that could then be selected on the client-side. As far as I can tell, there is no other way, at the time of this writing.

Eclipse Plugin Development: Adding items to a working set with the path of the item?

Hello,
I'm an eclipse plugin development newbie looking for pointers to get me started on a particular project.
I am trying to build an eclipse plugin that will automatically construct a working set from a text file that simply consists of a list of file path names. The files/items need not share any parent directories. The rough idea is represented in the following diagram:
I am not asking for the solution to this task. That's the over-arching goal. To achieve that goal, I want to conquer some smaller goals first.
With that in mind, here's the smaller goal I'm currently trying to tackle:
In Eclipse, how can I prompt the user for a single file's path, and then add that file to an existing working set?
I'm not sure where to start. Should I work directly off of the existing org.eclipse.ui.workingSets extension point? Or should I use a collection of other extension points? How do I convert strings into something that can be added to a working set? Do I write code that directly modifies the workingsets.xml file?
Even with a much simpler goal, I still feel quite overwhelmed with the vastness of eclipse extension options. There are probably many ways to go about implementing something like this, but I just need one to get started.
Thanks a bunch!
To manipulate working sets you use the working set manager interface IWorkingSetManager. Get this with:
IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager();
From this you can get a particular working by name with:
IWorkingSet workingSet = manager.getWorkingSet("name");
The contents of a working set is an array of IAdaptable objects:
IAdaptable [] contents = workingSet.getElements();
You add to the contents by adding to this array and setting the contents:
IAdaptable [] newContents
.... get new array with old contents + new contents
workingSet.setElements(newContents);
A lot of Eclipse objects implement IAdaptable, for a file in the workspace you would use IFile. You can use dialogs such as ResourceSelectionDialog to select resources from the workspace.

How to debug long scripts in Chrome?

I have a page which has a script tag. The script inside that tag is very long, but I would like to debug it. Unfortunately, I cannot scroll to the relevant place in the Console, because after a certain length the script is simply not displayed, see the attachment:
As you can see, it ends with
return !filt...
The actual function looks like this:
this.validate = function(filters) {
for (var filter in filters) {
if (!innerValidation(filters[filter].filterType, filters[filter].evaluatedValue, data[filters[filter].key])) {
return filters[filter].isOr;
}
}
return !filters[filter].isOr;
};
Question: Why does Chrome truncate my script and how could that be changed?
Note, that I know I could load it from an external file, but I am actually interested to know the cause of this behavior.
The display of the script is truncated but it still parses and runs the code correctly. You should be able to view the full code in the Sources tab under the relevant host and put breakpoints in there.
If you have a long script, it is best to make that into its own file instead. This will provide you with the best debugging experience.
The Elements panel truncates large scripts to help keep things fast and there is no way to undo this. Therefore, you would need to use some external debugging tools to try and get at this, but even then most of them work best with external script files as well.
Inline scripts should be very short if ever used. For any decent sized chunks of scripting, allocate that into its own file.

Is it possible to use a control without putting it on a form in VB6?

I'm pretty sure about the answer to this, but I'm trying a variety of things to get a very stubborn project to work. One idea was to try to run code through a control without defining it on a form.
So, for example, my original code looked like this:
frmProcess.MyViewer.MaxPageSize = 100
frmProcess.MyViewer.ResetPages
frmProcess.MyViewer.AddPageToView "C:\TestPage1.txt"
I've changed it to:
Dim objViewer As MyViewer
objViewer.MaxPageSize = 100
objViewer.ResetPages
objViewer.AddPageToView "C:\TestPage1.txt"
I get an error window with "Run-time error '91': Object variable or With block variable not set".
But there doesn't seem to be a way to 'set' this control. Is this just impossible, or is there another way to do it that doesn't require a form?
EDIT: I ended up abandoning this entire path of activity, as an alternate solution was found that got around the problem I was having with this form freezing. I don't want to delete this question in case someone else comes along and can benefit from the answers, which are potentially useful.
Try this on a form.
Dim objViewer As MyViewer
Set objViewer = Controls.Add("MyViewer", "MyViewer1")
objViewer.MaxPageSize = 100
objViewer.ResetPages
objViewer.AddPageToView "C:\TestPage1.txt"
I've had similar situations in the past. If all else fails and you have to use a form you can do something crude like
1) Set the .Left property of the control to a negative number (like -10000) so the control doesn't appear on the form, the user can not see it
2) Make the entire form not visible..
ActiveX controls normally expect a number of services from their containers, for example persistence. They are also "packaged and marked" in ways that set the kinds of instantiation they support.
See Introduction to ActiveX Controls.
While it is perfectly possible for a control to be created in such a way as to make many of the available services optional, most controls are created from template code that requires a number of them. And most controls that are "visible at runtime" are going to require container services.
However that doesn't mean a control can't be designed to support containerless instantiation. A well known example of such a control is Microsoft Script Control 1.0 (MSScriptControl.ScriptControl) which can be used either way.