c# - UI automation and menu item -


i trying use .net ui automation. have third party application know written in .net, have no source code for. starting application, process.start("exe path"); , getting processid , search main application window

 this.mainwindow = automationelement.rootelement.findfirst                     (treescope.children,                      new andcondition(                          new propertycondition(automationelement.processidproperty, this.processid),                          new propertycondition(automationelement.nameproperty, initialwindowname)                          )); 

this working find in main window, there menu bar has common "file, edit, ..."

so, next step select menu bar , expand file menu with

var menubar = this.mainwindow.findfirst(treescope.children,                                       new propertycondition(automationelement.localizedcontroltypeproperty, "menu bar"));                 var filemenu = menubar.findall(treescope.children, condition.truecondition)[0];                 var expandpattern = filemenu.getcurrentpattern(expandcollapsepattern.pattern) expandcollapsepattern;                 if (expandpattern.current.expandcollapsestate != expandcollapsestate.expanded)                     expandpattern.expand();                 thread.sleep(3000); 

since "file" menu option first option in menu bar, expanding "file" menu options

now, want call print menu item in "file" menu list.

the print menu item has name "print document ctrl+p"

so search

var printmenuitem = this.mainwindow.findfirst(treescope.descendants, new propertycondition(automationelement.nameproperty,"print document   ctrl+p")); 

but without success. tried different way, getting items descendants , looping through names find if have "print" in them without success, this

var list = this.mainwindow.findall(treescope.descendants, new propertycondition(automationelement.localizedcontroltypeproperty,"menu item")); (int = 0; < list.count; i++) {    if (list[0].current.name.indexof("print") > -1)... 

i tried , able find print menu

var printmenu = filemenu.findfirst(treescope.children, new propertycondition(automationelement.nameproperty, "print")); 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -