Jump to content

New Project Folder


willichan
 Share

Recommended Posts

This evolved from my AU3Project utility.

This one is much more flexible ... and better coded.

When you create a project folder, you enter basic information about the project, select a template (AU3, PAS, C, PHP, ... anything you create) and a profile (information about yourself) to use in creating the project folder. The folder is then created, and variable substitution applied to populate the folder with the files needed for the project. Using this utility, I have profiles for each client I write scripts for, as well as one for scripts I write for myself.

Play around with it, and you will see how useful it can be.

---------- Latest Code ----------

MyProjectFolder.au3

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=icons\MyProjectFolder.ico
#AutoIt3Wrapper_Outfile=MyProjectFolder.exe
#AutoIt3Wrapper_Outfile_x64=MyProjectFolder64.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Compile_Both=y
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Res_Description=Creates a new project folder based on the selected template and profile
#AutoIt3Wrapper_Res_Fileversion=1.0.0.20
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_Language=1033
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
://////=__=
://////=__==willichan)
://////=__=://.=
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y
#AutoIt3Wrapper_Run_Tidy=y
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/striponly
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------

Project Name: New Project Folder
Description: Creates a new project folder based on the selected template and profile
AutoIt Version: v3.3.6.1
Author: David Williams (willichan)
Email: david@optionsintegrated.com
website: http://optionsintegrated.com
Company: Options Integrated
Creation Date: 9/30/2010

