Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Script Manager


  • Please log in to reply
46 replies to this topic
asred
  • Members
  • 26 posts
  • Last active: Nov 24 2012 08:01 PM
  • Joined: 28 Feb 2011
I composed this script manager gui to manage all the script that I run throughout my work day. This Script Manager displays whatever Autohotkey scripts are located in the same directory it lives in. Use the buttons and menus to control and edit the listed scripts.

How it works: Select a script from the list and choose a command from the buttons below the listview or by using the right click context menu or the menubar.

Make it work for you: Just compile the script (save script as .ahk > right click on the .ahk > select compile) and move the executable to the same directory that your scripts live in and run it from there.

Note: Be sure to use the compiled (exe) version of the script manager rather than the .ahk. The only functional difference is that you will stop the Script Manager when the "Stop all running scripts" menu item is clicked because the subroutine will kill all running processes with the AutHotkey class.


Features / Included Commands:
* Displays a list of scripts in the working directory
* Run, reload, edit and stop scripts from the available script list
* Stop all running scripts
* Add a shortcut of the selected script to your startup folder
* Open the working directory
* Open the startup folder
* Open Window Spy
* Open AutoHotkey User Guide
* Create and delete scripts (New scripts have a built in template)



Contributers
iDrug - Close button = Minimize to system tray icon (version 2.3)
Spoiler


Code: Script Manager Full v.2.3 (Designd for Multiple folders)
Spoiler


shajul
  • Members
  • 571 posts
  • Last active: Aug 01 2015 03:45 PM
  • Joined: 15 Sep 2006
nice work. Some screenshots would be nice :)
If i've seen further it is by standing on the shoulders of giants

my site | ~shajul | WYSIWYG BBCode Editor

AmourSpirit
  • Members
  • 93 posts
  • Last active: Mar 01 2016 04:28 PM
  • Joined: 01 Dec 2010
I can see this being very useful.
Great work.

If you could pick additional folders to include scripts with and or all subfolder via recursion it would be un-believable. :idea:

I will still use it all the same :D

asred
  • Members
  • 26 posts
  • Last active: Nov 24 2012 08:01 PM
  • Joined: 28 Feb 2011

nice work. Some screenshots would be nice :)



Good idea! . . Done.

:)

asred
  • Members
  • 26 posts
  • Last active: Nov 24 2012 08:01 PM
  • Joined: 28 Feb 2011

If you could pick additional folders to include scripts with and or all subfolder via recursion it would be un-believable. :idea:



Yeah, that is a good idea. I am not sure that it would work though (at least with the way the subroutines are currently written) because the paths of scripts in subdirectories would be different than the working directory that the script manager executable lives in. This would result in the names of the scripts to be listed in the listview, but none of the subroutines would work on them.

I'd take it as a challenge if I were you. Good luck!

RESOURCE:
http://www.autohotke...ds/LoopFile.htm

shajul
  • Members
  • 571 posts
  • Last active: Aug 01 2015 03:45 PM
  • Joined: 15 Sep 2006
Another suggestion. Why not upload to autohotkey.net?
Imageshack images are not viewable for certain audiences unless registered.
If i've seen further it is by standing on the shoulders of giants

my site | ~shajul | WYSIWYG BBCode Editor

asred
  • Members
  • 26 posts
  • Last active: Nov 24 2012 08:01 PM
  • Joined: 28 Feb 2011

Another suggestion. Why not upload to autohotkey.net?



Good idea again. . . done.

SoggyDog
  • Members
  • 803 posts
  • Last active: Mar 04 2013 06:27 AM
  • Joined: 02 May 2006

...or all subfolder via recursion...

Agreed;
My scripts are neatly divided and sorted into a gazillion sub-folders.
It would almost need to be a tree hierarchy, though, otherwise I'd end up with a single list of tens-of-thousands of scripts/scriptlets.

asred
  • Members
  • 26 posts
  • Last active: Nov 24 2012 08:01 PM
  • Joined: 28 Feb 2011

...or all subfolder via recursion...

Agreed;
My scripts are neatly divided and sorted into a gazillion sub-folders.
It would almost need to be a tree hierarchy, though, otherwise I'd end up with a single list of tens-of-thousands of scripts/scriptlets.



