Mithat, Thanks for posting this. It is a very interesting program. Makes a great script organizer. Very clean and accessable interface that is easy to configure and maintain.
I wanted to limit the number of tray Icons that are showing with multiple ahk scripts running, but still have an indication of what scripts were active. I came up with the idea to use a checkmark by the menu item to show the shortcut script selections. It will also close a running script if the shortcut 'checked item' is selected. I add the
#NoTrayIcon directive in my script files to hide the tray icons. In the example code I separated Notepad in the list to isolate it from the script shortcuts. A line is added to open notepad that does not use a shortcut file.
If you use a startup shortcut to first start any scripts you want active then start Traycut (example code) it will show the checks by any already running scripts in the shortcut list.
Example of modified script which checks menu list items, and will open or close the scripts. Run from within the Traycut Directory.
Code:
;
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: Mithat Konar
;
; Script Function:
; Provides system tray access to shortcuts placed in the "shortcuts" folder.
; 28 December 2006 22:18:39
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
#Persistent ; Keep the script permanently running
#SingleInstance off ; Allow multiple instances
DetectHiddenWindows On ; Allows a script's hidden main window to be detected.
; constants
kProgramName = Traycut ; name of this script/program
kProgramVersion = 0.1 ; version number/name of this script/program
kTrayIcon = %A_ScriptDir%\rsc\trayico.ico ; path to icon that will be used in tray
kShortcutDir = %A_ScriptDir%\shortcuts ; path to the shortcuts dir
kShortcutExt = lnk ; extension of file type (typically a shortcut) to be processed by this script
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Let's get started...
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SetWorkingDir, %kShortcutDir% ; set the working dir to the shortcuts dir
Menu, Tray, Icon, %kTrayIcon%
Menu, Tray, Tip, right-click to select shortcut
Menu, Tray, Add, About..., About
Menu, Tray, Default, About...
Menu, Tray, Add, Exit, Quit
Menu, Tray, Add
Menu, Tray, Add, New Notepad, RunNotepad
Menu, Tray, NoStandard
Loop, %A_WorkingDir%\*.%kShortcutExt%,, ; for each shortcut in the directory, add a menu item for it
{
SplitPath, A_LoopFileName, , , , menuName, ; remove extension
Menu, Tray, Add, %menuName%, RunThisMenuItem
FileGetShortcut, %menuName%.%kShortcutExt%, OutTarget
IfWinExist, %OutTarget%
menu, tray, ToggleCheck, %menuName%}
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Subroutines
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
About:
; Displays an About box.
MsgBox, 8192, About %kProgramName%, %kProgramName% v%kProgramVersion%`n`n© 2007 Mithat Konar ; Task modal
return
Quit:
; Does the obvious
ExitApp
return
RunNotepad:
; Runs Notepad
Run, Notepad.exe
return
RunThisMenuItem:
; Runs the shortcut corresponding to the last selected tray menu item
menuName = % A_ThisMenuItem
FileGetShortcut, %menuName%.%kShortcutExt%, OutTarget
IfWinExist, %OutTarget%
WinClose
else
Run %menuName%.%kShortcutExt%
menu, tray, ToggleCheck, %menuName%
Return