vane / pywinauto

Automatically exported from code.google.com/p/pywinauto
Other
0 stars 0 forks source link

How to access the application menu, if it's name has spaces in it ? #30

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Open any application whose dialogue box title, has spaces in it's name 
2.Then try to access the menu using it's name 
3.After that error will pop up  

What is the expected output? What do you see instead?
I'm expecting to access the menu item, but it' not able to access

What version of the product are you using? On what operating system?
pywinauto-0.4.2 with Python 2.7 on Windows 7

Please provide any additional information below.

1.I have an application called 'Syntext Serna' xml editor. 
2.I'm able to open up the application, but when I try to access it's Menu, it's 
giving me error like this:

Traceback (most recent call last):
  File "test.py", line 4, in <module>
    app.dlg.MenuSelect("Document->Open")
  File "c:\python27\lib\site-packages\pywinauto\application.py", line 238, in __getattr__
    ctrls = _resolve_control(self.criteria)
  File "c:\python27\lib\site-packages\pywinauto\application.py", line 795, in _resolve_control
    raise e.original_exception
pywinauto.findbestmatch.MatchError: Could not find 'dlg' in '[u'Syntext Serna 
Free 4.2.0-20091009QWidget', u'QWidget', u'Syntext Serna Free 4.2.0-20091009']'

My code:
from pywinauto import application
app = application.Application.start(r"C:\Program Files\Syntext\Serna Free 
4.2\bin\serna.exe")
dlg = "Syntext Serna Free 4.2.0-20091009"
app.dlg.MenuSelect("Document->Open")

I believe the main reason behind this is, the application name has spaces in 
between. Is there any workaround for this ?

Original issue reported on code.google.com by DeepakNa...@gmail.com on 15 Oct 2014 at 4:49

GoogleCodeExporter commented 9 years ago
Try app[dlg] because app.dlg is eqiuvalent to app["dlg"].

Original comment by vasily.v...@gmail.com on 19 Apr 2015 at 9:27