With that being said, I suppose there are two ways to go about enabling the use of sub folders. One is the change the listview to have a column with the script's full path (A_LoopFileFullPath) then change all the buttons to use the full path of the selected script rather than A_WorkingDir (e.g. %A_WorkingDir%\%FileName%). But this would just create a really big list.

The second is to scrap the listview and go straight for the glory of treeview. Check out the ahk user guides example script for treeview it basically does what you desire. All you'd have to do is incorporate buttons and subroutines.

http://www.autohotke...ds/TreeView.htm

sumon
  • Moderators
  • 1317 posts
  • Last active: Dec 05 2016 10:14 PM
  • Joined: 18 May 2010
I also did something like this a while ago, but discontinued it since I wanted to do it differently. If you want to look at it for some example code on how to achieve stuff (for example my way of allowing recursing, and listing multiple pages, etc.), you can check it out at the thread about The Master Script.

asred
  • Members
  • 26 posts
  • Last active: Nov 24 2012 08:01 PM
  • Joined: 28 Feb 2011

I also did something like this a while ago, but discontinued it since I wanted to do it differently. If you want to look at it for some example code on how to achieve stuff (for example my way of allowing recursing, and listing multiple pages, etc.), you can check it out at the thread about The Master Script.


Looks pretty cool. I'll have to investigate your code on setting a script to auto start. Did you ever figure out how to create a dynamic list of running scripts?

sumon
  • Moderators
  • 1317 posts
  • Last active: Dec 05 2016 10:14 PM
  • Joined: 18 May 2010

I also did something like this a while ago, but discontinued it since I wanted to do it differently. If you want to look at it for some example code on how to achieve stuff (for example my way of allowing recursing, and listing multiple pages, etc.), you can check it out at the thread about The Master Script.


Looks pretty cool. I'll have to investigate your code on setting a script to auto start. Did you ever figure out how to create a dynamic list of running scripts?


Nope, didn't think of it. However, I'd be glad to investigate the issue further, for my next applauncher.

asred
  • Members
  • 26 posts
  • Last active: Nov 24 2012 08:01 PM
  • Joined: 28 Feb 2011

Nope, didn't think of it. However, I'd be glad to investigate the issue further, for my next applauncher.


I'll have to keep an eye out for it.

If I end up having time to incorporate the treeview (a earlier suggestion), I'm sure I'll be tempted to dig a little more on the subject myself. I'll post something on your thread if I figure anything out.

asred
  • Members
  • 26 posts
  • Last active: Nov 24 2012 08:01 PM
  • Joined: 28 Feb 2011

If you could pick additional folders to include scripts with and or all subfolder via recursion it would be un-believable. :idea:



Okay, I had a little time to attempt to incorporate the tree view. I have run into an issue. Below is the base code for the treeview (retrieved from the AHK user guide). I am not able to get the "TreeRoot" variable to work with the "A_WorkingDir" so that the treeview starts at the working directory (See line 20). The working directory variable works, as it is displayed in the titlebar, but for some unknown reason the treeview doesn't like it.

Thoughts anyone?




#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases. 
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
DetectHiddenWindows On  ; Allows a script's hidden main window to be detected.
SetTitleMatchMode 2  ; Avoids the need to specify the full path of the file below.

 
; **************************** READ ME ****************************
; RESOURCE: http://www.autohotkey.com/docs/commands/TreeView.htm  < base code was retrieved from the example 
; The following is a working script that is more elaborate than the one near the top of this page.
; It creates and displays a TreeView containing all folders in the all-users Start Menu.  When the
; user selects a folder, its contents are shown in a ListView to the right (like Windows Explorer).
; In addition, a StatusBar control shows information about the currently selected folder.
; **************************** READ ME END ****************************

; **************************** Begin Script ****************************
; The following folder will be the root folder for the TreeView. Note that loading might take a long
; time if an entire drive such as C:\ is specified:
; TreeRoot = %A_WorkingDir% ; <<<< for some reason the A_Working direcotry builtin variable doesn't work to. Full paths do though. 
TreeRoot = %A_StartMenuCommon%   ; <<< the origial variable
TreeViewWidth := 200
;ListViewWidth := A_ScreenWidth - TreeViewWidth - 30

; Allow the user to maximize or drag-resize the window:
Gui +Resize

