[AutoIt] Installer Template (Changed Code) 11-16-2011, 01:49 AM
#1
If You Decide to Make an Installer In AutoScript, Heres a Template to Help You Start.
Changes:
-------------
- Took out the Need for GUIConstants.au3
- Changed Select to Switch
- Took out Tray Icon (AutoIt)
- Added Vertical Scroll bar for Terms and Conditions.
Heres the Image to Go With it. Place it in the Folder with the AU3 File. Its the Side Image in the Installer.
Save it As "logo.jpg".
Changes:
-------------
- Took out the Need for GUIConstants.au3
- Changed Select to Switch
- Took out Tray Icon (AutoIt)
- Added Vertical Scroll bar for Terms and Conditions.
Code:
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#NoTrayIcon
InstallerGUI()
TermsAndConditions()
InstallDir()
InstallFiles()
Func InstallerGUI()
GUICreate("Installer", 400, 340)
$page1_image = GUICtrlCreatePic("image.jpg", 10, 10, 100, 320)
$main_text_1 = GUICtrlCreateLabel("This is a AutoScript Installer Template.", 130, 170)
$page1_next_button = GUICtrlCreateButton("Next", 240, 313, 80)
$page1_cancel_button = GUICtrlCreateButton("Cancel", 320, 313, 80)
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $msg
Case -3
Exit
Case $page1_next_button
TermsAndConditions()
Case $page1_cancel_button
$verify_cancel = MsgBox(36, "Cancel Installation", "Are You Sure You Want to Cancel the Installation?")
if $verify_cancel = 6 Then Exit
EndSwitch
WEnd
EndFunc
Func TermsAndConditions()
GUIDelete()
GUICreate("Installer - Terms and Conditions", 400, 340)
$terms_and_conditions = GUICtrlCreateEdit("Terms and Conditions...", 10, 20, 380, 220, $ES_READONLY+$WS_VSCROLL)
$agree_label = GUICtrlCreateLabel("Do you Agree to the Terms and Conditions?", 20, 260)
$agree = GUICtrlCreateRadio("I Agree", 20, 280)
$disagree = GUICtrlCreateRadio("I Disagree", 90, 280)
$page2_next_button = GUICtrlCreateButton("Next", 240, 313, 80)
ControlDisable("Installer - Terms and Conditions", "", $page2_next_button)
$page2_cancel_button = GUICtrlCreateButton("Cancel", 320, 313, 80)
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $msg
Case -3
Exit
Case $page2_cancel_button
Exit
Case $disagree
ControlDisable("Installer - Terms and Conditions", "", $page2_next_button)
Case $agree
ControlEnable("Installer - Terms and Conditions", "", $page2_next_button)
Case $page2_next_button
InstallDir()
Case $page2_cancel_button
$verify_cancel = MsgBox(36, "Cancel Installation", "Are You Sure You Want to Cancel the Installation?")
if $verify_cancel = 6 Then Exit
EndSwitch
WEnd
EndFunc
Func InstallDir()
GUIDelete()
GUICreate("Installation Directory", 400, 340)
$page3_image = GUICtrlCreatePic("image.jpg", 10, 10, 100, 320)
$installdir = GUICtrlCreateInput("", 120, 140, 200, 20, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY))
$browse_button = GUICtrlCreateButton("Browse", 330, 140, 50, 21)
$page3_install_button = GUICtrlCreateButton("Install", 240, 313, 80)
$page3_cancel_button = GUICtrlCreateButton("Cancel", 320, 313, 80)
$page3_label1 = GUICtrlCreateLabel("Choose Where to Install the Files to...", 120, 110)
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $msg
Case -3
Exit
Case $browse_button
$select = FileSelectFolder ( "Choose the Installation Directory...", "" , 5, @DesktopDir)
GUICtrlSetData($installdir, $select)
Case $page3_cancel_button
$verify_cancel = MsgBox(36, "Cancel Installation", "Are You Sure You Want to Cancel the Installation?")
if $verify_cancel = 6 Then Exit
Case $page3_install_button
InstallFiles()
EndSwitch
WEnd
EndFunc
Func InstallFiles()
GUIDelete()
GUICreate("Installation Complete", 400, 340)
$lastpage_image = GUICtrlCreatePic("image.jpg", 10, 10, 100, 320)
$label = GUICtrlCreateLabel("Installation Complete!", 150, 140, 100, 100)
$close_button = GUICtrlCreateButton("Close", 320, 313, 80)
ProgressOn ( "Progress","Installing...")
For $i = 0 to 100 step 20
sleep(1000)
ProgressSet( $i, $i & "% Complete")
Next
WinClose("Progress")
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $msg
Case -3
Exit
Case $close_button
Exit
EndSwitch
WEnd
EndFuncHeres the Image to Go With it. Place it in the Folder with the AU3 File. Its the Side Image in the Installer.
Save it As "logo.jpg".
(This post was last modified: 11-22-2011, 12:51 AM by doojan.)



![[+]](https://sinister.li/images/modern/collapse_collapsed.png)