I wrote this custom function for you based on the information you provided. See if it helps you at all:
function main(){
wshell = new ActiveXObject('WScript.Shell');
/*
how you can call the search function when your control has a name
*/
var myFoundControl = findWPFControl("DBUtilities","DBUtilities","Button*Archive Jobs","2");
/*
returns the wpf control with really long name:
Sys.Process("DBUtilities").WPFObject("HwndSource: MainWindow", "DBUtilities 10.00.1622 | PROTO")
.WPFObject("MainWindow", "DBUtilities 10.00.1622 | PROTO", 1).WPFObject("Grid", "", 1)
.WPFObject("busyIndicator").WPFObject("Grid", "", 1).WPFObject("borderTasks").WPFObject("Grid", "", 1)
.WPFObject("StackPanel", "", 1).WPFObject("GroupBox", "Archival Options", 2)
.WPFObject("StackPanel", "", 1).WPFObject("Button", "Archive Jobs", 2)
*/
if (myFoundControl){
wshell.popup(myFoundControl.FullName);
}
/*
how you can call the search function when your control DOES NOT have a name
note the difference in the controlType parameter and how I pass the parent object name to narrow my search
additional "keywords" can be specified or the findall parameters within the findWPFControl function may be modified similarly
*/
var myFoundControl = findWPFControl("DBUtilities","DBUtilities","GroupBox*, 2*Button","2");
/*
returns the wpf control with really long name:
Sys.Process("DBUtilities").WPFObject("HwndSource: MainWindow", "DBUtilities 10.00.1622 | PROTO")
.WPFObject("MainWindow", "DBUtilities 10.00.1622 | PROTO", 1).WPFObject("Grid", "", 1)
.WPFObject("busyIndicator").WPFObject("Grid", "", 1).WPFObject("borderTasks").WPFObject("Grid", "", 1)
.WPFObject("StackPanel", "", 1).WPFObject("GroupBox", "Archival Options", 2)
.WPFObject("StackPanel", "", 1).WPFObject("Button", "", 2)
*/
if (myFoundControl){
wshell.popup(myFoundControl.FullName);
}
}
function findWPFControl(processName,formName,controlType,controlIndex,timeOut){
timeOut = !timeOut ? 0:timeOut;
var myControl = undefined;
var myObjectArray = [];
/*
returns forms WPF control specified by type and index
check if process exists - return undefined if it does not
*/
if (!Sys.WaitProcess(processName,0).Exists){
return undefined;
}
/*
check if form exists - return undefined if it does not
*/
if (!Sys.Process(processName).WaitWPFObject("*","*" + formName + "*",0).Exists){
return undefined;
}
myObjectArray = VBArray(Sys.Process(processName).WPFObject("*","*" + formName + "*").FindAll(["FullName"],["*" + controlType + "*, " + controlIndex],500,true)).toArray();
for (var object = 0;object < myObjectArray.length;object++){
/*
you can iterate the object array and check additional properties here
*/
if (myObjectArray[object].Exists){
return myObjectArray[object];
}
}
/*
if timeOut is reached (roughly 30 seconds + search time
then return undefined
*/
if (timeOut > 30){
return undefined;
}
timeOut++;
/*
if we didn't find the object (possibly because the form is loading)
then make a call back to the findWPFControl function
*/
BuiltIn.Delay(1000,"Searching for control...")
return findWPFControl(processName,formName,controlType,controlIndex,timeOut);
}