; Create an ImageList and put some standard system icons into it: Folder icons
ImageListID := IL_Create(5)
Loop 5  ; Below omits the DLL's path so that it works on Windows 9x too:
    IL_Add(ImageListID, "shell32.dll", A_Index)

; Create a TreeView and a ListView side-by-side to behave like Windows Explorer:
Gui, Add, TreeView, vMyTree r20 w%TreeViewWidth% gMyTree ImageList%ImageListID%
Gui, Add, ListView, vMyList r20 w%ListViewWidth% x+10,Name

; Set the ListView's column widths (this is optional):
LV_ModifyCol(1, %CharCount%)  ; Allows room for vertical scrollbar.
LV_ModifyCol(2, %CharCount%) ; Auto-size each column to fit its contents.

; Create a Status Bar to give info about the number of files and their total size:
Gui, Add, StatusBar
SB_SetParts(60, 85)  ; Create three parts in the bar (the third part fills all the remaining width).

; Add folders and their subfolders to the tree. Display the status in case loading takes a long time:
SplashTextOn, 200, 25, TreeView and StatusBar Example, Loading the tree...
AddSubFoldersToTree(TreeRoot)
SplashTextOff

; Display the window and return. The OS will notify the script whenever the user performs an eligible action:
Gui, Show,, %TreeRoot%  ; Display the source directory (TreeRoot) in the title bar.
return

AddSubFoldersToTree(Folder, ParentItemID = 0)
{
    ; This function adds to the TreeView all subfolders in the specified folder.
    ; It also calls itself recursively to gather nested folders to any depth.
    Loop %Folder%\*.*, 2  ; Retrieve all of Folder's sub-folders.
        AddSubFoldersToTree(A_LoopFileFullPath, TV_Add(A_LoopFileName, ParentItemID, "Icon4"))
}

MyTree:  ; This subroutine handles user actions (such as clicking).
if A_GuiEvent <> S  ; i.e. an event other than "select new tree item".
    return  ; Do nothing.
; Otherwise, populate the ListView with the contents of the selected folder.
; First determine the full path of the selected folder:
TV_GetText(SelectedItemText, A_EventInfo)
ParentID := A_EventInfo
Loop  ; Build the full path to the selected folder.
{
    ParentID := TV_GetParent(ParentID)
    if not ParentID  ; No more ancestors.
        break
    TV_GetText(ParentText, ParentID)
    SelectedItemText = %ParentText%\%SelectedItemText%
}
SelectedFullPath = %TreeRoot%\%SelectedItemText%

; Put the files into the ListView:
LV_Delete()  ; Clear all rows.
GuiControl, -Redraw, MyListView  ; Improve performance by disabling redrawing during load.
FileCount = 0  ; Init prior to loop below.
TotalSize = 0
Loop %SelectedFullPath%\*.*  ; For simplicity, this omits folders so that only files are shown in the ListView.
{
    LV_Add("", A_LoopFileName, A_LoopFileTimeModified)
    FileCount += 1
    TotalSize += A_LoopFileSize
}
GuiControl, +Redraw, MyListView

; Update the three parts of the status bar to show info about the currently selected folder:
SB_SetText(FileCount . " files", 1)
SB_SetText(Round(TotalSize / 1024, 1) . " KB", 2)
SB_SetText(SelectedFullPath, 3)
return

GuiSize:  ; Expand/shrink the ListView and TreeView in response to user's resizing of window.
if A_EventInfo = 1  ; The window has been minimized.  No action needed.
    return
; Otherwise, the window has been resized or maximized. Resize the controls to match.
GuiControl, Move, MyTree, % "H" . (A_GuiHeight - 30)  ; -30 for StatusBar and margins.
GuiControl, Move, MyList, % "H" . (A_GuiHeight - 30) . " W" . (A_GuiWidth - TreeViewWidth - 30)
return

GuiClose:  ; Exit the script when the user closes the TreeView's GUI window.
ExitApp


comvox
  • Members
  • 143 posts
  • Last active: Jan 29 2017 06:53 AM
  • Joined: 20 May 2009

I am not able to get the "TreeRoot" variable to work with the "A_WorkingDir" so that the treeview starts at the working directory (See line 20). The working directory variable works, as it is displayed in the titlebar, but for some unknown reason the treeview doesn't like it.


That's odd. It seems to work when I use A_WorkingDir.