Achilles Posted June 16, 2010 Share Posted June 16, 2010 (edited) Working alongside Scite, AutoItEasy lets you manage large programs with simplicity. Instead of scrolling through one huge file to get to specific part, you can work with multiple files. For example, I usually group things like this: Includes, Constants, GUI, Events, Helpers.. etc. Now each of those can have its own file that you work with in Scite. But whenever you want to throw everything together just click a button (Tools >> View Full Source) in the AutoItEasy window and it will group all your code together in the order you have it and open your entire project code in Scite.As always, please post your comments/suggestions/criticisms... This is not close to a final version, but I figured it was a good point to release a prototype..Hmm, I don't know if that made any sense. But here's the code: (note, the option for compile doesn't work yet because I'm lazy)Edit: On actually trying to use this for an actual program, I think it definitely needs some work... lots of issues with the concept, the code works fine..expandcollapse popup#Include <Constants.au3> #include <EditConstants.au3> #Include <File.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt('GUIOnEventMode', 1) Global $width = 350 Global $height = 250 Global $curProj = '' ; for testing purposes $gui = GUICreate('AutoItEasy', $width, $height, -1, -1, $WS_SIZEBOX) GUISetOnEvent($GUI_EVENT_CLOSE, '_Exit') $mainMenu = GUICtrlCreateMenu('File') GUICtrlCreateMenuItem('New project', $mainMenu) GUICtrlSetOnEvent(-1, '_NewProj') GUICtrlCreateMenuItem('Open project', $mainMenu) GUICtrlSetOnEvent(-1, '_OpenProj') GUICtrlCreateMenuItem('', $mainMenu) $btnCloseProj = GUICtrlCreateMenuItem('Close project', $mainMenu) GUICtrlSetOnEvent(-1, '_CloseProj') GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateMenuItem('', $mainMenu) GUICtrlCreateMenuItem('Exit', $mainMenu) $toolsMenu = GUICtrlCreateMenu('Tools') $btnFullSource = GUICtrlCreateMenuItem('View full source', $toolsMenu) GUICtrlSetOnEvent(-1, '_FullSource') GUICtrlSetState(-1, $GUI_DISABLE) $btnCompile = GUICtrlCreateMenuItem('Compile to exe', $toolsMenu) GUICtrlSetState(-1, $GUI_DISABLE) $exStyle = BitOR($LVS_EX_FULLROWSELECT , $LVS_EX_GRIDLINES) $lstFiles = GUICtrlCreateListView('', 0, 0, $width, $height - 42, -1, $exStyle) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHEIGHT, $GUI_DOCKBORDERS)) $lstFilesHdl = GUICtrlGetHandle($lstFiles) _GUICtrlListView_AddColumn($lstFilesHdl, 'Name', 200) _GUICtrlListView_AddColumn($lstFilesHdl, 'Lines') _GUICtrlListView_AddColumn($lstFilesHdl, 'Size') $fileMenu = GUICtrlCreateContextMenu($lstFiles) $btnOpen = GUICtrlCreateMenuItem('Open', $fileMenu) GUICtrlSetState(-1, $TRAY_DEFAULT) GUICtrlSetOnEvent(-1, '_Open') $btnDelete = GUICtrlCreateMenuItem('Delete', $fileMenu) GUICtrlCreateMenuItem('', $fileMenu) $btnMoveUp = GUICtrlCreateMenuItem('Move up', $fileMenu) GUICtrlSetOnEvent(-1, '_MoveUp') GUICtrlSetState(-1, $GUI_DISABLE) $btnMoveDown = GUICtrlCreateMenuItem('Move down', $fileMenu) GUICtrlSetOnEvent(-1, '_MoveDown') GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateMenuItem('', $fileMenu) $btnAddFile = GUICtrlCreateMenuItem('Add new file...', $fileMenu) GUICtrlSetOnEvent(-1, '_AddFile') GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY') GUISetState() While 1 Sleep(200) WEnd Func _FullSource() If $curProj = '' then Return $count = _GUICtrlListView_GetItemCount($lstFilesHdl) $fullFilePath = $curProj & '\' & _GetLastFolder($curProj) & '.au3' $fullFile = FileOpen($fullFilePath, 10) FileWriteLine($fullFile, ';~ Please make any code changes in the individual source files') FileWriteLine($fullFile, ';~ AutoItEasy will not remember any changes you make here') For $i = 0 to $count - 1 $f = _GUICtrlListView_GetItemText($lstFilesHdl, $i, 0) $fn = $curProj & '\Files\' & $f & '.au3' Local $temp[1] = ['#region *** ' & $f & ' ***'] $file = FileOpen($fn) While 1 $line = FileReadLine($file) If @error = -1 then ExitLoop _ArrayAdd($temp, $line) WEnd _ArrayAdd($temp, @CRLF) _ArrayAdd($temp, '#endregion') _FileWriteFromArray($fullFile, $temp) Next FileClose($fullFile) ShellExecute($fullFilePath, '', $curProj, 'edit') EndFunc Func _UpdateList() $count = _GUICtrlListView_GetItemCount($lstFilesHdl) _GUICtrlListView_BeginUpdate($lstFilesHdl) For $i = 0 to $count - 1 $file = $curProj & '\Files\' & _GUICtrlListView_GetItemText($lstFilesHdl, $i) & '.au3' $size = Round(FileGetSize($file) / 1024, 0) If $size = 0 then $size = 1 $lines = _FileCountLines($file) _GUICtrlListView_SetItemText($lstFilesHdl, $i, $lines, 1) _GUICtrlListView_SetItemText($lstFilesHdl, $i, $size & 'KB', 2) Next _GUICtrlListView_EndUpdate($lstFilesHdl) EndFunc Func _Open() $index = _GUICtrlListView_GetSelectedIndices($lstFilesHdl) $file = _GUICtrlListView_GetItemText($lstFilesHdl, $index, 0) ShellExecute($curProj & '\Files\' & $file & '.au3', '', $curProj, 'edit', @SW_SHOWNOACTIVATE) EndFunc Func _MoveUp() $count = _GUICtrlListView_GetItemCount($lstFilesHdl) $index = _GUICtrlListView_GetSelectedIndices($lstFilesHdl) If $index = 0 then Return $text = _GUICtrlListView_GetItemTextString($lstFilesHdl, $index) _GUICtrlListView_DeleteItem($lstFilesHdl, $index) _GUICtrlListView_InsertItem($lstFilesHdl, $text, $index - 1) _GUICtrlListView_SetItemSelected($lstFilesHdl, $index - 1, True, True) EndFunc Func _MoveDown() $count = _GUICtrlListView_GetItemCount($lstFilesHdl) $index = _GUICtrlListView_GetSelectedIndices($lstFilesHdl) If $index = $count - 1 then Return $text = _GUICtrlListView_GetItemTextString($lstFilesHdl, $index) _GUICtrlListView_DeleteItem($lstFilesHdl, $index) _GUICtrlListView_InsertItem($lstFilesHdl, $text, $index + 1) _GUICtrlListView_SetItemSelected($lstFilesHdl, $index + 1, True, True) EndFunc Func _AddFile() $fileName = InputBox('New file', 'Input file name...', '', '', 200, 130) If $fileName = '' then Return $fullFileName = $curProj & '\Files\' & $fileName & '.au3' If FileExists($fullFileName) then Msgbox(16, 'Error', 'A file with that name already exists!') Return EndIf _FileCreate($fullFileName) ShellExecute($fullFileName, '', $curProj, 'edit', @SW_SHOWNOACTIVATE) ;~ WinSetState($gui, '', @SW_SHOW) _GUICtrlListView_AddItem($lstFilesHdl, $fileName) EndFunc Func _CloseProj() $file = FileOpen($curProj & '\order.txt', 2) For $i = 0 to _GUICtrlListView_GetItemCount($lstFilesHdl) - 1 FileWriteLine($file, _GUICtrlListView_GetItemText($lstFilesHdl, $i)) Next _GUICtrlListView_DeleteAllItems($lstFilesHdl) WinSetTitle($gui, '', 'AutoItEasy') GUICtrlSetState($btnCloseProj, $GUI_DISABLE) GUICtrlSetState($btnFullSource, $GUI_DISABLE) GUICtrlSetState($btnCompile, $GUI_DISABLE) $curProj = '' EndFunc Func _OpenProj($pass = '') $dir = FileSelectFolder('Select a folder...', @HomePath, 7, @MyDocumentsDir) If $dir = '' then Return If $curProj <> '' then _CloseProj() $curProj = $dir Local $data _FileReadToArray($curProj & '\order.txt', $data) ;~ _ArrayDisplay($data) _GUICtrlListView_BeginUpdate($lstFilesHdl) For $i = 1 to UBound($data) - 1 If StringLeft($data[$i], 2) = '\\' then Else _GUICtrlListView_AddItem($lstFilesHdl, $data[$i]) EndIf Next _GUICtrlListView_EndUpdate($lstFilesHdl) _UpdateList() GUICtrlSetState($btnCloseProj, $GUI_ENABLE) GUICtrlSetState($btnFullSource, $GUI_ENABLE) GUICtrlSetState($btnCompile, $GUI_ENABLE) WinSetTitle($gui, '', 'AutoItEasy - ' & $curProj) EndFunc Func _NewProj() WinSetState($gui, '', @SW_DISABLE) Opt('GUIOnEventMode', 0) $width = 300 $height = 135 $projGUI = GUICreate('New project', $width, $height) GUICtrlCreateLabel('Name:', 10, 10, 50, 25, $SS_CENTERIMAGE) $txtName = GUICtrlCreateInput('', 70, 11, $width - 80, 22) GUICtrlCreateLabel('Location:', 10, 40, 50, 25, $SS_CENTERIMAGE) $txtDir = GUICtrlCreateInput(@DesktopDir, 70, 41, $width - 110, 22) $btnBrowseDir = GUICtrlCreateButton('...', $width - 35, 41, 25, 22) GUICtrlCreateLabel('Icon:', 10, 70, 50, 25, $SS_CENTERIMAGE) $txtIcon = GUICtrlCreateInput(@AutoItExe, 70, 71, $width - 110, 22, $ES_READONLY) $btnBrowseIcon = GUICtrlCreateButton('...', $width - 35, 71, 25, 22) GUICtrlCreateLabel('Preview:', 10, 105, 50, 22, $SS_CENTERIMAGE) $lblIco = GUICtrlCreateIcon(@AutoItExe, -1, 70, 96, 32, 32) $iconPath = @AutoItExe $iconIndex = 0 $btnCancel = GUICtrlCreateButton('Cancel', $width - 140, 105, 60, 22) $btnCreate = GUICtrlCreateButton('Create', $width - 70, 105, 60, 22) GUISetState() $msg = -1 Do $msg = GUIGetMsg() Switch $msg Case $btnBrowseDir $dir = FileSelectFolder('Select a folder...', @HomePath, 7, @MyDocumentsDir) If $dir <> '' then GUICtrlSetData($txtDir, $dir) EndIf Case $btnBrowseIcon $data = _WinAPI_PickIconDlg('', '', $projGUI) If Not @error then GUICtrlSetData($txtIcon, $data[0]) GUICtrlSetImage($lblIco, $data[0], - (1 + $data[1])) $iconPath = $data[0] $iconIndex = -1 * (1 + $data[1]) EndIf Case $btnCancel ExitLoop Case $btnCreate $dir = GUICtrlRead($txtDir) $pass = 5 $name = GUICtrlRead($txtName) If FileExists($dir & '\' & $name) then $pass = Msgbox(36, 'Warning', 'The directory you selected already exists. If you continue that directory will be deleted and recreated. Would you like to continue?') EndIf If $pass < 7 then ; if either the user pressed yes to overwrite or there was no folder to begin with If $pass = 6 then DirRemove($dir & '\' & $name) If $name = '' then Msgbox(16, 'Error', 'You must enter a name for the project!') Else $pass = DirCreate($dir & '\' & $name) If $pass = 0 then Msgbox(16, 'Error', 'There was an error created the selected directory.') Else DirCreate($dir & '\' & $name & '\Files') $before = $iconIndex If $iconIndex < 0 then $iconIndex = Abs($iconIndex + 1) EndIf ConsoleWrite('> b: ' & $before & @TAB & 'a: ' & $iconIndex) $file = FileOpen($dir & '\' & $name & '\desktop.ini', 2) FileWriteLine($file, '[.ShellClassInfo]') FileWriteLine($file, 'IconResource=' & $iconPath & ',' & $iconIndex) FileClose($file) FileSetAttrib($dir & '\' & $name & '\desktop.ini', 'HSA') FileSetAttrib($dir & '\' & $name, '+S') If $curProj <> '' then _CloseProj() $curProj = $dir & '\' & $name GUICtrlSetState($btnCloseProj, $GUI_ENABLE) GUICtrlSetState($btnFullSource, $GUI_ENABLE) GUICtrlSetState($btnCompile, $GUI_ENABLE) ExitLoop EndIf EndIf EndIf EndSwitch Until $msg = $GUI_EVENT_CLOSE GUIDelete() Opt('GUIOnEventMode', 1) WinSetState($gui, '', @SW_ENABLE) If $msg = $btnCreate then WinSetTitle($gui, '', 'AutoItEasy - ' & $curProj) Else WinSetTitle($gui, '', 'AutoItEasy') EndIf EndFunc Func _Exit() WinSetState($gui, '', @SW_HIDE) _CloseProj() Exit EndFunc #region *** Notify *** Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $lstFilesHdl Switch $iCode Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) If DllStructGetData($tInfo, 'Index') = -1 then _AddFile() Else _Open() EndIf Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $index = DllStructGetData($tInfo, 'Index') $count = _GUICtrlListView_GetItemCount($lstFilesHdl) If $index = -1 then GUICtrlSetState($btnOpen, $GUI_DISABLE) GUICtrlSetState($btnDelete, $GUI_DISABLE) If $curProj = '' then GUICtrlSetState($btnAddFile, $GUI_DISABLE) Else GUICtrlSetState($btnAddFile, $TRAY_DEFAULT) EndIf GUICtrlSetState($btnMoveUp, $GUI_DISABLE) GUICtrlSetState($btnMoveDown, $GUI_DISABLE) Else GUICtrlSetState($btnOpen, $GUI_ENABLE) GUICtrlSetState($btnDelete, $GUI_ENABLE) GUICtrlSetState($btnOpen, $TRAY_DEFAULT) If $index > 0 then GUICtrlSetState($btnMoveUp, $GUI_ENABLE) Else GUICtrlSetState($btnMoveUp, $GUI_DISABLE) EndIf If $index < $count - 1 then GUICtrlSetState($btnMoveDown, $GUI_ENABLE) Else GUICtrlSetState($btnMoveDown, $GUI_DISABLE) EndIf EndIf Case $NM_SETFOCUS ; The control has received the input focus ;~ ConsoleWrite('! FOCUS' & @CRLF) _UpdateList() EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY #endregion #region *** Helpers *** Func _GetLastFolder($dir) $split = StringSplit($dir, '\') Return $split[$split[0]] EndFunc Func _SciteIsOpen() Return ProcessExists('Scite.exe') > 0 EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_PickIconDlg ; Description....: Displays a dialog box that allows the user to choose an icon. ; Syntax.........: _WinAPI_PickIconDlg ( [$sIcon [, $iIndex [, $hParent]]] ) ; Parameters.....: $sIcon - The fully-qualified path of the file that contains the initial icon. ; $iIndex - The index of the initial icon. ; $hParent - Handle of the parent window. ; Return values..: Success - The array containing the following parameters: ; ; [0] - The path of the file that contains the selected icon. ; [1] - The index of the selected icon. ; ; Failure - 0 and sets the @error flag to non-zero. ; Author.........: Yashied ; Modified.......: ; Remarks........: This function also sets the @error flag to 1 if the icon was not selected. ; Related........: ; Link...........: @@MsdnLink@@ PickIconDlg ; Example........: Yes ; =============================================================================================================================== Func _WinAPI_PickIconDlg($sIcon = '', $iIndex = 0, $hParent = 0) Local $tIcon = DllStructCreate('wchar[1024]'), $tIndex = DllStructCreate('int') Local $Ret, $Error = 1, $Result[2] = [$sIcon, $iIndex] DllStructSetData($tIcon, 1, $sIcon) DllStructSetData($tIndex, 1, $iIndex) $Ret = DllCall('shell32.dll', 'int', 'PickIconDlg', 'hwnd', $hParent, 'ptr', DllStructGetPtr($tIcon), 'int', 1024, 'ptr', DllStructGetPtr($tIndex)) If (Not @error) And ($Ret[0]) Then $Ret = DllCall('kernel32.dll', 'int', 'ExpandEnvironmentStringsW', 'wstr', DllStructGetData($tIcon, 1), 'ptr', DllStructGetPtr($tIcon), 'int', 1024) If (Not @error) And ($Ret[0]) Then $Result[0] = DllStructGetData($tIcon, 1) $Result[1] = DllStructGetData($tIndex, 1) $Error = 0 EndIf EndIf Return SetError($Error, 0, $Result) EndFunc ;==>_WinAPI_PickIconDlg #endregion Edited June 16, 2010 by Achilles My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
AlmarM Posted June 16, 2010 Share Posted June 16, 2010 Heya, good idea . You brought me on an idea. This is very useful :] Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Mat Posted June 16, 2010 Share Posted June 16, 2010 This is what I want: AutoIt Project Listing Link to comment Share on other sites More sharing options...
Achilles Posted June 16, 2010 Author Share Posted June 16, 2010 Heya, good idea .You brought me on an idea. This is very useful :]Thanks.. @Mat: That looks like it's been done.. or is that just some made up image? anyway, I would do something like that more if I could figure out how to embed scite in my window... I wouldn't run to just have plain text seeing that scite is definitely very useful My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
Mat Posted June 16, 2010 Share Posted June 16, 2010 Thanks.. @Mat: That looks like it's been done.. or is that just some made up image? anyway, I would do something like that more if I could figure out how to embed scite in my window... I wouldn't run to just have plain text seeing that scite is definitely very usefulMade up image. Took me a few minutes with the visual studio form designer.There are AutoIt UDF's for embedding SciTE so maybe it will be possible... AutoIt Project Listing Link to comment Share on other sites More sharing options...
SkinnyWhiteGuy Posted June 16, 2010 Share Posted June 16, 2010 Using the SciTe Director interface, it's pretty easy to design a Project Manager type GUI to manage the files for a project and communicate with SciTe, without having to embed it. I've actually been working on just such a creation recently. Nothing to show yet, but hopefully it won't take long to finish things up. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now