AHK Startup (Consolidate AHK Scripts' Tray Icons)

Post your working scripts, libraries and tools
FanaticGuru
Posts: 1207
Joined: 30 Sep 2013, 22:25

AHK Startup (Consolidate AHK Scripts' Tray Icons)

27 Nov 2013, 15:18

AHK Startup

This is my startup script that I put a shortcut to run in my startup folder to load my standard scripts on computer bootup.

It basically Runs a list of scripts.
This list can include a folder which will run all files in that folder and subfolders. Wildcards * and ? can also be used.
Relative path can also be used by using .\ at the beginning of a file path. One dot is the folder this script is located in. Each additional dot steps back one folder.
It also looks for a txt file with the same name as the script and includes the files listed there.
It then creates a tooltip that list all the scripts that it started.
It then removes the tray icon of all the scripts it started leaving only the "AHK Startup" tray icon.
When AHK Startup is exited or stopped all the scripts it started will also be exited and stopped.

All the lines between:
(Join,

)]
Are example paths only to show different syntax and formatting of how paths can be done. These lines must be edited to the path and scripts that the user wants AHK Startup to run.

I use this script for startup but it does not necessarily have to be used that way. It is useful any time you want to run several AHK scripts but only have one tray icon and have all the scripts start and stop together.

You lose the functionality of right mouse clicking on a scripts tray icon as the tray icons for the scripts are removed. So there are no individual script tray icons to click on and stop, pause, suspend, edit, etc. a script but I have another one of my scripts always running that gives me a different way to access those abilities other than right clicking a tray icon.

Hotkey Help - Help Dialog for Currently Running AHK Scripts

Update: Added a custom right click menu to the AHK Startup tray icon to allow access to some individual script controls.

Code: Select all

; AHK Startup
; Fanatic Guru
; 2015 07 30
;
; Startup Script for Startup Folder to Run on Bootup.
;{-----------------------------------------------
; Runs the Scripts Defined in the Files Array
; Removes the Scripts' Tray Icons leaving only AHK Startup
; Creates a ToolTip for the One Tray Icon Showing the Startup Scripts
; If AHK Startup is Exited All Startup Scripts are Exited
;}

; INITIALIZATION - ENVIROMENT
;{-----------------------------------------------
;
#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.
#SingleInstance force  ; Ensures that only the last executed instance of script is running
DetectHiddenWindows, On
;}

; INITIALIZATION - VARIABLES
;{-----------------------------------------------
;
Files := [	; Additional Startup Files and Folders Can Be Added Between the ( Continuations  ) Below
(Join, 
"C:\Users\Guru\Documents\AutoHotkey\Startup\"
"C:\Users\Guru\Documents\AutoHotkey\Compiled Scripts\*.exe"
A_MyDocuments "\AutoHotkey\My Scripts\Hotstring Helper.ahk"
"C:\Users\Guru\Documents\AutoHotkey\My Scripts\Calculator.ahk"
".\Web\Google Search.ahk"
"..\Dictionary.ahk"
"Hotkey Help.ahk"
"MediaMonkey.ahk"
)]
;}

; AUTO-EXECUTE
;{-----------------------------------------------
;
if FileExist(RegExReplace(A_ScriptName,"(.*)\..*","$1.txt")) ; Look for text file with same name as script
	Loop, Read, % RegExReplace(A_ScriptName,"(.*)\..*","$1.txt")
		if A_LoopReadLine
			Files.Insert(A_LoopReadLine)

Scripts := {}
For key, File in Files
{
	RegExMatch(File,"^(\.*)\\",Match), R := StrLen(Match1) ; Look for relative pathing
	if (R=1) 
		File_Exp := A_ScriptDir SubStr(File,R+1)
	else if (R>1)
		File_Exp := SubStr(A_ScriptDir,1,InStr(A_ScriptDir,"\",,0,R-1)) SubStr(File,R+2)
	else
		File_Exp := File
	if RegExMatch(File_Exp,"\\$") ; If File ends in \ assume it is a folder
		Loop, %File_Exp%*.*,,1 ; Get full path of all files in folder and subfolders
			Scripts.Insert(A_LoopFileFullPath)
	else
		if RegExMatch(File_Exp,"\*|\?") ; If File contains wildcard
			Loop, %File_Exp%,,1 ; Get full path of all matching files in folder and subfolders
				Scripts.Insert(A_LoopFileFullPath)
		else
			Scripts.Insert(File_Exp)
}

Startup := {}
for index, Script in Scripts ; Run All the Scripts, Keep Their PID, Keep Info for Tooltip Text
{
	RegExMatch(Script,"([^\\]*)\..*$", Match), Script_Name := Match1
	Run, %Script%,,, pid
	Startup[Script_Name,"PID"] := pid
	Tip_Text .= Script_Name "`n"
}

Sort, Tip_Text ; Create the Tooltip
Tip_Text := TrimAtDelim(Trim(Tip_Text, " `n"))
Menu, Tray, Tip, %Tip_Text% ; Tooltip is limited to first 127 characters

; Shortcut Trick to Get Windows 7 to Update Hidden Tray (Uncomment if needed)
; Send {LWin Down}b{LWin Up}{Enter}{Escape} 

Sleep 500
gosub MenuBuild

OnExit, ExitSub ; Gosub to ExitSub when this Script Exits

Tray_Icons := {}
Loop, 10	; Try To Remove Over Time Because Icons May Lag During Bootup
{
	Tray_Icons := TrayIcon_GetInfo()
	for index, Script in Startup
		for index2, Icon in Tray_Icons
			If (Script.Pid = Icon.Pid)
				TrayIcon_Remove(Icon.hWnd, Icon.uID)
	Sleep A_index**2 * 200
}
;
;}-----------------------------------------------
; END OF AUTO-EXECUTE

; HOTKEYS
;{-----------------------------------------------
;
~#^!Escape::ExitApp ; <-- Terminate Script
;}

; SUBROUTINES
;{-----------------------------------------------
;
ExitSub: ; Stop All the Startup Scripts (Called When this Scripts Exits)
	for index, Script in Startup
		PostMessage, 0x111, 65307,,,% "ahk_pid " Script.PID	; 65307 or 65405
ExitApp
;}

; SUBROUTINES - GUI
;{-----------------------------------------------
;
MenuBuild:	
	for index, Script in Startup
	{	
		PID := Script.PID
		Menu, SubMenu_%PID%, Add, View Lines, ScriptCommand
		Menu, SubMenu_%PID%, Add, View Variables, ScriptCommand
		Menu, SubMenu_%PID%, Add, View Hotkeys, ScriptCommand
		Menu, SubMenu_%PID%, Add, View Key History, ScriptCommand
		Menu, SubMenu_%PID%, Add
		Menu, SubMenu_%PID%, Add, &Open, ScriptCommand
		Menu, SubMenu_%PID%, Add, &Edit, ScriptCommand
		Menu, SubMenu_%PID%, Add, &Exit, ScriptCommand
	}

	for index, Script in Startup
	{	
		PID := Script.PID
		Menu, Tray, Add, %index%, :SubMenu_%PID%
	}

	Menu, Tray, NoStandard
	Menu, Tray, Add
	Menu, Tray, Standard
return

ScriptCommand:
	Cmd_Open    = 65300
	Cmd_Edit    = 65401
	Cmd_Exit    = 65405
	Cmd_ViewLines      = 65406
	Cmd_ViewVariables  = 65407
	Cmd_ViewHotkeys    = 65408
	Cmd_ViewKeyHistory = 65409
	PID := RegExReplace(A_ThisMenu,"SubMenu_(\d*)$","$1")
    cmd := RegExReplace(A_ThisMenuItem, "[^\w#@$?\[\]]") ; strip invalid chars
    cmd := Cmd_%cmd%
	PostMessage, 0x111, %cmd%,,,ahk_pid %PID%
	if (cmd = 65405)
	{
		for index, Script in Startup
			if (Script.PID = PID)
			{
				Startup.Remove(index)
				break
			}
		Menu, Tray, Delete, %index%
		Tip_Text := RegExReplace(Tip_Text,index "\v?")
		Menu, Tray, Tip, %Tip_Text%
	}
return
;}

; FUNCTIONS
;{-----------------------------------------------
;
TrimAtDelim(String,Length:=124,Delim:="`n",Tail:="...")
{
	if (StrLen(String)>Length)
		RegExMatch(SubStr(String, 1, Length+1),"(.*)" Delim, Match), Result := Match Tail
	else
		Result := String
	return Result
}
;}



; FUNCTIONS - LIBRARY
;{-----------------------------------------------
;

TrayIcon_GetInfo(sExeName := "")
{
	DetectHiddenWindows, % (Setting_A_DetectHiddenWindows := A_DetectHiddenWindows) ? "On" :
	oTrayIcon_GetInfo := {}
	For key, sTray in ["NotifyIconOverflowWindow", "Shell_TrayWnd"]
	{
		idxTB := TrayIcon_GetTrayBar()
		WinGet, pidTaskbar, PID, ahk_class %sTray%
		
		hProc := DllCall("OpenProcess", UInt, 0x38, Int, 0, UInt, pidTaskbar)
		pRB   := DllCall("VirtualAllocEx", Ptr, hProc, Ptr, 0, UPtr, 20, UInt, 0x1000, UInt, 0x4)

		if (SubStr(A_OSVersion,1,2)=10)
			SendMessage, 0x418, 0, 0, ToolbarWindow32%key%, ahk_class %sTray%   ; TB_BUTTONCOUNT
		else	
			SendMessage, 0x418, 0, 0, ToolbarWindow32%idxTB%, ahk_class %sTray%   ; TB_BUTTONCOUNT
		
		szBtn := VarSetCapacity(btn, (A_Is64bitOS ? 32 : 20), 0)
		szNfo := VarSetCapacity(nfo, (A_Is64bitOS ? 32 : 24), 0)
		szTip := VarSetCapacity(tip, 128 * 2, 0)
		
		Loop, %ErrorLevel%
		{
			if (SubStr(A_OSVersion,1,2)=10)
				SendMessage, 0x417, A_Index - 1, pRB, ToolbarWindow32%key%, ahk_class %sTray%   ; TB_GETBUTTON
			else
				SendMessage, 0x417, A_Index - 1, pRB, ToolbarWindow32%idxTB%, ahk_class %sTray%   ; TB_GETBUTTON
			DllCall("ReadProcessMemory", Ptr, hProc, Ptr, pRB, Ptr, &btn, UPtr, szBtn, UPtr, 0)

			iBitmap := NumGet(btn, 0, "Int")
			IDcmd   := NumGet(btn, 4, "Int")
			statyle := NumGet(btn, 8)
			dwData  := NumGet(btn, (A_Is64bitOS ? 16 : 12))
			iString := NumGet(btn, (A_Is64bitOS ? 24 : 16), "Ptr")

			DllCall("ReadProcessMemory", Ptr, hProc, Ptr, dwData, Ptr, &nfo, UPtr, szNfo, UPtr, 0)

			hWnd  := NumGet(nfo, 0, "Ptr")
			uID   := NumGet(nfo, (A_Is64bitOS ? 8 : 4), "UInt")
			msgID := NumGet(nfo, (A_Is64bitOS ? 12 : 8))
			hIcon := NumGet(nfo, (A_Is64bitOS ? 24 : 20), "Ptr")

			WinGet, pID, PID, ahk_id %hWnd%
			WinGet, sProcess, ProcessName, ahk_id %hWnd%
			WinGetClass, sClass, ahk_id %hWnd%

			If !sExeName || (sExeName = sProcess) || (sExeName = pID)
			{
				DllCall("ReadProcessMemory", Ptr, hProc, Ptr, iString, Ptr, &tip, UPtr, szTip, UPtr, 0)
				Index := (oTrayIcon_GetInfo.MaxIndex()>0 ? oTrayIcon_GetInfo.MaxIndex()+1 : 1)
				oTrayIcon_GetInfo[Index,"idx"]     := A_Index - 1
				oTrayIcon_GetInfo[Index,"IDcmd"]   := IDcmd
				oTrayIcon_GetInfo[Index,"pID"]     := pID
				oTrayIcon_GetInfo[Index,"uID"]     := uID
				oTrayIcon_GetInfo[Index,"msgID"]   := msgID
				oTrayIcon_GetInfo[Index,"hIcon"]   := hIcon
				oTrayIcon_GetInfo[Index,"hWnd"]    := hWnd
				oTrayIcon_GetInfo[Index,"Class"]   := sClass
				oTrayIcon_GetInfo[Index,"Process"] := sProcess
				oTrayIcon_GetInfo[Index,"Tooltip"] := StrGet(&tip, "UTF-16")
				oTrayIcon_GetInfo[Index,"Tray"]    := sTray
			}
		}
		DllCall("VirtualFreeEx", Ptr, hProc, Ptr, pProc, UPtr, 0, Uint, 0x8000)
		DllCall("CloseHandle", Ptr, hProc)
	}
	DetectHiddenWindows, %Setting_A_DetectHiddenWindows%
	Return oTrayIcon_GetInfo
}

TrayIcon_GetTrayBar()
{
	DetectHiddenWindows, % (Setting_A_DetectHiddenWindows := A_DetectHiddenWindows) ? "On" :
	WinGet, ControlList, ControlList, ahk_class Shell_TrayWnd
	RegExMatch(ControlList, "(?<=ToolbarWindow32)\d+(?!.*ToolbarWindow32)", nTB)
	Loop, %nTB%
	{
		ControlGet, hWnd, hWnd,, ToolbarWindow32%A_Index%, ahk_class Shell_TrayWnd
		hParent := DllCall( "GetParent", Ptr, hWnd )
		WinGetClass, sClass, ahk_id %hParent%
		If (sClass <> "SysPager")
			Continue
		idxTB := A_Index
		Break
	}
	DetectHiddenWindows, %Setting_A_DetectHiddenWindows%
	Return  idxTB
}

TrayIcon_Remove(hWnd, uID)
{
		NumPut(VarSetCapacity(NID,(A_IsUnicode ? 2 : 1) * 384 + A_PtrSize * 5 + 40,0), NID)
		NumPut(hWnd , NID, (A_PtrSize == 4 ? 4 : 8 ))
		NumPut(uID  , NID, (A_PtrSize == 4 ? 8  : 16 ))
		Return DllCall("shell32\Shell_NotifyIcon", "Uint", 0x2, "Uint", &NID)
}

;}
This script uses TrayIcon functions created by others that I have updated to be more functional for my needs. These functions are probably useful for others and the original links to them are broken and the old functions probably would not work even if the links were live as they were written for AutoHotkey Basic.

I #include [Library] TrayIcon.ahk in my script as I use these functions in other scripts but have manually placed the three required function at the end of AutoHotkey Startup above for convenience.

Here is a link to my version of the entire updated TrayIcon Library:

Updated TrayIcon Library

FG
Last edited by FanaticGuru on 14 Apr 2016, 15:37, edited 22 times in total.
Hotkey Help - Help Dialog for Currently Running AHK Scripts

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon

[Function] Timer - Create and Manage Timers
User avatar
Chef
Posts: 50
Joined: 14 Nov 2013, 13:01

Re: AutoHotkey Startup (Consolidate AHK Scripts' Tray Icons)

27 Nov 2013, 15:47

Nice FanaticGuru, this is going to be very useful :D
FanaticGuru
Posts: 1207
Joined: 30 Sep 2013, 22:25

Re: AutoHotkey Startup (Consolidate AHK Scripts' Tray Icons)

10 Dec 2013, 17:00

Updated Script on First Page

Change Log:
Streamlined code by combining TrayIconsOverflow function into TrayIcons function so that one function call gets the information on all the Icons regardless of location.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon

[Function] Timer - Create and Manage Timers
FanaticGuru
Posts: 1207
Joined: 30 Sep 2013, 22:25

Re: AutoHotkey Startup (Consolidate AHK Scripts' Tray Icons)

16 Jan 2014, 17:56

Updated Script on First Page

Change Log:
Updated to work with Unicode 64 bit.
Included only the required 3 TrayIcon functions in the script.
Provided Link to entire updated TrayIcon Library.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon

[Function] Timer - Create and Manage Timers
AHKxx
Posts: 54
Joined: 26 Feb 2014, 01:37

Re: AutoHotkey Startup (Consolidate AHK Scripts' Tray Icons)

13 Mar 2014, 12:34

Thank you for this. Makes life much easier.

I initially was having a problem where this one script was not getting loaded. It turned out to be a problem with the scripts name: explorer paths.ahk. When I changed it to expxlorerpaths.ahk, it worked fine. It wasn't the space. Something about one or both the words was making it not happy. But this did give me an idea for how the script might be improved.

Would it be possible to, instead of having to enter the file names to be loaded into the script directly, have the script look for a specified folder, one level down, and then just load every script it finds? That way you could easily move scripts in and out of that folder, and not have to be concerned with their names. It would function just like the Windows Startup folder does with shortcuts. It would also make it possible to use it as an executable.

Thanks again. This and the Hotkey Help script are both incredibly useful, and compliment each other beautifully.
ozzii
Posts: 312
Joined: 30 Oct 2013, 06:04

Re: AutoHotkey Startup (Consolidate AHK Scripts' Tray Icons)

14 Mar 2014, 07:59

Would it be possible to, instead of having to enter the file names to be loaded into the script directly, have the script look for a specified folder, one level down, and then just load every script it finds? That way you could easily move scripts in and out of that folder, and not have to be concerned with their names. It would function just like the Windows Startup folder does with shortcuts. It would also make it possible to use it as an executable.
This is a great idea..
A sub folder 'Startup' where the scripts/lnk files can be found.
This could be really handful.
Guest10
Posts: 578
Joined: 01 Oct 2013, 02:50

Re: AutoHotkey Startup (Consolidate AHK Scripts' Tray Icons)

14 Mar 2014, 08:42

thanks about to test could you please explain what ~#^!Escape means?
Guest10
Posts: 578
Joined: 01 Oct 2013, 02:50

Re: AutoHotkey Startup (Consolidate AHK Scripts' Tray Icons)

14 Mar 2014, 09:21

what if these scripts are scattered all over are not all centrally placed in script folder? how would you modify the script toward this case?
FanaticGuru
Posts: 1207
Joined: 30 Sep 2013, 22:25

Re: AutoHotkey Startup (Consolidate AHK Scripts' Tray Icons)

14 Mar 2014, 12:34

thanks about to test could you please explain what ~#^!Escape means?
~#^!Escape Is Crtl+Win+Alt+Escape which will terminate the script. ~ makes it where the keys can activating more than one script at a time.

I put this in all my scripts so that if I push that key combination all my scripts will be terminated. It is kind of a fail safe to terminate all my scripts.

You can leave this line out it has nothing to do with how this script works.

FG
Last edited by FanaticGuru on 14 Mar 2014, 12:57, edited 1 time in total.
Hotkey Help - Help Dialog for Currently Running AHK Scripts

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon

[Function] Timer - Create and Manage Timers
FanaticGuru
Posts: 1207
Joined: 30 Sep 2013, 22:25

Re: AutoHotkey Startup (Consolidate AHK Scripts' Tray Icons)

14 Mar 2014, 12:56

what if these scripts are scattered all over are not all centrally placed in script folder? how would you modify the script toward this case?
You can put the full path instead of just the file name in the appropriate place in the script.
"C:\Users\Guru\Documents\AutoHotkey\My Scripts\Hotstring Helper.ahk"

The only problem with that is then the entire path gets added to the tooltip that is created.

That is pretty easy to fix though.

I am toying with adding an option to look in a folder like suggested and maybe looking in a text file for a list of script names also. The coding part I can do but I am not sure of the logistics of how it should work. I am trying to devise a way to have it so that you would not have to edit the script to define the folder location but that means there has to be some type of ini or additional file that holds these settings which I am not too keen on.

I will play around with it and post a more versatile script.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon

[Function] Timer - Create and Manage Timers
Guest10
Posts: 578
Joined: 01 Oct 2013, 02:50

Re: AutoHotkey Startup (Consolidate AHK Scripts' Tray Icons)

14 Mar 2014, 21:09

thanks that would be great! :D
FanaticGuru
Posts: 1207
Joined: 30 Sep 2013, 22:25

Re: AutoHotkey Startup (Consolidate AHK Scripts' Tray Icons)

19 Mar 2014, 12:23

Updated Script on First Page

Change Log (2014-03-19):
Changed the list of files to run to accept full paths as well as folders.
Folders names must end with "\"
Changed the list of files to also accept wildcards * and ?
Script will look for a text file with the same name as the script and use that to get list of file names (ie. Startup - Autohotkey.txt) Do not include "" in the text file.

Code: Select all

C:\Users\Guru\Documents\AutoHotkey\Startup\
C:\Users\Guru\Documents\AutoHotkey\Compiled Scripts\*.exe
You could probably use stuff like %A_MyDocuments% in the txt but I have not tested it.

The script will combine the files defined in the script and the files in the txt.

If you don't want any files defined in the script just delete all of them like this

Code: Select all

Files := [	; Additional Startup Files and Folders Can Be Added Between the ( Continuations  ) Below
(Join, 
)]
You could get rid of the continuation entirely and just use Files := {} but leaving the continuation is good in case you ever want to add any back in the script itself.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon

[Function] Timer - Create and Manage Timers
Guest10
Posts: 578
Joined: 01 Oct 2013, 02:50

Re: AutoHotkey Startup (Consolidate AHK Scripts' Tray Icons)

19 Mar 2014, 16:24

thanks for the update! :) it goes for my next restart since my computer is running non-stop for weeks... :lol:
Guest10
Posts: 578
Joined: 01 Oct 2013, 02:50

Re: AutoHotkey Startup (Consolidate AHK Scripts' Tray Icons)

19 Mar 2014, 16:39

sorry i may be asking a bit too much but it would be ideal if a user could "selectively" add or remove scripts from the Startup menu or tray icon so that it won't an all or nothing deal and a user could selectively load or close scripts through Startup tray icon or something similar (a panel, a menu, etc.).
AHKxx
Posts: 54
Joined: 26 Feb 2014, 01:37

Re: AutoHotkey Startup (Consolidate AHK Scripts' Tray Icons)

19 Mar 2014, 16:50

@Guest10 If I understand what you're asking, it's possible to do that if you also use FG's Hotkey Help script (see his sig.)

It's useful on its own but makes a really great pairing with the Startup script (having them both running, its easy to forget that they're actually 2 diff scripts!), and it lets you selectively pause, stop, suspend, edit, reload, and open script. There's a menu on top... and if you open the script and look for where the menu is generated, and yo add an &mpersand in front of each menu item, you get shortcut keys. Very cool.

I haven't been able to get the new Startup to work without throwing one error or another. Not sure if it's something I'm doing or not doing or what. Will post later with more deets if I can't figure it out.

@FG Thank you for these 2 fantastically helpful scripts!
sttrebo
Posts: 65
Joined: 27 Jan 2014, 12:31

Re: AutoHotkey Startup (Consolidate AHK Scripts' Tray Icons)

19 Mar 2014, 17:06

excellent script, thanks for this.

one question though: instead of using absolute paths to the scripts that I have loaded, I use relative paths (makes it easier for using this on multiple computers). what I mean is this:
absolute path: c:\user\myname\dropbox\ahk\autocomplete\autocomplete.ahk
relative path (assuming that autohotkey startup.ahk is in c:\user\myname\dropbox\ahk): .\autocomplete\autocomplete.ahk

but this relative style of pathing doesn't seem to work with your script. is this something you could look at?

thanks
Guest10
Posts: 578
Joined: 01 Oct 2013, 02:50

Re: AutoHotkey Startup (Consolidate AHK Scripts' Tray Icons)

19 Mar 2014, 19:02

thanks i didn't know Hotkey Help existed. i did a lil mod to tighten up spacing in Hotkey Help - Pick Settings: yxxx:

Code: Select all

; Create Setting Gui
Gui, Set:Font, s10
Gui, Set:Add, Text, x120 y10 w200 h20 , Hotkey Help - Pick Settings
Gui, Set:Add, Text, x30 y40 w390 h2 0x7
Gui, Set:Add, CheckBox, x60 y50 w380 h30 vSet_ShowBlank, Show Files With No Hotkeys
Gui, Set:Add, CheckBox, x60 y80 w380 h30 vSet_ShowBlankInclude, Show Include Files With No Hotkeys
Gui, Set:Add, CheckBox, x60 y110 w380 h30 vSet_ShowExe, Show EXE Files (Help Comments Do Not Exist in EXE)
Gui, Set:Add, CheckBox, x60 y140 w380 h30 vSet_AhkExe, Scan AHK File with Same Name as Running EXE
Gui, Set:Add, CheckBox, x60 y170 w380 h30 vSet_AhkTxt, Scan Text Files with Same Name as Running Script
Gui, Set:Add, CheckBox, x60 y200 w380 h30 vSet_AhkTxtOver, Text File Help will Overwrite Duplicate Help
Gui, Set:Add, CheckBox, x60 y230 w380 h30 vSet_ShowHotkey, Show Created with Hotkey Command
Gui, Set:Add, CheckBox, x60 y260 w380 h30 vSet_VarHotkey, Attempt to Resolve Variables in Dynamic Hotkeys
Gui, Set:Add, CheckBox, x60 y290 w380 h30 vSet_FlagHotkey, Flag Hotkeys created with the Hotkey Command with <HK>
Gui, Set:Add, CheckBox, x60 y320 w380 h30 vSet_SortInfo, Sort by Hotkey Description (Otherwise by Hotkey Name)
Gui, Set:Add, CheckBox, x60 y350 w180 h30 vSet_CapHotkey, Hotkey Capitalization
Gui, Set:Add, Radio, x240 y380 w80 h30 vSet_CapHotkey_Radio, Title
Gui, Set:Add, Radio, x320 y380 w120 h30, UPPER
Gui, Set:Add, CheckBox, x60 y410 w380 h30 vSet_ShowString, Show Hotstrings
Gui, Set:Add, CheckBox, x60 y440 w380 h30 vSet_HideFold, Hide Fold Start  `;`{  from Help Comment
Gui, Set:Add, CheckBox, x60 y470 w380 h30 vSet_IniSet, Use INI File to Save Settings
Gui, Set:Add, CheckBox, x60 y500 w380 h30 vSet_IniExcluded, Use INI File to Save Excluded Files and Hotkeys
Gui, Set:Add, ComboBox, x60 y530 w60 h30 R5 Choose1 vSet_Hotkey_Mod_Delimiter, "%Set_Hotkey_Mod_Delimiter%"|"+"|"-"|" + "|" - "
Gui, Set:Add, Text, x130 y560 w250 h30, Delimiter to Separate Hotkey Modifiers
Gui, Set:Add, Button, Default x60 y580 w330 h30, Finished
@Guest10 If I understand what you're asking, it's possible to do that if you also use FG's Hotkey Help script (see his sig.)

It's useful on its own but makes a really great pairing with the Startup script (having them both running, its easy to forget that they're actually 2 diff scripts!), and it lets you selectively pause, stop, suspend, edit, reload, and open script. There's a menu on top... and if you open the script and look for where the menu is generated, and yo add an &mpersand in front of each menu item, you get shortcut keys. Very cool.

I haven't been able to get the new Startup to work without throwing one error or another. Not sure if it's something I'm doing or not doing or what. Will post later with more deets if I can't figure it out.

@FG Thank you for these 2 fantastically helpful scripts!
FanaticGuru
Posts: 1207
Joined: 30 Sep 2013, 22:25

Re: AutoHotkey Startup (Consolidate AHK Scripts' Tray Icons)

20 Mar 2014, 00:48

excellent script, thanks for this.

one question though: instead of using absolute paths to the scripts that I have loaded, I use relative paths (makes it easier for using this on multiple computers). what I mean is this:
absolute path: c:\user\myname\dropbox\ahk\autocomplete\autocomplete.ahk
relative path (assuming that autohotkey startup.ahk is in c:\user\myname\dropbox\ahk): .\autocomplete\autocomplete.ahk

but this relative style of pathing doesn't seem to work with your script. is this something you could look at?

thanks
A_ScriptDir "\autocomplete\autocomplete.ahk" would allow relative pathing.
A_ScriptDir is a built-in variable that contains the full path of the directory where the current script is located.

I will see about adding the ability to use .\ to make it easier though and possibly ..\ to step back a folder.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon

[Function] Timer - Create and Manage Timers
ozzii
Posts: 312
Joined: 30 Oct 2013, 06:04

Re: AutoHotkey Startup (Consolidate AHK Scripts' Tray Icons)

20 Mar 2014, 04:49

Hi FanaticGuru,
Thanks for this handful script.
I have a question:

I've put this:

Code: Select all

(Join, 
A_ScriptDir "\Startup\"
)]
I have a message Startup.ahk does not exist. Create it now ?
How come ?
FanaticGuru
Posts: 1207
Joined: 30 Sep 2013, 22:25

Re: AutoHotkey Startup (Consolidate AHK Scripts' Tray Icons)

20 Mar 2014, 15:31

Hi FanaticGuru,
Thanks for this handful script.
I have a question:

I've put this:

Code: Select all

(Join, 
A_ScriptDir "\Startup\"
)]
I have a message Startup.ahk does not exist. Create it now ?
How come ?
I don't know. This works for me.

The message you are getting I believe is when you attempt to use the Run command to run a script that does not exist.

Below is my directory structure for testing your problem.

Code: Select all

C:\Users\Guru\Documents\AutoHotkey\My Scripts\Startup - AutoHotkey.ahk
C:\Users\Guru\Documents\AutoHotkey\My Scripts\Startup\Startup.ahk
"Startup - AutoHotkey.ahk" is this script and I have a shortcut in my Windows Startup folder to run it on bootup. Must be a shortcut and not the actually script or A_ScriptDir will be looking in the Windows Startup folder which is probably not what you want.

A_ScriptDir gets expanded to C:\Users\Guru\Documents\AutoHotkey\My Scripts which causes the folder to look in to be C:\Users\Guru\Documents\AutoHotkey\My Scripts\Startup\ where it finds Startup.ahk which then gets Run.

I have a function that lets me look at array contents from the String Things library.

Code: Select all

st_printArr(array, depth=5, indentLevel="")
{
   for k,v in Array
   {
      list.= indentLevel "[" k "]"
      if (IsObject(v) && depth>1)
         list.="`n" st_printArr(v, depth-1, indentLevel . "    ")
      Else
         list.=" => " v
      list.="`n"
   }
   return rtrim(list)
}
If you put that function at the end of the script then you can put this at places in the script to make sure the array Files and Scripts contain the expected information.

Code: Select all

MsgBox % ST_printarr(Files)
MsgBox % ST_printarr(Scripts)
Maybe that will help you sort out the problem. There could be problem with my script or A_ScriptDir does not contain what you expect. I also believe you are not running a standard American English setup but I don't see right off how that could have anything to do with the problem. Does your A_ScriptDir contain any "weird" characters?

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon

[Function] Timer - Create and Manage Timers

Return to “Scripts and Functions”

Who is online

Users browsing this forum: cocobanana and 47 guests