python - How to access the control identifiers in pywinauto -
i trying access control identifiers gets displayed unable so. when open window gets popped ok , cancel button able access.. not able acccess othe options. please
once have dialog open , assigned variable print_control_identifiers() (also aliased printcontrolidentifiers) method should print available controls.
>>> app = application.start('notepad') >>> app.untitlednotepad.menuitem("edit -> replace").select() >>> app.replace.print_control_identifiers() control identifiers: static - 'fi&nd what:' (l1456, t336, r1528, b349) 'fi&nd what:' 'fi&nd what:static' 'static' 'static0' 'static1' edit - '' (l1531, t332, r1702, b352) 'edit' 'edit0' 'edit1' 'fi&nd what:edit' static - 're&place with:' (l1456, t363, r1528, b376) 're&place with:' 're&place with:static' 'static2' edit - '' (l1531, t360, r1702, b380) 'edit2' 're&place with:edit' button - 'match &case' (l1458, t422, r1547, b442) 'checkbox2' 'match &case' 'match &casecheckbox' button - '&find next' (l1711, t328, r1786, b351) '&find next' '&find nextbutton' 'button' 'button0' 'button1' button - '&replace' (l1711, t355, r1786, b378) '&replace' '&replacebutton' 'button2' button - 'replace &all' (l1711, t383, r1786, b406) 'button3' 'replace &all' 'replace &allbutton' button - 'cancel' (l1711, t410, r1786, b433) 'button4' 'cancel' 'cancelbutton' >>> app.replace.printcontrolidentifiers() control identifiers: static - 'fi&nd what:' (l1456, t336, r1528, b349) 'fi&nd what:' 'fi&nd what:static' 'static' 'static0' 'static1' edit - '' (l1531, t332, r1702, b352) 'edit' 'edit0' 'edit1' 'fi&nd what:edit' static - 're&place with:' (l1456, t363, r1528, b376) 're&place with:' 're&place with:static' 'static2' edit - '' (l1531, t360, r1702, b380) 'edit2' 're&place with:edit' button - 'match &case' (l1458, t422, r1547, b442) 'checkbox2' 'match &case' 'match &casecheckbox' button - '&find next' (l1711, t328, r1786, b351) '&find next' '&find nextbutton' 'button' 'button0' 'button1' button - '&replace' (l1711, t355, r1786, b378) '&replace' '&replacebutton' 'button2' button - 'replace &all' (l1711, t383, r1786, b406) 'button3' 'replace &all' 'replace &allbutton' button - 'cancel' (l1711, t410, r1786, b433) 'button4' 'cancel' 'cancelbutton'
the 2nd line output each control different identifiers (though things spaces , ampersands (&) should removed.
it quite possible windows media player not use 'standard' win32 dialogs. open dialog should easy enough..
here output of testing of (with errors , mistakes removed protect guilty :))
>>> wmp = application.start(r'c:\program files (x86)\windows media player\wmplayer.exe') >>> wmp.windowsmediaplayer.typekeys("^o") <pywinauto.controls.win32_controls.dialogwrapper object @ 0x027ccdb0> >>> wmp.open.printcontrolidentifiers() control identifiers: duiviewwndclassname - '' (l200, t187, r1152, b590) 'duiviewwndclassname' 'files of &type:duiviewwndclassname' directuihwnd - '' (l200, t187, r1152, b590) 'directuihwnd' 'directuihwnd0' 'directuihwnd1' 'files of &type:directuihwnd' 'files of &type :directuihwnd0' 'files of &type:directuihwnd1' ctrlnotifysink - '' (l201, t217, r426, b590) 'ctrlnotifysink' 'ctrlnotifysink0' 'ctrlnotifysink1' 'files of &type:ctrlnotifysink' 'files of &type:ctrlnotifysink0' 'files of &type:ctrlnotifysink1' namespacetreecontrol - 'namespace tree control' (l201, t217, r426, b590) 'namespace tree control' 'namespace tree control0' 'namespace tree control1' 'namespace tree controlnamespacetreecontrol' 'namespacetreecontrol' systreeview32 - 'tree view' (l201, t217, r426, b590) 'tree view' 'tree viewtreeview' 'treeview' ctrlnotifysink - '' (l429, t217, r1152, b590) 'ctrlnotifysink3' 'files of &type:ctrlnotifysink2' shelldll_defview - 'shellview' (l429, t217, r1152, b590) 'shelldll_defview' 'shellview' 'shellviewshelldll_defview' directuihwnd - '' (l429, t217, r1152, b590) 'directuihwnd2' 'files of &type:directuihwnd2' static - 'file &name:' (l330, t603, r384, b618) 'file &name:' 'file &name:static' 'static2' comboboxex32 - '' (l389, t599, r935, b623) 'comboboxex' 'file &name:comboboxex' combobox - '' (l389, t599, r935, b623) 'combobox' 'combobox0' 'combobox1' 'file &name:combobox' 'file &name:combobox0' 'file &name: combobox1' edit - '' (l393, t604, r917, b619) 'edit' 'file &name:edit' static - 'files of &type:' (l200, t152, r200, b152) 'files of &type:' 'files of &type:static' 'files of &type:static0' 'files of &type:static1' 'static3' combobox - 'media files (all types)' (l947, t599, r1135, b622) 'combobox2' 'file &name:combobox2' 'files of &type:combobox' button - '&open' (l947, t628, r1035, b654) '&open' '&openbutton' 'button' 'button0' 'button1' button - 'cancel' (l1047, t628, r1135, b654) 'button2' 'cancel' 'cancelbutton' scrollbar - '' (l1137, t651, r1152, b666) 'cancelscrollbar' 'scrollbar3' workerw - '' (l200, t152, r1152, b187) 'files of &type:workerw' 'workerw' rebarwindow32 - '' (l200, t152, r1152, b187) 'files of &type:rebar' 'rebar' travelband - '' (l200, t152, r270, b184) 'files of &type:travelband' 'travelband' toolbarwindow32 - '' (l202, t154, r270, b184) 'files of &type:toolbar' 'files of &type:toolbar0' 'files of &type:toolbar1' 'toolbar' 'tool bar0' 'toolbar1' address band root - '' (l270, t156, r944, b179) 'address band root' 'files of &type:address band root' msctls_progress32 - '' (l272, t157, r942, b178) 'files of &type:progress' 'progress' breadcrumb parent - '' (l272, t157, r898, b178) 'breadcrumb parent' 'files of &type:breadcrumb parent' toolbarwindow32 - 'address: c:\\program files (x86)\\windows media player' (l272, t157, r898, b178 ) 'address: c:\\program files (x86)\\windows media player' 'address: c:\\program files (x86)\\ windows media playertoolbar' 'toolbar2' toolbarwindow32 - '' (l898, t157, r942, b178) 'files of &type:toolbar2' 'toolbar3' universalsearchband - '' (l948, t156, r1152, b179) 'files of &type:universalsearchband' 'universalsearchband' search box - '' (l948, t156, r1152, b179) 'files of &type:search box' 'search box' searcheditboxwrapperclass - '' (l953, t156, r1147, b179) 'files of &type:searcheditboxwrapperclass' 'searcheditboxwrapperclass' directuihwnd - '' (l953, t156, r1147, b179) 'directuihwnd3' 'files of &type:directuihwnd3' >>> >>> wmp.open.filenameedit.typekeys(r"c:\your_file_name.mp3") <pywinauto.controls.win32_controls.editwrapper object @ 0x027ccc50> >>> wmp.open.open.click()
you can see (hopefully) filenameedit came
edit - '' (l393, t604, r917, b619) 'edit' 'file &name:edit'
Comments
Post a Comment