1

I tried to open a pdf file and save it as xml1.0 using pywinauto. i have started writting the below code but i am not able to find the controls for menu and saving it as xml. i am new to pywinauto. can you help me in this. and also please suggest where can i get the tutorial for python pywinauto.

  from pywinauto import application

    In_File = "sample.pdf"
    Ap = "C:\Program Files\Adobe\Acrobat 7.0\Acrobat\Acrobat.exe"
    app = application.Application()
    app.start_(Ap)
    app.

Thanks

Fla-Hyd
  • 279
  • 7
  • 17

1 Answers1

2

Here is an example for Adobe Reader X

import pywinauto
pwa_app = pywinauto.application.Application()    
w_handle = pywinauto.findwindows.find_windows(title=u'Adobe Reader', class_name='AcrobatSDIWindow')[0]
window = pwa_app.window_(handle=w_handle)
window.MenuItem(u'&File->#0').Click()

By the way am the author of GUI tool for pywinauto - SWAPY. It can generate some code. I hope it would help your automation.

SWAPYAutomation
  • 693
  • 4
  • 11
  • Thanks a lot for giving me the example. I will be installing SWAPY and will work on it. – Fla-Hyd Feb 10 '13 at 13:23
  • I tried opening a notepad, entering some text and saving as file1.txt. i Used the SWAPY tool as suggested. I am not able to enter the filename in SaveAs text box. and also when i ru nthe program i am getting the below error message. can you please help me."name WINDOW not defined" import pywinauto pwa_app = pywinauto.application.Application() window.MenuItem(u'&File->&New\tCtrl+N').Click() ctrl = window['Edit'] ctrl.Select() window.MenuItem(u'&File->Save &As...').Click() – Fla-Hyd Feb 10 '13 at 14:59
  • Sure, you missed window = pwa_app.window_(handle=w_handle) code. Be careful with SWAPY code generation. Usual it generates only initial code & action with the control, but passed code for window. I recommend you the next algorithm of code geneation:1 run SWAPY,2 init a window(right click --> SetFocus), 3 make an action on a control. – SWAPYAutomation Feb 11 '13 at 08:09