This directory contains graphical user interface (GUI) launchers for managing and running multiple AutoHotkey scripts from a centralized location.
Purpose: Main script launcher with tabbed interface
Features:
- Tabbed interface for organizing scripts
- Quick launch buttons for common scripts
- Process monitoring (shows if scripts are running)
- Kill script functionality
- System tray integration
Usage:
# Run the launcher
GUI.ahk
# Click buttons to start/stop scripts
# Right-click tray icon for quick accessCustomization:
; Add your own buttons to the GUI
; Edit the tabs and button definitions in the scriptPurpose: Window Management GUI controls
Features:
- Visual controls for window operations
- Borderless fullscreen toggle
- Window positioning presets
- Always-on-top toggle
- Monitor configuration display
Usage:
# Run the window manager
WM.ahk
# Use GUI buttons for window operations
# Select target window or use "Active Window"Functions:
- Toggle borderless fullscreen
- Snap windows to screen edges
- Set windows always on top
- Monitor management
Purpose: Shared framework and utilities for GUI scripts
Description: This is a library file that provides common functionality for GUI applications. It is not meant to be run directly.
Contains:
- Shared GUI styling functions
- Common button handlers
- Process management utilities
- Configuration loading/saving
Usage:
; Include in other GUI scripts
#Include A_ScriptDir "\GUI_Shared.ahk"
; Use shared functions
CreateStyledButton("Launch", LaunchHandler)-
Modern GUI Design
- Clean, organized layout
- Consistent styling
- Responsive controls
-
Process Management
- Track running scripts by PID
- Show running status
- Proper cleanup on exit
-
Error Handling
- User-friendly error messages
- Validation of inputs
- Graceful failure handling
-
System Tray Integration
- Minimize to tray
- Tray menu for quick access
- Status indicators
Example: Add a new script button to GUI.ahk
; 1. Define your script path
myScriptPath := A_ScriptDir "\..\Other\MyScript.ahk"
; 2. Add button to GUI
myGui.Add("Button", "w200", "Launch My Script").OnEvent("Click", LaunchMyScript)
; 3. Add launch handler
LaunchMyScript(*) {
global myScriptPID
if WinExist("ahk_pid " myScriptPID) {
MsgBox("My Script is already running!")
return
}
Run(myScriptPath, , , &myScriptPID)
}
; 4. Add close button if needed
myGui.Add("Button", "w200", "Close My Script").OnEvent("Click", CloseMyScript)
CloseMyScript(*) {
global myScriptPID
if WinExist("ahk_pid " myScriptPID) {
WinClose("ahk_pid " myScriptPID)
myScriptPID := 0
}
}; Add a new tab category
myGui.Add("Tab3", "w600", ["Gaming", "Utilities", "Custom"])
; Select the new tab
myGui["Tab"].Choose(3)
; Add controls to the custom tab
myGui.Add("Text", , "Custom Scripts")
myGui.Add("Button", "w200", "Custom Action").OnEvent("Click", CustomHandler)
CustomHandler(*) {
MsgBox("Custom button clicked!")
}; Modify GUI properties
myGui := Gui("+AlwaysOnTop -MinimizeBox", "My Launcher")
myGui.BackColor := "0x2B2B2B" ; Dark background
myGui.SetFont("s10 cWhite", "Segoe UI")
; Custom button styling
myButton := myGui.Add("Button", "w200 h40")
myButton.SetFont("s11 bold", "Arial")Template:
; =============================================================================
; Custom GUI Launcher
; =============================================================================
#Requires AutoHotkey v2.0
#SingleInstance Force
SendMode "Input"
SetWorkingDir A_ScriptDir
#Include A_ScriptDir "\GUI_Shared.ahk" ; Optional: use shared functions
#Include A_ScriptDir "\..\..\Lib\v2\AHK_Common.ahk"
InitScript(false, false)
; Global variables for process tracking
global scriptPID := 0
; Create GUI
myGui := Gui("+AlwaysOnTop", "My Launcher")
myGui.OnEvent("Close", GuiClose)
; Add controls
myGui.Add("Text", , "Select an action:")
myGui.Add("Button", "w200", "Launch Script").OnEvent("Click", LaunchScript)
myGui.Add("Button", "w200", "Close Script").OnEvent("Click", CloseScript)
myGui.Add("Button", "w200", "Exit Launcher").OnEvent("Click", GuiClose)
; Show GUI
myGui.Show()
return
; Event handlers
LaunchScript(*) {
global scriptPID
scriptPath := A_ScriptDir "\..\MyScript.ahk"
if WinExist("ahk_pid " scriptPID) {
MsgBox("Script already running!")
return
}
try {
Run(scriptPath, , , &scriptPID)
MsgBox("Script launched!")
} catch as e {
MsgBox("Failed to launch: " e.Message)
}
}
CloseScript(*) {
global scriptPID
if WinExist("ahk_pid " scriptPID) {
WinClose("ahk_pid " scriptPID)
scriptPID := 0
MsgBox("Script closed!")
} else {
MsgBox("Script is not running!")
}
}
GuiClose(*) {
ExitApp
}- Track PIDs: Always store process IDs for launched scripts
- Check if running: Verify script isn't already running before launching
- Proper cleanup: Close launched scripts when GUI exits
- Error handling: Use try/catch for file operations
- User feedback: Provide clear status messages
- Consistent styling: Follow existing GUI design patterns
Test checklist:
- All buttons launch correct scripts
- Scripts don't launch multiple times
- Close buttons properly terminate scripts
- GUI closes cleanly (no orphaned processes)
- Error messages are clear and helpful
- GUI appearance is consistent
- Works with and without admin privileges
Possible causes:
- Incorrect script path
- Script doesn't exist
- Missing AutoHotkey installation
- Insufficient permissions
Solutions:
; Debug script path
MsgBox("Script path: " scriptPath)
MsgBox("File exists: " FileExist(scriptPath))
; Use absolute paths
scriptPath := A_ScriptDir "\..\MyScript.ahk"
; Check for errors
try {
Run(scriptPath, , , &scriptPID)
} catch as e {
MsgBox("Error: " e.Message "`nFile: " e.File "`nLine: " e.Line)
}Problem: Script launches multiple times when button clicked repeatedly
Solution:
; Check if already running
if WinExist("ahk_pid " scriptPID) {
MsgBox("Already running!")
return
}
; Alternative: Disable button while launching
myButton.Enabled := false
Run(scriptPath, , , &scriptPID)
Sleep(500)
myButton.Enabled := trueProblem: Scripts keep running after GUI closes
Solution:
; Add cleanup in OnEvent("Close")
GuiClose(*) {
; Close all tracked processes
if WinExist("ahk_pid " script1PID)
WinClose("ahk_pid " script1PID)
if WinExist("ahk_pid " script2PID)
WinClose("ahk_pid " script2PID)
ExitApp
}#Requires AutoHotkey v2.0
#SingleInstance Force
global pid := 0
myGui := Gui(, "Simple Launcher")
myGui.Add("Button", "w200", "Start Script").OnEvent("Click", (*) => Run("script.ahk", , , &pid))
myGui.Add("Button", "w200", "Stop Script").OnEvent("Click", (*) => WinClose("ahk_pid " pid))
myGui.Show()#Requires AutoHotkey v2.0
#SingleInstance Force
global pid := 0
global statusText := ""
myGui := Gui(, "Status Launcher")
statusText := myGui.Add("Text", "w200", "Status: Not running")
myGui.Add("Button", "w200", "Launch").OnEvent("Click", Launch)
; Update status periodically
SetTimer(UpdateStatus, 1000)
Launch(*) {
global pid
Run("script.ahk", , , &pid)
}
UpdateStatus() {
global statusText, pid
if WinExist("ahk_pid " pid)
statusText.Value := "Status: Running (PID: " pid ")"
else
statusText.Value := "Status: Not running"
}
myGui.Show()- AutoHotkey v2 GUI Documentation
- ahk/README.md - Parent directory documentation
- CLAUDE.md - Developer guide
When adding new GUI scripts:
- Follow the established design patterns
- Use consistent button sizes and spacing
- Include proper error handling
- Test all button functions
- Document hotkeys and features
- Update this README
See CONTRIBUTING.md for detailed guidelines.
Last Updated: 2025-12-26