How to use python script to automate software installation
Question: I am new to Python. I want to automate the software installation process. The
scenario is as follow  

> Run the installation file. On first screen it has two buttons next, cancel.
> On click of next it goes to next screen having two buttons, next, cancel and
> some input data is required. After details are provided, it will show finish
> or cancel button.  
>

In this I want to write python script that would automate this activity. It
should identify the button click it, should enter the data wherever required
and finish the installation.  
  
To achieve this functionality

  1. Python API is required, if any? 
  2. Some code samples or link of the tutorials to use the same.   
[Sample image for referance](http://i.stack.imgur.com/WLyqh.jpg)  
Thank you!!


Answer: As Rawing mentioned, pywinauto is good choice for Windows installer. Here is
nice sample video: <http://pywinauto.github.io/>  
  
For waiting next page use something like that:
`app.WizardPageTitle.Wait('ready')`  
When installer finished: `app.FinishPage.WaitNot('visible')`  
For edit box input: `app.WizardPage.Edit.TypeKeys('some input path',
with_spaces=True)`  
For button clicks I'd recommend `ClickInput()` as more reliable method.  
  
If you want to install the app on many machines automatically, you can create
Remote Desktop or VNC session and run local copy of the Python script inside
that session. Just do not minimize RDP or VNC window to prevent GUI context
loss. Losing focus is safe and you can continue your work on master machine in
another window without affecting remote installation.  
  
  
Example of easy install script for FastStone Image Viewer 4.6:

    
    
    import os
    from pywinauto.application import Application as app
    
    fsv = app.Start("FSViewerSetup46.exe")
    
    fsv.InstallDialog.NextButton.Wait('ready', timeout=30).ClickInput()
    fsv.InstallDialog.IAgreeRadioButton.Wait('ready', timeout=30).ClickInput()
    fsv.InstallDialog.Edit.Wait('ready', timeout=30).TypeKeys(os.getcwd() + "\FastStone Image Viewer", with_spaces=True)
    fsv.InstallDialog.InstallButton.Wait('ready', timeout=30).ClickInput()
    fsv.InstallDialog.FinishButton.Wait('ready', timeout=30).ClickInput()
    