#ce ----------------------------------------------------------------------------
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Date.au3>
Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declare
Opt("TrayAutoPause", 0) ;0=no pause, 1=Pause
Opt("TrayMenuMode", 0) ;0=append, 1=no default menu, 2=no automatic check, 4=menuitemID  not return
Opt("TrayIconHide", 0) ;0=show, 1=hide tray icon
Opt("GUIOnEventMode", 1)
Global Const $MyName = "MyProjectFolder"
Global Const $datapath = @AppDataCommonDir & "\MyProjectFolder\"
Global Const $IniFile = @AppDataCommonDir & "\MyProjectFolder.ini"
Global $vars, $delimiter, $mymutex
Global $frm_main, $frm_main_loop
Global $frm_main_lbl_path, $frm_main_path
Global $frm_main_lbl_longname, $frm_main_longname
Global $frm_main_lbl_shortname, $frm_main_shortname
Global $frm_main_lbl_description, $frm_main_description
Global $frm_main_lbl_profile, $frm_main_profile
Global $frm_main_lbl_template, $frm_main_template
Global $frm_main_OK, $frm_main_Cancel
SRandom(@YDAY & @MSEC)
$mymutex = Hex(Random(0, 65535, 1), 4) & Hex(Random(0, 65535, 1), 4) & Hex(Random(0, 65535, 1), 4) & Hex(Random(0, 65535, 1), 4)
_frm_main()
Func _frm_main()
;form
Global $frm_main = GUICreate("New Project Folder", 412, 235, 194, 233)
GUISetFont(7, 400, 0, "MS Sans Serif")
GUISetOnEvent($GUI_EVENT_CLOSE, "_frm_main_Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "_frm_main_Minimize")
GUISetOnEvent($GUI_EVENT_RESTORE, "_frm_main_Restore")
If $CmdLine[0] = 0 Then
  ;path
  Global $frm_main_lbl_path = GUICtrlCreateLabel("Target Path:", 8, 8, 63, 17, 0)
  Global $frm_main_path = GUICtrlCreateInput("", 80, 8, 303, 21)
  GUICtrlSetTip($frm_main_path, "Path where the new folder should be created")
  Global $frm_main_browse = GUICtrlCreateButton("...", 384, 8, 19, 21, $WS_GROUP)
  GUICtrlSetTip($frm_main_browse, "Browse")
  GUICtrlSetOnEvent($frm_main_browse, "_frm_main_browse_click")
EndIf
;long name
$frm_main_lbl_longname = GUICtrlCreateLabel("Long Name:", 8, 40, 62, 17, 0)
$frm_main_longname = GUICtrlCreateInput("", 80, 40, 321, 21, $GUI_SS_DEFAULT_INPUT)
GUICtrlSetTip($frm_main_longname, "Full name of the project")
GUICtrlSetOnEvent($frm_main_longname, "_frm_main_longname_Change")
;short name
$frm_main_lbl_shortname = GUICtrlCreateLabel("Short Name:", 8, 72, 63, 17, 0)
$frm_main_shortname = GUICtrlCreateInput("", 80, 72, 321, 21, $GUI_SS_DEFAULT_INPUT)
GUICtrlSetTip($frm_main_shortname, "Short name for project (and name of the new folder)")
;description
$frm_main_lbl_description = GUICtrlCreateLabel("Description:", 8, 104, 60, 17, 0)
$frm_main_description = GUICtrlCreateInput("", 80, 104, 321, 21, $GUI_SS_DEFAULT_INPUT)
GUICtrlSetTip($frm_main_description, "Description of the new project")
;profile
$frm_main_lbl_profile = GUICtrlCreateLabel("Profile:", 8, 136, 36, 17)
$frm_main_profile = GUICtrlCreateCombo("", 80, 136, 321, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetTip($frm_main_profile, "Profile (your info) to use for this project")
;template
$frm_main_lbl_template = GUICtrlCreateLabel("Template:", 8, 168, 51, 17)
$frm_main_template = GUICtrlCreateCombo("", 80, 168, 321, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetTip($frm_main_template, "Project template to use")
;ok button
$frm_main_OK = GUICtrlCreateButton("OK", 16, 200, 179, 25)
GUICtrlSetOnEvent($frm_main_OK, "_frm_main_OK_Click")
GUICtrlSetTip($frm_main_OK, "Create the project folder")
;cancel button
$frm_main_Cancel = GUICtrlCreateButton("Cancel", 216, 200, 179, 25)
GUICtrlSetOnEvent($frm_main_Cancel, "_frm_main_Cancel_Click")
GUICtrlSetTip($frm_main_Cancel, "Abort the new project folder")
If $CmdLine[0] > 0 Then
  ;path
  Global $frm_main_lbl_path = GUICtrlCreateLabel("Target Path:", 8, 8, 63, 17, 0)
  Global $frm_main_path = GUICtrlCreateInput("", 80, 8, 303, 21)
  GUICtrlSetTip($frm_main_path, "Path where the new folder should be created")
  Global $frm_main_browse = GUICtrlCreateButton("...", 384, 8, 19, 21, $WS_GROUP)
  GUICtrlSetTip($frm_main_browse, "Browse")
  GUICtrlSetOnEvent($frm_main_browse, "_frm_main_browse_click")
EndIf
;load default values
_frm_main_LoadDefaults()
;run the GUI
GUISetState(@SW_SHOW, $frm_main)
$frm_main_loop = True
While $frm_main_loop
  Sleep(100)
WEnd
EndFunc   ;==>_frm_main
Func _frm_main_Close()
_frm_main_Cancel_Click()
EndFunc   ;==>_frm_main_Close
Func _frm_main_Minimize()
EndFunc   ;==>_frm_main_Minimize
Func _frm_main_Restore()
EndFunc   ;==>_frm_main_Restore
Func _frm_main_browse_click()
Local $ret
$ret = FileSelectFolder("Select folder where project folder will be created", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", 7, StringStripWS(GUICtrlRead($frm_main_path), 8))
If $ret <> "" Then GUICtrlSetData($frm_main_path, $ret)
EndFunc   ;==>_frm_main_browse_click
Func _frm_main_longname_Change()
Local $short = GUICtrlRead($frm_main_shortname)
If StringStripWS($short, 3) = "" Then
  GUICtrlSetData($frm_main_shortname, StringStripWS(GUICtrlRead($frm_main_longname), 8))
EndIf
EndFunc   ;==>_frm_main_longname_Change
Func _frm_main_OK_Click()
If Not _frm_main_ValidEntries() Then Return
GUISetState(@SW_HIDE, $frm_main)
$frm_main_loop = False
_frm_main_SaveDefaluts()
_CreateFolder()
EndFunc   ;==>_frm_main_OK_Click
Func _frm_main_Cancel_Click()
GUISetState(@SW_HIDE, $frm_main)
$frm_main_loop = False
EndFunc   ;==>_frm_main_Cancel_Click
Func _frm_main_SaveDefaluts()
IniWrite($IniFile, "LastValues", "profile", GUICtrlRead($frm_main_profile))
IniWrite($IniFile, "LastValues", "template", GUICtrlRead($frm_main_template))
EndFunc   ;==>_frm_main_SaveDefaluts
Func _frm_main_LoadDefaults()
Local $temp1, $temp2
;;path
Switch $CmdLine[0]
  Case 0 ;No path provided, use @WorkingDir
   $temp1 = @WorkingDir
   If StringRight($temp1, 1) <> "\" Then $temp1 &= "\"
  Case 1
   $temp1 = $CmdLine[1] ;Path given on command line
  Case Else
   $temp1 = $CmdLine[2] ;Path given through context menu
EndSwitch
$temp1 = StringLeft($temp1, StringInStr($temp1, "\", 0, -1))
GUICtrlSetData($frm_main_path, $temp1)
;;profile
$temp1 = _GetProfiles()
$temp2 = IniRead($IniFile, "LastValues", "profile", "")
GUICtrlSetData($frm_main_profile, $temp1, $temp2)
;;template
$temp1 = _GetTemplates()
$temp2 = IniRead($IniFile, "LastValues", "template", "")
GUICtrlSetData($frm_main_template, $temp1, $temp2)
EndFunc   ;==>_frm_main_LoadDefaults
Func _frm_main_ValidEntries()
Local $Invalid = ""
If StringStripWS(GUICtrlRead($frm_main_path), 3) = "" Then $Invalid &= @CRLF & "Target Path"
If StringStripWS(GUICtrlRead($frm_main_longname), 3) = "" Then $Invalid &= @CRLF & "Long Name"
If StringStripWS(GUICtrlRead($frm_main_shortname), 3) = "" Then $Invalid &= @CRLF & "Short Name"
If StringStripWS(GUICtrlRead($frm_main_profile), 3) = "" Then $Invalid &= @CRLF & "Profile"
If StringStripWS(GUICtrlRead($frm_main_template), 3) = "" Then $Invalid &= @CRLF & "Template"
If $Invalid = "" Then Return True
MsgBox(8192 + 48, "MyProjectFolder Warning", "The following fields must have valid entries:" & $Invalid)
Return False
EndFunc   ;==>_frm_main_ValidEntries
Func _GetProfiles()
Local $search, $file
Local $found = ""
$search = FileFindFirstFile($datapath & "profiles\*.ini")
If $search = -1 Then
  Return ""
EndIf
While 1
  $file = FileFindNextFile($search)
  If @error Then ExitLoop
  If StringLower(IniRead($datapath & "profiles\" & $file, "config", "status", "")) = "active" Then
   $found &= "|" & StringLeft($file, StringInStr($file, ".", 0, -1) - 1)
  EndIf
WEnd
FileClose($search)
If $found <> "" Then $found = StringRight($found, StringLen($found) - 1)
Return $found
EndFunc   ;==>_GetProfiles
Func _GetTemplates()
Local $search, $file
Local $found = ""
$search = FileFindFirstFile($datapath & "templates\*.*")
If $search = -1 Then
  Return ""
EndIf
While 1
  $file = FileFindNextFile($search)
  If @error Then ExitLoop
  If StringLower(IniRead($datapath & "templates\" & $file & "\template.ini", "config", "status", "")) = "active" Then
   $found &= "|" & $file
  EndIf
WEnd
FileClose($search)
If $found <> "" Then $found = StringRight($found, StringLen($found) - 1)
Return $found
EndFunc   ;==>_GetTemplates
Func _CreateFolder()
Local $files, $NewPath, $source, $target, $i, $data, $attrib, $activedir
$vars = IniReadSection($datapath & "profiles\" & StringStripWS(GUICtrlRead($frm_main_profile), 3) & ".ini", "variables")
If @error Then
  MsgBox(8192 + 16, $MyName & " Error", "Unable to read " & @ScriptDir & "\profiles\" & StringStripWS(GUICtrlRead($frm_main_profile), 3) & ".ini" & @CRLF & "Profile may be corrupt")
  Exit 2
EndIf
$files = IniReadSection($datapath & "templates\" & StringStripWS(GUICtrlRead($frm_main_template), 3) & "\template.ini", "files")
If @error Then
  MsgBox(8192 + 16, $MyName & " Error", "Unable to read " & $datapath & "templates\" & StringStripWS(GUICtrlRead($frm_main_template), 3) & "\template.ini" & @CRLF & "Template may be corrupt")
  Exit 1
EndIf
$delimiter = IniRead($datapath & "templates\" & StringStripWS(GUICtrlRead($frm_main_template), 3) & "\template.ini", "config", "variablemarker", "__")
$NewPath = StringStripWS(GUICtrlRead($frm_main_path), 3)
If StringRight($NewPath, 1) <> "\" Then $NewPath &= "\"
$NewPath &= StringStripWS(GUICtrlRead($frm_main_shortname), 3)
DirCreate($NewPath)
FileSetAttrib($NewPath, "+s")
If $files[0][0] > 0 Then
  For $i = 1 To $files[0][0]
   $source = $files[$i][1]
   While StringLeft($source, 1) = "\"
    $source = StringStripWS(StringRight($source, StringLen($source) - 1), 1)
   WEnd
   $target = $source
   If StringInStr("fr", StringLower($files[$i][0])) Then _ReplaceVariables($target)
   $attrib = FileGetAttrib($datapath & "templates\" & StringStripWS(GUICtrlRead($frm_main_template), 3) & "\include\" & $source)
   StringReplace($attrib, "N", "")
   StringReplace($attrib, "D", "")
   StringReplace($attrib, "O", "")
   StringReplace($attrib, "C", "")
   StringReplace($attrib, "T", "")
   $data = FileRead($datapath & "templates\" & StringStripWS(GUICtrlRead($frm_main_template), 3) & "\include\" & $source)
   If StringInStr("fp", StringLower($files[$i][0])) Then _ReplaceVariables($data)
   If StringInStr($target, "\") Then DirCreate($NewPath & "\" & StringLeft($target, StringInStr($target, "\", 0, -1) - 1))
   FileWrite($NewPath & "\" & $target, $data)
   FileSetAttrib($NewPath & "\" & $target, "+" & $attrib)
  Next
EndIf
$files = IniReadSection($datapath & "templates\" & StringStripWS(GUICtrlRead($frm_main_template), 3) & "\template.ini", "execute")
If Not @error Then
  If $files[0][0] > 0 Then
   For $i = 1 To $files[0][0]
    $activedir = StringLeft($NewPath & "\" & $files[$i][1], StringInStr($NewPath & "\" & $files[$i][1], "\", 0, -1) - 1)
    Switch StringLower(StringRight($files[$i][1], StringLen($files[$i][1]) - StringInStr($files[$i][1], ".", 0, -1)))
     Case "bat", "cmd"
      RunWait(@ComSpec & " /c " & '"' & $NewPath & "\" & $files[$i][1] & '"', $activedir)
     Case Else
      ShellExecuteWait($NewPath & "\" & $files[$i][1], "", $activedir)
    EndSwitch
   Next
  EndIf
EndIf
EndFunc   ;==>_CreateFolder
Func _ReplaceVariables(ByRef $thestring)
Local $i
$thestring = StringReplace($thestring, _Delimited("templatepath"), $datapath & "templates\" & StringStripWS(GUICtrlRead($frm_main_template), 3) & "\include", 0, 1)
$thestring = StringReplace($thestring, _Delimited("nameshort"), StringStripWS(GUICtrlRead($frm_main_shortname), 3), 0, 1)
$thestring = StringReplace($thestring, _Delimited("namelong"), StringStripWS(GUICtrlRead($frm_main_shortname), 3), 0, 1)
$thestring = StringReplace($thestring, _Delimited("autoitver"), RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "Version"), 0, 1)
$thestring = StringReplace($thestring, _Delimited("date"), _NowDate(), 0, 1)
$thestring = StringReplace($thestring, _Delimited("description"), StringStripWS(GUICtrlRead($frm_main_description), 3), 0, 1)
$thestring = StringReplace($thestring, _Delimited("mutex"), $mymutex, 0, 1)
If $vars[0][0] > 0 Then
  For $i = 1 To $vars[0][0]
   $thestring = StringReplace($thestring, _Delimited($vars[$i][0]), $vars[$i][1], 0, 1)
  Next
EndIf
EndFunc   ;==>_ReplaceVariables
Func _Delimited($thestring)
Return $delimiter & $thestring & $delimiter
EndFunc   ;==>_Delimited

install.au3

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=icons\install.ico
#AutoIt3Wrapper_Outfile=install.exe
#AutoIt3Wrapper_Outfile_x64=install64.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Compile_Both=y
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Res_Description=Installs the MyProjectFolder utility
#AutoIt3Wrapper_Res_Fileversion=1.0.1.24
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_LegalCopyright=Copyright 2009, 2010 by David (willichan) Williams
#AutoIt3Wrapper_Res_Language=1033
#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y
#AutoIt3Wrapper_Run_Tidy=y
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/striponly
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
Global Const $installpath = @ProgramFilesDir & "\MyProjectFolder\"
Global Const $datapath = @AppDataCommonDir & "\MyProjectFolder\"
Global Const $extension = ".mypf"
Global Const $classname = "MyProjectFolder"
Global Const $menutext = "MyProject Folder"
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Global $frm_install_loop = True
Global $frm_install = GUICreate("Install", 180, 138, 192, 132)
GUISetFont(7, 400, 0, "MS Sans Serif")
GUISetOnEvent($GUI_EVENT_CLOSE, "frm_installClose")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "frm_installMinimize")
GUISetOnEvent($GUI_EVENT_RESTORE, "frm_installRestore")
Global $frm_install_context = GUICtrlCreateCheckbox("Add to context menu", 8, 8, 153, 17)
GUICtrlSetState($frm_install_context, $GUI_CHECKED)
GUICtrlSetOnEvent($frm_install_context, "frm_install_contextClick")
Global $frm_install_desktop = GUICtrlCreateCheckbox("Create desktop shortcut", 8, 32, 169, 17)
GUICtrlSetState($frm_install_desktop, $GUI_CHECKED)
GUICtrlSetOnEvent($frm_install_desktop, "frm_install_desktopClick")
Global $frm_install_allusers = GUICtrlCreateCheckbox("All users", 24, 56, 81, 17)
GUICtrlSetState($frm_install_allusers, $GUI_CHECKED)
GUICtrlSetOnEvent($frm_install_allusers, "frm_install_allusersClick")
Global $frm_install_startmenu = GUICtrlCreateCheckbox("Add to Start menu", 8, 80, 129, 17)
GUICtrlSetState($frm_install_startmenu, $GUI_CHECKED)
GUICtrlSetOnEvent($frm_install_startmenu, "frm_install_startmenuClick")
Global $frm_install_OK = GUICtrlCreateButton("OK", 8, 104, 75, 25, $WS_GROUP)
GUICtrlSetOnEvent($frm_install_OK, "frm_install_OKClick")
Global $frm_install_Cancel = GUICtrlCreateButton("Cancel", 96, 104, 75, 25, $WS_GROUP)
GUICtrlSetOnEvent($frm_install_Cancel, "frm_install_CancelClick")
GUISetState(@SW_SHOW)
While $frm_install_loop
 Sleep(100)
WEnd
Func frm_install_allusersClick()
EndFunc   ;==>frm_install_allusersClick
Func frm_install_CancelClick()
 Exit
EndFunc   ;==>frm_install_CancelClick
Func frm_install_contextClick()
EndFunc   ;==>frm_install_contextClick
Func frm_install_desktopClick()
EndFunc   ;==>frm_install_desktopClick
Func frm_install_OKClick()
 $frm_install_loop = False
EndFunc   ;==>frm_install_OKClick
Func frm_install_startmenuClick()
EndFunc   ;==>frm_install_startmenuClick
Func frm_installClose()
 frm_install_CancelClick()
EndFunc   ;==>frm_installClose
Func frm_installMinimize()
EndFunc   ;==>frm_installMinimize
Func frm_installRestore()
EndFunc   ;==>frm_installRestore
If Not DirCreate($installpath) Then MsgBox(0, "Install Error", "Cannot create " & @CRLF & $installpath)
If Not DirCreate($datapath) Then MsgBox(0, "Install Error", "Cannot create " & @CRLF & $datapath)
DirCreate($datapath & "profiles")
DirCreate($datapath & "templates\AU3-general\include")
DirCreate($datapath & "templates\AU3-Sqlite\include")
If @OSArch = "X64" Then
 FileInstall("MyProjectFolder64.exe", $installpath & "MyProjectFolder.exe", 1)
Else
 FileInstall("MyProjectFolder.exe", $installpath & "MyProjectFolder.exe", 1)
EndIf
FileInstall("icons\MyProjectFolder.ico", $installpath & "MyProjectFolder.ico", 0)
FileInstall("icons\MyAU3Project.ico", $installpath & "MyAU3Project.ico", 0)
FileInstall("uninstall.exe", $installpath & "uninstall.exe", 1)
FileInstall("profiles\sample.ini", $datapath & "profiles\sample.ini", 0)
FileInstall("templates\AU3-general\template.ini", $datapath & "templates\AU3-general\template.ini", 0)
FileInstall("templates\AU3-general\include\__nameshort__.au3", $datapath & "templates\AU3-general\include\__nameshort__.au3", 0)
FileInstall("templates\AU3-general\include\__nameshort__.ico", $datapath & "templates\AU3-general\include\__nameshort__.ico", 0)
FileInstall("templates\AU3-general\include\config.au3", $datapath & "templates\AU3-general\include\config.au3", 0)
FileInstall("templates\AU3-general\include\Desktop.ini", $datapath & "templates\AU3-general\include\Desktop.ini", 0)
FileInstall("templates\AU3-Sqlite\template.ini", $datapath & "templates\AU3-Sqlite\template.ini", 0)
FileInstall("templates\AU3-Sqlite\include\__nameshort__.au3", $datapath & "templates\AU3-Sqlite\include\__nameshort__.au3", 0)
FileInstall("templates\AU3-Sqlite\include\__nameshort__.ico", $datapath & "templates\AU3-Sqlite\include\__nameshort__.ico", 0)
FileInstall("templates\AU3-Sqlite\include\config.au3", $datapath & "templates\AU3-Sqlite\include\config.au3", 0)
FileInstall("templates\AU3-Sqlite\include\Desktop.ini", $datapath & "templates\AU3-Sqlite\include\Desktop.ini", 0)
FileSetAttrib($datapath & "templates\AU3-general\include\Desktop.ini", "+sh")
FileSetAttrib($datapath & "templates\AU3-Sqlite\include\Desktop.ini", "+sh")
If GUICtrlRead($frm_install_startmenu) = $GUI_CHECKED Then
 DirCreate(@ProgramsCommonDir & "\MyProjectFolder")
 FileCreateShortcut($installpath & "MyProjectFolder.exe", @ProgramsCommonDir & "\MyProjectFolder\New MyProject Folder.lnk")
 FileCreateShortcut($installpath & "uninstall.exe", @ProgramsCommonDir & "\MyProjectFolder\Uninstall.lnk")
EndIf
If GUICtrlRead($frm_install_desktop) = $GUI_CHECKED Then
 If GUICtrlRead($frm_install_allusers) = $GUI_CHECKED Then
  FileCreateShortcut($installpath & "MyProjectFolder.exe", @DesktopCommonDir & "\New MyProject Folder.lnk")
 Else
  FileCreateShortcut($installpath & "MyProjectFolder.exe", @DesktopDir & "\New MyProject Folder.lnk")
 EndIf
EndIf
If GUICtrlRead($frm_install_context) = $GUI_CHECKED Then
 RegWrite('HKEY_CLASSES_ROOT\' & $classname, "", "REG_SZ", $menutext)
 RegWrite('HKEY_CLASSES_ROOT\' & $classname & '\DefaultIcon', "", "REG_SZ", $installpath & 'MyProjectFolder.ico')
 RegWrite('HKEY_CLASSES_ROOT\' & $classname & '\Shell', "", "REG_SZ", 'Open')
 RegWrite('HKEY_CLASSES_ROOT\' & $classname & '\Shell\Open', "", "REG_SZ", 'Open')
 RegWrite('HKEY_CLASSES_ROOT\' & $classname & '\Shell\Open\Command', "", "REG_SZ", 'notepad "%1"')
 RegWrite('HKEY_CLASSES_ROOT\' & $extension, 'PerceivedType', "REG_SZ", 'text')
 RegWrite('HKEY_CLASSES_ROOT\' & $extension, "", "REG_SZ", $classname)
 RegWrite('HKEY_CLASSES_ROOT\' & $extension & '\PersistentHandler', "", "REG_SZ", '{5e941d80-bf96-11cd-b579-08002b30bfeb}')
 RegWrite('HKEY_CLASSES_ROOT\' & $extension & '\ShellNew', 'Command', "REG_SZ", '"' & $installpath & 'MyProjectFolder.exe" "%1"')
 MsgBox(64, "MyAU3Project Installer", "It is recomended that you restart your PC to complete the installation process.")
EndIf
Exit

uninstall.au3

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=icons\uninstall.ico
#AutoIt3Wrapper_Outfile=uninstall.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Res_Description=Uninstalls the MyProjectF older utility
#AutoIt3Wrapper_Res_Fileversion=1.0.0.8
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_LegalCopyright=Copyright 2009, David (willichan) Williams
#AutoIt3Wrapper_Res_Language=1033
#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y
#AutoIt3Wrapper_Run_Tidy=y
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/striponly
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
Global Const $installpath = @ProgramFilesDir & "\MyProjectFolder\"
Global Const $datapath = @AppDataCommonDir & "\MyProjectFolder\"
Global Const $extension = ".mypf"
Global Const $classname = "MyProjectFolder"
RegDelete('HKEY_CLASSES_ROOT\' & $extension)
RegDelete('HKEY_CLASSES_ROOT\' & $classname)
FileSetAttrib($datapath & "templates\AU3-general\include\Desktop.ini", "-rsh")
FileSetAttrib($datapath & "templates\AU3-Sqlite\include\Desktop.ini", "-rsh")
FileDelete($installpath & "MyProjectFolder.exe")
FileDelete($installpath & "MyProjectFolder.ico")
FileDelete($installpath & "MyAU3Project.ico")
FileDelete($installpath & "uninstall.exe")
FileDelete($datapath & "profiles\sample.ini")
FileDelete($datapath & "templates\AU3-general\template.ini")
FileDelete($datapath & "templates\AU3-general\include\__nameshort__.au3")
FileDelete($datapath & "templates\AU3-general\include\__nameshort__.ico")
FileDelete($datapath & "templates\AU3-general\include\config.au3")
FileDelete($datapath & "templates\AU3-general\include\Desktop.ini")
FileDelete($datapath & "templates\AU3-Sqlite\template.ini")
FileDelete($datapath & "templates\AU3-Sqlite\include\__nameshort__.au3")
FileDelete($datapath & "templates\AU3-Sqlite\include\__nameshort__.ico")
FileDelete($datapath & "templates\AU3-Sqlite\include\config.au3")
FileDelete($datapath & "templates\AU3-Sqlite\include\Desktop.ini")
DirRemove($installpath, 1)
DirRemove($datapath, 1)
FileDelete(@ProgramsCommonDir & "\MyProjectFolder\New MyProject Folder.lnk")
FileDelete(@ProgramsCommonDir & "\MyProjectFolder\Uninstall.lnk")
FileDelete(@DesktopCommonDir & "\New MyProject Folder.lnk")
FileDelete(@DesktopDir & "\New MyProject Folder.lnk")
DirRemove(@ProgramsCommonDir & "\MyProjectFolder")

MsgBox(64, "MyProjectFolder Uninstaller", "It is recomended that you restart your PC to complete the uninstallation process.")
Exit

---------- Extra Templates ----------

HTML Book - Added Nov. 11, 2010

HTML Book 2 - Added Sep. 10, 2011

---------- Changelog ----------

November 9, 2010 -- New version uploaded to server fixes a minor bug where template sub-folders are not created.

December 20, 2010 -- Source posted below (post #7)

January 26, 2011 -- Minor aesthetic update to alter field focus based on how script is launched.

September 10, 2011 -- Added ability to execute an external program as part of the template launch. (Sep. 10, 2011 or later version of utility)

April 20, 2010 -- Fully Windows 7 compatible (32bit and 64 bit)

Edited by willichan
Link to comment
Share on other sites

  • 4 weeks later...

Here is an extra template to use with the utility. I use it for creating online HTML books. Just unzip it into the "%ProgramFiles%\MyProjectFolder\templates" folder.

HTML-Book template

Link to comment
Share on other sites

  • 1 month later...

@Steevegl Did you install as an administrator?

[font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS:

%programfiles%/AutoIt3/autoit3.chm
Link to comment
Share on other sites

Tested on Windows 7 64bits

Install fail

:x

I'll have to look into Win7. I understand 'Program Files' is handled differently. I would not be surprised to know that the context menus are different as well.

I am getting a Win7 Ultimate system set up. I'll put out a new version as soon as I get it working right on that system.

Link to comment
Share on other sites

Should be nice if you could give the source. It's probably not a big bug, but I can't figure out myself. :x

BTW, I been able to try the old version by compiling the source myself, and I have a suggestion if it doesn't include in this version:

  • A way to split the source and a the build folder. I'm still surprise to not see it as a default function.
Link to comment
Share on other sites

Should be nice if you could give the source.

No objections here. I always intended to after cleaning the code up a bit. I just haven't had the time to put on it yet.

Still needs a little more cleanup, but here it is. The installer is probably the piece that is not working with 64-bit.

This is pretty much a full rewrite. I didn't like how clunky the other one was. It was nice for what I needed when I wrote it, but it wasn't much worth trying to fix.

The templates can be pulled from the download above.

MyProjectFolder.au3

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Date.au3>

Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declare
Opt("TrayAutoPause", 0) ;0=no pause, 1=Pause
Opt("TrayMenuMode", 0) ;0=append, 1=no default menu, 2=no automatic check, 4=menuitemID  not return
Opt("TrayIconHide", 0) ;0=show, 1=hide tray icon
Opt("GUIOnEventMode", 1)

Global Const $MyName = StringLeft(@ScriptName, StringInStr(@ScriptName, ".", 0, -1) - 1)
Global Const $IniFile = @ScriptDir & "\" & $MyName & ".ini"

Global $vars, $delimiter, $mymutex

Global $frm_main, $frm_main_loop
Global $frm_main_lbl_path, $frm_main_path
Global $frm_main_lbl_longname, $frm_main_longname
Global $frm_main_lbl_shortname, $frm_main_shortname
Global $frm_main_lbl_description, $frm_main_description
Global $frm_main_lbl_profile, $frm_main_profile
Global $frm_main_lbl_template, $frm_main_template
Global $frm_main_OK, $frm_main_Cancel

SRandom(@YDAY & @MSEC)
$mymutex = Hex(Random(0, 65535, 1), 4) & Hex(Random(0, 65535, 1), 4) & Hex(Random(0, 65535, 1), 4) & Hex(Random(0, 65535, 1), 4)

_frm_main()

Func _frm_main()
    ;form
    Global $frm_main = GUICreate("New Project Folder", 412, 235, 194, 233)
    GUISetFont(7, 400, 0, "MS Sans Serif")
    GUISetOnEvent($GUI_EVENT_CLOSE, "_frm_main_Close")
    GUISetOnEvent($GUI_EVENT_MINIMIZE, "_frm_main_Minimize")
    GUISetOnEvent($GUI_EVENT_RESTORE, "_frm_main_Restore")
    If $CmdLine[0] = 0 Then
        ;path
        Global $frm_main_lbl_path = GUICtrlCreateLabel("Target Path:", 8, 8, 63, 17, 0)
        Global $frm_main_path = GUICtrlCreateInput("", 80, 8, 303, 21)
        GUICtrlSetTip($frm_main_path, "Path where the new folder should be created")
        Global $frm_main_browse = GUICtrlCreateButton("...", 384, 8, 19, 21, $WS_GROUP)
        GUICtrlSetTip($frm_main_browse, "Browse")
        GUICtrlSetOnEvent($frm_main_browse, "_frm_main_browse_click")
    EndIf
    ;long name
    $frm_main_lbl_longname = GUICtrlCreateLabel("Long Name:", 8, 40, 62, 17, 0)
    $frm_main_longname = GUICtrlCreateInput("", 80, 40, 321, 21, $GUI_SS_DEFAULT_INPUT)
    GUICtrlSetTip($frm_main_longname, "Full name of the project")
    GUICtrlSetOnEvent($frm_main_longname, "_frm_main_longname_Change")
    ;short name
    $frm_main_lbl_shortname = GUICtrlCreateLabel("Short Name:", 8, 72, 63, 17, 0)
    $frm_main_shortname = GUICtrlCreateInput("", 80, 72, 321, 21, $GUI_SS_DEFAULT_INPUT)
    GUICtrlSetTip($frm_main_shortname, "Short name for project (and name of the new folder)")
    ;description
    $frm_main_lbl_description = GUICtrlCreateLabel("Description:", 8, 104, 60, 17, 0)
    $frm_main_description = GUICtrlCreateInput("", 80, 104, 321, 21, $GUI_SS_DEFAULT_INPUT)
    GUICtrlSetTip($frm_main_description, "Description of the new project")
    ;profile
    $frm_main_lbl_profile = GUICtrlCreateLabel("Profile:", 8, 136, 36, 17)
    $frm_main_profile = GUICtrlCreateCombo("", 80, 136, 321, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    GUICtrlSetTip($frm_main_profile, "Profile (your info) to use for this project")
    ;template
    $frm_main_lbl_template = GUICtrlCreateLabel("Template:", 8, 168, 51, 17)
    $frm_main_template = GUICtrlCreateCombo("", 80, 168, 321, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    GUICtrlSetTip($frm_main_template, "Project template to use")
    ;ok button
    $frm_main_OK = GUICtrlCreateButton("OK", 16, 200, 179, 25)
    GUICtrlSetOnEvent($frm_main_OK, "_frm_main_OK_Click")
    GUICtrlSetTip($frm_main_OK, "Create the project folder")
    ;cancel button
    $frm_main_Cancel = GUICtrlCreateButton("Cancel", 216, 200, 179, 25)
    GUICtrlSetOnEvent($frm_main_Cancel, "_frm_main_Cancel_Click")
    GUICtrlSetTip($frm_main_Cancel, "Abort the new project folder")
    If $CmdLine[0] > 0 Then
        ;path
        Global $frm_main_lbl_path = GUICtrlCreateLabel("Target Path:", 8, 8, 63, 17, 0)
        Global $frm_main_path = GUICtrlCreateInput("", 80, 8, 303, 21)
        GUICtrlSetTip($frm_main_path, "Path where the new folder should be created")
        Global $frm_main_browse = GUICtrlCreateButton("...", 384, 8, 19, 21, $WS_GROUP)
        GUICtrlSetTip($frm_main_browse, "Browse")
        GUICtrlSetOnEvent($frm_main_browse, "_frm_main_browse_click")
    EndIf
    ;load default values
    _frm_main_LoadDefaults()
    ;run the GUI
    GUISetState(@SW_SHOW, $frm_main)
    $frm_main_loop = True
    While $frm_main_loop
        Sleep(100)
    WEnd
EndFunc   ;==>_frm_main

Func _frm_main_Close()
    _frm_main_Cancel_Click()
EndFunc   ;==>_frm_main_Close

Func _frm_main_Minimize()
EndFunc   ;==>_frm_main_Minimize

Func _frm_main_Restore()
EndFunc   ;==>_frm_main_Restore

Func _frm_main_browse_click()
    Local $ret
    $ret = FileSelectFolder("Select folder where project folder will be created", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", 7, StringStripWS(GUICtrlRead($frm_main_path), 8))
    If $ret <> "" Then GUICtrlSetData($frm_main_path, $ret)
EndFunc   ;==>_frm_main_browse_click

Func _frm_main_longname_Change()
    Local $short = GUICtrlRead($frm_main_shortname)
    If StringStripWS($short, 3) = "" Then
        GUICtrlSetData($frm_main_shortname, StringStripWS(GUICtrlRead($frm_main_longname), 8))
    EndIf
EndFunc   ;==>_frm_main_longname_Change

Func _frm_main_OK_Click()
    If Not _frm_main_ValidEntries() Then Return
    GUISetState(@SW_HIDE, $frm_main)
    $frm_main_loop = False
    _frm_main_SaveDefaluts()
    _CreateFolder()
EndFunc   ;==>_frm_main_OK_Click

Func _frm_main_Cancel_Click()
    GUISetState(@SW_HIDE, $frm_main)
    $frm_main_loop = False
EndFunc   ;==>_frm_main_Cancel_Click

Func _frm_main_SaveDefaluts()
    IniWrite($IniFile, "LastValues", "profile", GUICtrlRead($frm_main_profile))
    IniWrite($IniFile, "LastValues", "template", GUICtrlRead($frm_main_template))
EndFunc   ;==>_frm_main_SaveDefaluts

Func _frm_main_LoadDefaults()
    Local $temp1, $temp2
    ;;path
    Switch $CmdLine[0]
        Case 0 ;No path provided, use @WorkingDir
            $temp1 = @WorkingDir
            If StringRight($temp1, 1) <> "\" Then $temp1 &= "\"
        Case 1
            $temp1 = $CmdLine[1] ;Path given on command line
        Case Else
            $temp1 = $CmdLine[2] ;Path given through context menu
    EndSwitch
    $temp1 = StringLeft($temp1, StringInStr($temp1, "\", 0, -1))
    GUICtrlSetData($frm_main_path, $temp1)
    ;;profile
    $temp1 = _GetProfiles()
    $temp2 = IniRead($IniFile, "LastValues", "profile", "")
    GUICtrlSetData($frm_main_profile, $temp1, $temp2)
    ;;template
    $temp1 = _GetTemplates()
    $temp2 = IniRead($IniFile, "LastValues", "template", "")
    GUICtrlSetData($frm_main_template, $temp1, $temp2)
EndFunc   ;==>_frm_main_LoadDefaults

Func _frm_main_ValidEntries()
    Local $Invalid = ""
    If StringStripWS(GUICtrlRead($frm_main_path), 3) = "" Then $Invalid &= @CRLF & "Target Path"
    If StringStripWS(GUICtrlRead($frm_main_longname), 3) = "" Then $Invalid &= @CRLF & "Long Name"
    If StringStripWS(GUICtrlRead($frm_main_shortname), 3) = "" Then $Invalid &= @CRLF & "Short Name"
    If StringStripWS(GUICtrlRead($frm_main_profile), 3) = "" Then $Invalid &= @CRLF & "Profile"
    If StringStripWS(GUICtrlRead($frm_main_template), 3) = "" Then $Invalid &= @CRLF & "Template"
    If $Invalid = "" Then Return True
    MsgBox(8192 + 48, $MyName & " Warning", "The following fields must have valid entries:" & $Invalid)
    Return False
EndFunc   ;==>_frm_main_ValidEntries

Func _GetProfiles()
    Local $search, $file
    Local $found = ""
    $search = FileFindFirstFile(@ScriptDir & "\profiles\*.ini")
    If $search = -1 Then
        Return ""
    EndIf
    While 1
        $file = FileFindNextFile($search)
        If @error Then ExitLoop
        If StringLower(IniRead(@ScriptDir & "\profiles\" & $file, "config", "status", "")) = "active" Then
            $found &= "|" & StringLeft($file, StringInStr($file, ".", 0, -1) - 1)
        EndIf
    WEnd
    FileClose($search)
    If $found <> "" Then $found = StringRight($found, StringLen($found) - 1)
    Return $found
EndFunc   ;==>_GetProfiles

Func _GetTemplates()
    Local $search, $file
    Local $found = ""
    $search = FileFindFirstFile(@ScriptDir & "\templates\*.*")
    If $search = -1 Then
        Return ""
    EndIf
    While 1
        $file = FileFindNextFile($search)
        If @error Then ExitLoop
        If StringLower(IniRead(@ScriptDir & "\templates\" & $file & "\template.ini", "config", "status", "")) = "active" Then
            $found &= "|" & $file
        EndIf
    WEnd
    FileClose($search)
    If $found <> "" Then $found = StringRight($found, StringLen($found) - 1)
    Return $found
EndFunc   ;==>_GetTemplates

Func _CreateFolder()
    Local $files, $NewPath, $source, $target, $i, $data, $attrib, $activedir
    $vars = IniReadSection(@ScriptDir & "\profiles\" & StringStripWS(GUICtrlRead($frm_main_profile), 3) & ".ini", "variables")
    If @error Then
        MsgBox(8192 + 16, $MyName & " Error", "Unable to read " & @ScriptDir & "\profiles\" & StringStripWS(GUICtrlRead($frm_main_profile), 3) & ".ini" & @CRLF & "Profile may be corrupt")
        Exit 2
    EndIf
    $files = IniReadSection(@ScriptDir & "\templates\" & StringStripWS(GUICtrlRead($frm_main_template), 3) & "\template.ini", "files")
    If @error Then
        MsgBox(8192 + 16, $MyName & " Error", "Unable to read " & @ScriptDir & "\templates\" & StringStripWS(GUICtrlRead($frm_main_template), 3) & "\template.ini" & @CRLF & "Template may be corrupt")
        Exit 1
    EndIf
    $delimiter = IniRead(@ScriptDir & "\templates\" & StringStripWS(GUICtrlRead($frm_main_template), 3) & "\template.ini", "config", "variablemarker", "__")
    $NewPath = StringStripWS(GUICtrlRead($frm_main_path), 3)
    If StringRight($NewPath, 1) <> "\" Then $NewPath &= "\"
    $NewPath &= StringStripWS(GUICtrlRead($frm_main_shortname), 3)
    DirCreate($NewPath)
    FileSetAttrib($NewPath, "+s")
    If $files[0][0] > 0 Then
        For $i = 1 To $files[0][0]
            $source = $files[$i][1]
            While StringLeft($source, 1) = "\"
                $source = StringStripWS(StringRight($source, StringLen($source) - 1), 1)
            WEnd
            $target = $source
            If StringInStr("fr", StringLower($files[$i][0])) Then _ReplaceVariables($target)
            $attrib = FileGetAttrib(@ScriptDir & "\templates\" & StringStripWS(GUICtrlRead($frm_main_template), 3) & "\include\" & $source)
            StringReplace($attrib, "N", "")
            StringReplace($attrib, "D", "")
            StringReplace($attrib, "O", "")
            StringReplace($attrib, "C", "")
            StringReplace($attrib, "T", "")
            $data = FileRead(@ScriptDir & "\templates\" & StringStripWS(GUICtrlRead($frm_main_template), 3) & "\include\" & $source)
            If StringInStr("fp", StringLower($files[$i][0])) Then _ReplaceVariables($data)
            If StringInStr($target, "\") Then DirCreate($NewPath & "\" & StringLeft($target, StringInStr($target, "\", 0, -1) - 1))
            FileWrite($NewPath & "\" & $target, $data)
            FileSetAttrib($NewPath & "\" & $target, "+" & $attrib)
        Next
    EndIf
    $files = IniReadSection(@ScriptDir & "\templates\" & StringStripWS(GUICtrlRead($frm_main_template), 3) & "\template.ini", "execute")
    If Not @error Then
        If $files[0][0] > 0 Then
            For $i = 1 To $files[0][0]
                $activedir = StringLeft($NewPath & "\" & $files[$i][1], StringInStr($NewPath & "\" & $files[$i][1], "\", 0, -1) - 1)
                Switch StringLower(StringRight($files[$i][1], StringLen($files[$i][1]) - StringInStr($files[$i][1], ".", 0, -1)))
                    Case "bat", "cmd"
                        RunWait(@ComSpec & " /c " & '"' & $NewPath & "\" & $files[$i][1] & '"', $activedir)
                    Case Else
                        ShellExecuteWait($NewPath & "\" & $files[$i][1], "", $activedir)
                EndSwitch
            Next
        EndIf
    EndIf
EndFunc   ;==>_CreateFolder

Func _ReplaceVariables(ByRef $thestring)
    Local $i
    $thestring = StringReplace($thestring, _Delimited("templatepath"), @ScriptDir & "\templates\" & StringStripWS(GUICtrlRead($frm_main_template), 3) & "\include", 0, 1)
    $thestring = StringReplace($thestring, _Delimited("nameshort"), StringStripWS(GUICtrlRead($frm_main_shortname), 3), 0, 1)
    $thestring = StringReplace($thestring, _Delimited("namelong"), StringStripWS(GUICtrlRead($frm_main_shortname), 3), 0, 1)
    $thestring = StringReplace($thestring, _Delimited("autoitver"), RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "Version"), 0, 1)
    $thestring = StringReplace($thestring, _Delimited("date"), _NowDate(), 0, 1)
    $thestring = StringReplace($thestring, _Delimited("description"), StringStripWS(GUICtrlRead($frm_main_description), 3), 0, 1)
    $thestring = StringReplace($thestring, _Delimited("mutex"), $mymutex, 0, 1)
    If $vars[0][0] > 0 Then
        For $i = 1 To $vars[0][0]
            $thestring = StringReplace($thestring, _Delimited($vars[$i][0]), $vars[$i][1], 0, 1)
        Next
    EndIf
EndFunc   ;==>_ReplaceVariables

Func _Delimited($thestring)
    Return $delimiter & $thestring & $delimiter
EndFunc   ;==>_Delimited

install.au3

Global Const $installpath = @ProgramFilesDir & "\MyProjectFolder\"
Global Const $extension = ".mypf"
Global Const $classname = "MyProjectFolder"
Global Const $menutext = "MyProject Folder"

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)

If Not IsAdmin() Then
    MsgBox(0, "MyProjectFolder Installer", "You must have administrator rights to install this utility.")
    Exit
EndIf

Global $frm_install_loop = True
Global $frm_install = GUICreate("Install", 180, 138, 192, 132)
GUISetFont(7, 400, 0, "MS Sans Serif")
GUISetOnEvent($GUI_EVENT_CLOSE, "frm_installClose")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "frm_installMinimize")
GUISetOnEvent($GUI_EVENT_RESTORE, "frm_installRestore")
Global $frm_install_context = GUICtrlCreateCheckbox("Add to context menu", 8, 8, 153, 17)
GUICtrlSetState($frm_install_context, $GUI_CHECKED)
GUICtrlSetOnEvent($frm_install_context, "frm_install_contextClick")
Global $frm_install_desktop = GUICtrlCreateCheckbox("Create desktop shortcut", 8, 32, 169, 17)
GUICtrlSetState($frm_install_desktop, $GUI_CHECKED)
GUICtrlSetOnEvent($frm_install_desktop, "frm_install_desktopClick")
Global $frm_install_allusers = GUICtrlCreateCheckbox("All users", 24, 56, 81, 17)
GUICtrlSetState($frm_install_allusers, $GUI_CHECKED)
GUICtrlSetOnEvent($frm_install_allusers, "frm_install_allusersClick")
Global $frm_install_startmenu = GUICtrlCreateCheckbox("Add to Start menu", 8, 80, 129, 17)
GUICtrlSetState($frm_install_startmenu, $GUI_CHECKED)
GUICtrlSetOnEvent($frm_install_startmenu, "frm_install_startmenuClick")
Global $frm_install_OK = GUICtrlCreateButton("OK", 8, 104, 75, 25, $WS_GROUP)
GUICtrlSetOnEvent($frm_install_OK, "frm_install_OKClick")
Global $frm_install_Cancel = GUICtrlCreateButton("Cancel", 96, 104, 75, 25, $WS_GROUP)
GUICtrlSetOnEvent($frm_install_Cancel, "frm_install_CancelClick")
GUISetState(@SW_SHOW)

While $frm_install_loop
    Sleep(100)
WEnd

Func frm_install_allusersClick()
EndFunc   ;==>frm_install_allusersClick
Func frm_install_CancelClick()
    Exit
EndFunc   ;==>frm_install_CancelClick
Func frm_install_contextClick()
EndFunc   ;==>frm_install_contextClick
Func frm_install_desktopClick()
EndFunc   ;==>frm_install_desktopClick
Func frm_install_OKClick()
    $frm_install_loop = False
EndFunc   ;==>frm_install_OKClick
Func frm_install_startmenuClick()
EndFunc   ;==>frm_install_startmenuClick
Func frm_installClose()
    frm_install_CancelClick()
EndFunc   ;==>frm_installClose
Func frm_installMinimize()
EndFunc   ;==>frm_installMinimize
Func frm_installRestore()
EndFunc   ;==>frm_installRestore

DirCreate($installpath & "profiles")
DirCreate($installpath & "templates\AU3-general\include")
DirCreate($installpath & "templates\AU3-Sqlite\include")
FileInstall("MyProjectFolder.exe", $installpath & "MyProjectFolder.exe", 1)
FileInstall("icons\MyProjectFolder.ico", $installpath & "MyProjectFolder.ico", 0)
FileInstall("icons\MyAU3Project.ico", $installpath & "MyAU3Project.ico", 0)
FileInstall("uninstall.exe", $installpath & "uninstall.exe", 1)
FileInstall("profiles\sample.ini", $installpath & "profiles\sample.ini", 0)
FileInstall("templates\AU3-general\template.ini", $installpath & "templates\AU3-general\template.ini", 0)
FileInstall("templates\AU3-general\include\__nameshort__.au3", $installpath & "templates\AU3-general\include\__nameshort__.au3", 0)
FileInstall("templates\AU3-general\include\__nameshort__.ico", $installpath & "templates\AU3-general\include\__nameshort__.ico", 0)
FileInstall("templates\AU3-general\include\config.au3", $installpath & "templates\AU3-general\include\config.au3", 0)
FileInstall("templates\AU3-general\include\Desktop.ini", $installpath & "templates\AU3-general\include\Desktop.ini", 0)
FileInstall("templates\AU3-Sqlite\template.ini", $installpath & "templates\AU3-Sqlite\template.ini", 0)
FileInstall("templates\AU3-Sqlite\include\__nameshort__.au3", $installpath & "templates\AU3-Sqlite\include\__nameshort__.au3", 0)
FileInstall("templates\AU3-Sqlite\include\__nameshort__.ico", $installpath & "templates\AU3-Sqlite\include\__nameshort__.ico", 0)
FileInstall("templates\AU3-Sqlite\include\config.au3", $installpath & "templates\AU3-Sqlite\include\config.au3", 0)
FileInstall("templates\AU3-Sqlite\include\Desktop.ini", $installpath & "templates\AU3-Sqlite\include\Desktop.ini", 0)
FileSetAttrib($installpath & "templates\AU3-general\include\Desktop.ini", "+sh")
FileSetAttrib($installpath & "templates\AU3-Sqlite\include\Desktop.ini", "+sh")

If GUICtrlRead($frm_install_startmenu) = $GUI_CHECKED Then
    DirCreate(@ProgramsCommonDir & "\MyProjectFolder")
    FileCreateShortcut($installpath & "MyProjectFolder.exe", @ProgramsCommonDir & "\MyProjectFolder\New MyProject Folder.lnk")
    FileCreateShortcut($installpath & "uninstall.exe", @ProgramsCommonDir & "\MyProjectFolder\Uninstall.lnk")
EndIf

If GUICtrlRead($frm_install_desktop) = $GUI_CHECKED Then
    If GUICtrlRead($frm_install_allusers) = $GUI_CHECKED Then
        FileCreateShortcut($installpath & "MyProjectFolder.exe", @DesktopCommonDir & "\New MyProject Folder.lnk")
    Else
        FileCreateShortcut($installpath & "MyProjectFolder.exe", @DesktopDir & "\New MyProject Folder.lnk")
    EndIf
EndIf

If GUICtrlRead($frm_install_context) = $GUI_CHECKED Then
    RegWrite('HKEY_CLASSES_ROOT\' & $classname, "", "REG_SZ", $menutext)
    RegWrite('HKEY_CLASSES_ROOT\' & $classname & '\DefaultIcon', "", "REG_SZ", $installpath & 'MyProjectFolder.ico')
    RegWrite('HKEY_CLASSES_ROOT\' & $classname & '\Shell', "", "REG_SZ", 'Open')
    RegWrite('HKEY_CLASSES_ROOT\' & $classname & '\Shell\Open', "", "REG_SZ", 'Open')
    RegWrite('HKEY_CLASSES_ROOT\' & $classname & '\Shell\Open\Command', "", "REG_SZ", 'notepad "%1"')
    RegWrite('HKEY_CLASSES_ROOT\' & $extension, 'PerceivedType', "REG_SZ", 'text')
    RegWrite('HKEY_CLASSES_ROOT\' & $extension, "", "REG_SZ", $classname)
    RegWrite('HKEY_CLASSES_ROOT\' & $extension & '\PersistentHandler', "", "REG_SZ", '{5e941d80-bf96-11cd-b579-08002b30bfeb}')
    RegWrite('HKEY_CLASSES_ROOT\' & $extension & '\ShellNew', 'Command', "REG_SZ", '"' & $installpath & 'MyProjectFolder.exe" "%1"')
    MsgBox(64, "MyAU3Project Installer", "It is recomended that you restart your PC to complete the installation process.")
EndIf

Exit

---------- Edit ----------

12/21/2010 - Added admin rights detection to the installer

Edited by willichan
Link to comment
Share on other sites

shanet was right, the administrator right is needed. I thought I tried it, seems not.

BTW your installer not ask for administrator right and don't do error if I don't have the right

Seems you don't use AutoIt Wrapper, you could easy fix it with that

#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator

Cheers

Link to comment
Share on other sites

BTW your installer not ask for administrator right and don't do error if I don't have the right

I have added admin rights checking to the installer above. That is one of those cleanups I never got around to. :x

Seems you don't use AutoIt Wrapper, you could easy fix it with that

I do use the wrapper, but I usually strip that out before posting code. I tend to avoid putting anything that affects functionality as compiler directives. Where ever possible, I try to keep that within the code.

I use the wrapper more for things like version info, custom icons, tidy, obfuscator's /striponly, etc...

Link to comment
Share on other sites

  • 1 month later...

A purely aesthetic update. If run directly (from start menu) focus goes to the path field. Otherwise, focus goes to the long name field.

Link to comment
Share on other sites

  • 7 months later...

Added another template available for download.

HTML-Book2 semi-automates the creation of the Chapter list and links. I changed over to this template when I was making HTML versions of books downloaded from Project Gutenberg. I have created an at-home online library for my kids to have access to. I needed to not only make the texts look nicer and be easier to read, but I also needed to have them in a format that could be more easily converted to read on Palm, iPod, etc. This template has made that work much easier.

Please see the original post above for the download link.

---- Edit ----

You will also need to update to the version of this utility that was also uploaded today. It adds support for executing an external file as part of the template folder creation process.

Edited by willichan
Link to comment
Share on other sites

  • 7 months later...

Script is now fully Windows 7 (32bit and 64bit) compatible. See the for current code.

I still want to put the uninstaller in the add/remove programs screen, but I am being kind of lazy lately.

This version moves templates and profiles to a new location to accomodate the Windows 7 model.

Templates are in @AppDataCommonDir & "MyProjectFoldertemplates"

Profiles are in @AppDataCommonDir & "MyProjectFolderprofiles"

I recommend backing up your template and profile folders, and uninstalling the old version before installing this one, then restore your folders to the new locations.

You do not have to, but the files in the old location will not be used, and will just consume disk space. Once you install the newer version, uninstall will no longer clean-up the old location.

Edited by willichan
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...