I have proposed variable names for each idea, but any of these could be changed if desired.
I have split the proposals into two, with the less pressing ones in the second half.
As part of researching this, I have updated this link:
list of every command/function/variable from across all versions - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 42#p131642
RECENTLY FIXED
A_CaretX/A_CaretY: now CaretGetPos in AHK v2 (but remains as is in AHK v1).
A_Args: now available in both AHK v1 and v2.
[basis of code for a custom CaretGetPos backport]
convert coordinates between Client/Screen/Window modes - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=38472
CONTROLS: COORDINATES
A_CoordModeControl: to specify window/client coordinates for ControlXXX functions.
v2-changes
https://autohotkey.com/v2/v2-changes.htm
[basis of code for custom ControlXXX backports: JEE_ControlGetPosClient]ControlMove, ControlGetPos and ControlClick now use client coordinates (like GuiControl) instead of window coordinates.
FileSelectFile, add controls to the Open/Save As dialog - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=29934
[also:]
convert coordinates between Client/Screen/Window modes - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=38472
MOUSE
A_MouseSwapMode(/A_MouseButtonsSwapped/A_MouseButtonSwap/A_MouseSwapButtons): to determine how to handle {Click}/{Click right} etc.
SCRIPT PID
A_ScriptPID
This is possible:
vScriptPID := DllCall("kernel32\GetCurrentProcessId", UInt)
- I have numerous functions, where DllCall is used to get the PID as a static variable. Referring to a built-in variable would be preferable.
GUIs via DllCall: get/set internal/external control text - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=40514
- Also, when you execute code dynamically, e.g. for use with dll injection, or ExecScript, retrieving the PID like this clutters otherwise straightforward code.
- If an A_ScriptPID variable isn't available, then a custom ScriptGetPID function could be used, but this adds an annoying dependency to functions that are otherwise stand-alone.
- Anyway, the arguments for this are subtle, but overall, I think it is worthwhile. Also, I would use this variable far more frequently than many other variables.
FILES AND FOLDERS
summary of existing variables:
A_AhkDir [invalid], A_AhkPath, A_AhkName [invalid]
A_LoopFileDir, A_LoopFileFullPath, A_LoopFileName
A_ScriptDir, A_ScriptFullPath, A_ScriptName
A_WorkingDir
A_InitialWorkingDir [AHK v2 only]
- In my opinion, keeping A_ScriptName constant would be preferable.
- I would rather have a variable such as A_DlgTitle(/A_GuiTitle/A_DefaultTitle) to specify the default MsgBox/InputBox title.
- I would like my scripts to both have an A_DlgTitle variable available, but continue to be able to depend on A_ScriptName to reliably specify the name (including extension) of the script.
- Also, adding A_AhkDir would make the variables more consistent, reducing cognitive conflict:
cf. the capitalisation of 'Lock'
Suggestions on documentation improvements - Page 15 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 00#p189900
cf. 'Control, WinTitle, WinText, ExcludeTitle, ExcludeText'
Parameter order - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 37&t=30439
- It would also be worth backporting A_ComSpec and probably A_InitialWorkingDir.
FILES AND FOLDERS: #INCLUDE
Wish List 2.0 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 13&t=36789
- Another idea would be an /inc switch. Although having both solutions available would be best, and worthwhile in my opinion.>>> #Include: support more 'A_' variables
- support: A_Desktop, A_AhkPath, A_UserName, possibly 'A_Args##' [EDIT: this has been implemented except for A_Args##]
- A_AhkPath could be especially useful, as each exe in a folder could have its own folder or files e.g. 'AutoHotkeyU64 1.1.26.01.exe Lib' 'AutoHotkeyU64 1.1.26.01.exe.ahk'
- a lot of things 'can' be done with the #Include directive, but are unnecessarily and sometimes fiendishly complicated to do, and not newbie friendly
- other ideas would include: #IncludeIfArgContains (i.e. include a file if the nth command line parameter contains a certain string)
- I see making A_AhkPath available in this way, as an excellent way to have libraries that are unique to particular AHK exes. Is there any better/simpler solution?
- I recently moved the AHK exes out of C:\Program Files\AutoHotkey, since the folder causes admin nags, increasing the utility of variables such as A_Desktop and A_UserName.
- A_Desktop is also useful for specifying paths that are relative to C:\Users\%username% (or C:\Documents and Settings\%username%).
- E.g. of a workaround. This works but the #Include is allowed to fail which can be undesirable.
Code: Select all
#Include *i %A_AppData%\..\..\Desktop\MyScript.ahk
#Include *i %A_AppData%\..\Desktop\MyScript.ahk
A_EditTarget (or A_EditPath/A_EditCommand/A_EditOpenWith): Since changing the path of the program that edits scripts when Edit is used, depends on editing the registry, which isn't always accessible, it would be advantageous to be able to specify that path internally, via a variable. The variable could contain command line text including %1, just like what would appear in the registry key. E.g. "C:\Program Files\Windows NT\Accessories\wordpad.exe" "%1"
To specify paths/hIcons for the 4 systray icons:
A_IconFile (already exists)
A_IconFileP
A_IconFileS
A_IconFilePS
(where P and S stand for paused/suspended)
SORT
A_SortMode/A_SortStable: To specify stable/unstable sort.
- This could also be a parameter option in the Sort command, but most people who would want stable sort for the Sort command, would want it on by default, and so would want to blanket set all instances of the Sort command to use stable sort.
- Btw I believe that many (most?) users don't know what the difference is between stable/unstable sort, and would expect stable sort to be the default. Unstable sort is currently the default.
- Unstable sort: when two items are considered equal by the function, they can be rearranged. Stable sort: when two items are considered equal by the function, the earlier item remains earlier.
==================================================
MINOR: SPECIAL CHARACTERS: A_SPACE / A_TAB
Potentially useful variables, following a move to function syntax in AHK v2, to aid readability in certain cases:
A_Comma
A_DQ(/A_DQuote)
A_LP(/A_LParen)
A_RP(/A_RParen)
A_Sp (or Sp/StrRept functions, to repeat spaces)
A_SQ(/A_SQuote)
MINOR: DATES
I believe that the following are needed frequently enough to potentially deserve special variables:
A_NowMSec/A_NowMSecUTC: or a function to get both A_Now and A_MSec separately but in sync. It is never reliable to combine the use of separate variables to form a datestamp. E.g. New Year's Eve: you get the month, then the year, but the year changed as you did this. [EDIT: or a DateGet function as suggested in a post below.]
A_Today: the first 8 characters of A_Now.
MINOR: FILES AND FOLDERS:
There is potential value in having the following variables:
A_Recent(/A_RecentItems): the My Recent Documents/Recent Items folder.
A_AhkNameNoExt (and A_AhkDir/A_AhkName): for use with #Include (e.g. %A_AhkDir%\%A_AhkNameNoExt% Options.txt).
A_LoopFileNameNoExt: commonly useful.
A_ScriptNameNoExt: for use with MsgBox/InputBox/GUI titles and for use with #Include (e.g. %A_ScriptDir%\%A_ScriptNameNoExt% Options.txt).
MINOR: AHK V2 MODE FOR AHK V1
A 'SetAhkV2Mode' function or directive, would make certain things work as they do in AHK v2:
E.g. A_OSVersion (and also: InStr/SubStr/RegExMatch/RegExReplace, Loop).
MINOR: TIME IDLE
A_TimeIdlePhysical: An option to ignore mouse movements, i.e. the value is not reset to 0 by mouse movements. [EDIT: This has been implemented as A_TimeIdleKeyboard and A_TimeIdleMouse.]
A workaround:
A_TimeIdlePhysical to detect any input but not mouse movement? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 50#p170250
MINOR: LISTLINES
A_ListLines: To know whether it is on/off, to only record information for lines where a suspected bug will occur/to turn it off temporarily for loops. [EDIT: This has been implemented.]
MINOR: HOTKEYS
Variables such as these could potentially have merit:
A_ThisHotkeyHwnd(/A_ThisHwnd): active window when the hotkey was triggered.
A_ThisHotkeyIfWin(/A_ThisIfWinCriteria): #IfWin criteria when the hotkey was triggered.
A_ThisHotkeyNum(/A_ThisHotkeyIndex/A_HotkeyCount): a count of how many hotkeys have been triggered since the script loaded.
A_TimeOfPriorHotkey (cf. A_TimeSincePriorHotkey): the absolute time the hotkey was triggered, rather than the relative time.
Alternatively I could restructure the entire way that I define hotkeys in my script, to obtain such information via custom functions:
log hotkeys, get extended hotkey info, interact with the *right* window (Hotkey command with FunctionObject example) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=29560