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

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

; Run the installer.
$pid = _Automated()
$time = TimerInit()
Do
    Select
        Case WinExists('Welcome', 'Welcome to the InstallRite')
            If WinExists('InstallRite 2.5 Setup') Then
                WinSetState('InstallRite 2.5 Setup', '', @SW_HIDE)
            EndIf
            ControlClick('Welcome', 'Welcome to the InstallRite', 'Button1')
        Case WinExists('Freeware Status', 'InstallRite 2.5 is provided')
            ControlClick('Freeware Status', 'InstallRite 2.5 is provided', 'Button1')
        Case WinExists('Software License Agreement', 'Please read the following')
            ControlClick('Software License Agreement', 'Please read the following', 'Button2')
        Case WinExists('Information', 'Please visit www.epsilonsquare')
            ControlClick('Information', 'Please visit www.epsilonsquare', 'Button1')
        Case WinExists('Choose Destination Location', 'Setup will install InstallRite')
            ControlClick('Choose Destination Location', 'Setup will install InstallRite', 'Button1')
        Case WinExists('Setup Type', 'Program will be installed with')
            ControlClick('Setup Type', 'Program will be installed with', 'Button5')
        Case WinExists('Select Program Folder', 'Setup will add program icons')
            ControlSetText('Select Program Folder', 'Setup will add program icons', 'Edit1', $group)
            ControlClick('Select Program Folder', 'Setup will add program icons', 'Button2')
        Case WinExists('Setup Complete', 'InstallRite Setup is complete')
            ControlCommand('Setup Complete', 'InstallRite Setup is complete', 'Button1', 'UnCheck', '')
            ControlCommand('Setup Complete', 'InstallRite Setup is complete', 'Button2', 'UnCheck', '')
            ControlClick('Setup Complete', 'InstallRite Setup is complete', 'Button4')
    EndSelect
    Sleep(500)
    If TimerDiff($time) > $allowed Then _Abort()
Until Not ProcessExists($pid)

; Remove shortcuts.
If _Programs('InstallRite.lnk') Then
    FileChangeDir($group)
    FileDelete('InstallRite Tour.lnk')
    FileDelete('Uninstall InstallRite 2.5c.lnk')
EndIf

#region - Reg Entries
$key = 'HKCU\Software\Epsilon Squared\IW Engine'
RegWrite($key & '\Directories', 'AllFixedDisks', 'Reg_sz', 'TRUE')
RegWrite($key & '\Directories', 'IncludeCRC', 'Reg_sz', 'FALSE')
RegWrite($key & '\Settings', 'LanguageDLL', 'Reg_sz', 'resenu.dll')
RegWrite($key & '\Settings', 'ShowHelpOnStartup', 'Reg_sz', 'FALSE')
RegWrite($key & '\Settings', 'FilePatternToIgnore_00', 'Reg_sz', '')
RegWrite($key & '\Settings', 'RunInStartup', 'Reg_sz', 'FALSE')
RegWrite($key & '\Settings', 'RunInSystemTray', 'Reg_sz', 'FALSE')
RegWrite($key & '\Settings', 'DisplayFileSizeInK', 'Reg_sz', 'TRUE')
RegWrite($key & '\Settings', 'DetectSetupPrograms', 'Reg_sz', 'TRUE')
RegWrite($key & '\Settings', 'Texture', 'Reg_sz', 'Sky')
RegWrite($key & '\SnapshotSelection', 'SCANFILES', 'Reg_sz', 'TRUE')
RegWrite($key & '\SnapshotSelection', 'INCLUDEVERSION', 'Reg_sz', 'FALSE')
RegWrite($key & '\SnapshotSelection', 'CONTENTEXTENSIONS', 'Reg_sz', '')
RegWrite($key & '\SnapshotSelection', 'SCANINI', 'Reg_sz', 'TRUE')
RegWrite($key & '\SnapshotSelection', 'REGISTRYTOSCAN', 'Reg_sz', '000102')
#endregion

Exit
#endregion