#region - Picasa install script - (Automated with WinExists functions)
#include <Common_Functions.au3>
Opt('TrayIconDebug', 1)
Opt('WinTitleMatchMode', 4)
Break(False)

; Installer.
$executable = 'Picasa 2.7.36.40.exe'
; Default group folder in startmenu.
$group = 'Picasa2'
; Installation folder in Program Files.
$directory = 'Picasa2'
; Allowed time for installation.
$allowed = 60 * 1000

; Run the installer.
$pid = _Automated()
$time = TimerInit()
$title = 'Picasa2 Setup'
Do
    Select
        Case WinExists($title, 'License Agreement')
            WinSetState($title, 'License Agreement', @SW_MINIMIZE)
            ControlClick($title, 'License Agreement', 'Button2')
        Case WinExists($title, 'Choose Install Location')
            ControlClick($title, 'Choose Install Location', 'Button2')
        Case WinExists($title, 'Completing the Picasa2 Setup Wizard')
            ControlCommand($title, 'Completing the Picasa2 Setup Wizard', 'Button5', 'UnCheck')
            ControlCommand($title, 'Completing the Picasa2 Setup Wizard', 'Button6', 'UnCheck')
            ControlCommand($title, 'Completing the Picasa2 Setup Wizard', 'Button7', 'UnCheck')
            ControlCommand($title, 'Completing the Picasa2 Setup Wizard', 'Button4', 'UnCheck')
            ControlCommand($title, 'Completing the Picasa2 Setup Wizard', 'Button8', 'UnCheck')
            ControlClick($title, 'Completing the Picasa2 Setup Wizard', 'Button2')
    EndSelect
    Sleep(500)
    If TimerDiff($time) > $allowed Then _Abort()
Until Not ProcessExists($pid)

; Remove shortcuts.
If _Programs('Picasa2.lnk') Then
    FileMove($group & '\Picasa2.lnk', 'Editors\', 9)
    DirRemove($group, 1)
EndIf
_Desktop('Picasa2.lnk')
_QuickLaunch('Picasa2.lnk')

RegDelete('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run', 'Picasa Media Detector')

Exit
#endregion