Created
September 25, 2022 16:05
-
-
Save mark05e/7878e2200421979230afdc9009e6e5db to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; | |
; +-----------------------------------------------------------------------------+ | |
; | AHK Starter Template - mark05e | | |
; +-----------------------------------------------------------------------------+ | |
; | Change Log: | | |
; | 1 - Initial Commit | | |
; +-----------------------------------------------------------------------------+ | |
; | |
#NoEnv ; Recommended for performance. | |
#SingleInstance Force ; Make Single instance application. | |
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. | |
SetTitleMatchMode, 2 | |
SendMode Input ; Makes Send synonymous with SendInput. | |
Global AppVersion := "0.1" | |
Global AppName := "AHK Starter Template" | |
Global AppName := AppName . " " . AppVersion | |
Global LogEnable := true | |
Global settings := [] | |
settings["set1"] := "val1" | |
settings["set2"] := "val2" | |
Global ScriptNameNoExt | |
SplitPath, A_ScriptName, , , , ScriptNameNoExt | |
; | |
; +---------+ | |
; | Hotkeys | | |
; +---------+ | |
; | |
; Target specific window | |
#If isTargetWindowActive() | |
^+1:: ; Ctrl + Shift + 1 to trigger Function1 | |
Function1() | |
return | |
; No specific targets | |
#IfWinActive | |
^+\:: Reload ; Ctrl + Shift + \ to reload the script anytime | |
; | |
; +-----------+ | |
; | Functions | | |
; +-----------+ | |
; | |
isTargetWindowActive() { | |
if WinActive("Notepad") { | |
return 1 | |
} | |
} | |
WriteLog(text) { | |
if (LogEnable) { | |
FileAppend, % A_Now ": " text "`n", %ScriptNameNoExt%_log.txt ; | |
} | |
} | |
Function1() { | |
MsgBox % "This script name is: " . ScriptNameNoExt | |
MsgBox % "This app name is: " . AppName | |
WriteLog("This script name is: " . ScriptNameNoExt) | |
WriteLog("This app name is: " . AppName) | |
For _key, _val in settings { | |
WriteLog("Function1 - settings:" _key " = " _val) | |
displaySetting .= _key " = " _val "`n" | |
} | |
MsgBox % displaySetting | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment