Wish List 2.0

Propose new features and changes
User avatar
jeeswg
Posts: 6841
Joined: 19 Dec 2016, 01:58
Location: UK

Wish List 2.0

08 Sep 2017, 01:42

==================================================
= = = = = MY 2ND AUTOHOTKEY V1/V2 WISH LIST = = = = =
==================================================

[updated: 2019-11-08]
[note: this list is regularly tweaked, so I would recommend taking a copy and using WinMerge, or equivalent, to check for changes]
[note: throughout, any names could be changed as desired]

==================================================

IMPORTANT SIMPLE FUNCTIONS FOR AHK V1/V2
classic simple functions: Swap / Assign / Sign - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=13&t=64405
- [KEY] IsSet(var) for AHK v1
- [KEY] StrJoin(delim(s), strings*)
- [KEY] StrRept(string, count)
- Base64Get(addr, size)
- Base64Put(string, addr, size)
- HexGet(addr, size, case:="U")
- HexPut(string, addr, size)
- Pow(num, pow) (eases translation) (to maintain formulas intact)
- Sign(num) (eases translation + writing algorithms + elegant code)
- StrCount(string, needle, casesen:=0)
- Swap(var1, var2)/VarSwap(var1, var2) (eases writing multiple algorithms, e.g. lim1, lim2, put the smaller number first) (makes intention clear, people are only likely to use a swap function, if it's built-in)
- perhaps: NoOp(params*) (or at least promote '(0)' or equivalent in the documentation)
- perhaps: FloorMod(num, divisor) (if divisor is positive, result is positive/zero) (like Python's % operator, and Java's floorMod)
- perhaps: Between(num, lim1, lim2) (like AutoHotkey_H)
- perhaps: IsNum, Num ('ToNum') (see lower down)
- perhaps: BaseToDec/DecToBase (in some form)
- perhaps: SwapBytes/NumSplit (in some form) (easier than bitshifting, e.g. (A)RGB to/from BGR(A))

IMPORTANT QUICK FIXES
[numeric-looking strings]
numbers/strings in expressions - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=37&t=55905
Bug: StrSplit - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=37&t=58857&p=247485#p247485
- [KEY!!] AHK v2: fix (restore) comparison of variables containing numeric-looking strings
- [KEY!!] AHK v2: PropGetValue/PropSetValue method, and/or ObjProp(Get/Set)Value function, in some form
- [KEY!!] AHK v1/v2: 'global A_XXX' to not cause a crash
- [KEY!] AHK v1: is operator: if (var is type) (and/or IsType/StrIsType AHK (v1/)v2 function)
- [KEY!] AHK v2: ControlXXX functions: always allow the Control parameter to be omitted (more flexible/convenient, consistency)
- [KEY] AHK v1/v2: A_AhkVersionPart1/2, A_OSVersionPart1/2 (e.g. 1.1/6.1) (for #Include and writing functions)
- [KEY] AHK v1/v2: A_ChrSize (2/1) and StrSetCapacity (TChars) (brevity/readability, time saved with string assignments and DllCall)
- [KEY] AHK v1/v2: A_WA (W/A) (brevity/readability, time saved with DllCall)
- AHK v1/v2: A_ variables: A_AhkDir/A_AhkName/A_AhkNameNoExt, A_ScriptNameNoExt [for #Include / dialog titles]
- AHK v1/v2: A_DlgTitle (or similar) for dialogs/GUIs (not A_ScriptName)
- AHK v1/v2: MsgBox: replace CRLFs with LFs, for correct copying and pasting
- AHK v1/v2: StrReplace: add StartPos/CaseSen parameters (StartPos consistent with RegExReplace)
- AHK v2: // (floor divide), /// (integer divide) (// is already called 'floor divide' in AHK, and // is floor divide in Python)
- AHK v2: replace class variables (that clutter the namespace) with Class function (and/or A_Classes.MyClass variable or equivalent)
- AHK v2: StatusBarGetText/StatusBarWait: add Control parameter, versus only use 'msctls_statusbar321'
- #Warn LocalSameAsGlobal: a way to exit the script early, e.g. a MsgBox 'No'/'Cancel' button, versus no way to escape tonnes of MsgBoxes for various variables
- perhaps: is operator: handle is ascii/longpath/validpath/odd/even (see lower down) (highly convenient, and more readable)
- perhaps: StrSetSize (bytes) (alongside StrSetCapacity (TChars)) [the pair can replace VarSetCapacity, the two key uses: StrSetSize for a struct of a specific size (alongside BufferAlloc), StrSetCapacity for a large string of unknown size]

IMPORTANT FUNCTIONALITY REQUIRING MORE THOUGHT
[two-way compatible Loop]
why was LoopParse (no space) removed? - Page 4 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=37&t=41821&p=235007#p235007
- [KEY] AHK v1/v2: assign text (single line) (AHK v1 style), perhaps: var `= value [support `s]
- [KEY] AHK v1/v2: mod operator (to maintain formulas intact) (perhaps: %/mod for Mod() and %% for FloorMod())
- AHK v1/v2: 'LoopXXX' (LoopFiles/LoopParse/LoopParseCSV/LoopRead/LoopReg, *no spaces*, cf. 'Loop Files')
- AHK v1/v2: assign text (multi-line) two-way compatible AHK v1-style continuation sections [or Deref function with %A_Pct% for a literal %]
- AHK v1/v2: assign text (multi-line) two-way compatible verbatim continuation sections [handle "]
- AHK v1/v2: OnHotkey [specify a function to call each time any hotkey is triggered, e.g. log hotkey data] [perhaps OnHotstring also]
- AHK v1: 'Loop (expression)'
- AHK (v1/)v2: Range(start, end, step:=1) (similar to Excel VBA for loop: start end step)
- AHK (v1/)v2: Sort: handle arrays, stable sort by default or A_ variable (and stable sort option), null sort option (e.g. null sort + R option = reverse with no sort)
- [KEY] perhaps: an '/inc' command-line switch to specify files for inclusion (e.g. if ahk files are opened with a go-between script, this would allow the easy addition of code based on the script's properties/contents)
- [KEY] perhaps: #IncludeDirList or similar to determine which folders are checked for auto-includes (directives/options to: clear the list, add a folder to the list) (or one directive, to specify an empty/pipe-separated list) (adding an A_AhkDir variable would aid this)
- perhaps: make LoopParse Delimiters parameter like StrSplit
- note: a small number of AHK v2 features (Loop/in/contains) could be backported to AHK v1 with the explicit warning that their behaviour might change in future, 'bridging features'
- [KEY!] note: because of the massive convenience gains, I would allow (ignore) '% ' at the start of any parameters used with Loop/Loop XXX in AHK v2, until the final release, e.g. this would be two-way compatible for the time being: Loop Parse, vText, % "`n", % "`r"

IMPORTANT FUNCTIONALITY PRE-APPROVED IN SOME FORM
- [KEY] AHK v1/v2: IsPassed or A_ThisFuncParams.HasKey() or equivalent
- [KEY] AHK v1: #If WinActive() (optimised)
- AHK v1/v2: ahk_dhw/ahk_mode or equivalent (could combine both as ahk_mode/ahk_opt)
- AHK v1/v2: contains operator (or StrContains function)
- AHK v1/v2: in operator (or StrEquals/StrMatch function with an N (numerical) mode, which would also serve as a function version of = and ==)
- AHK v2: A_BIF.XXX() (redefine but access built-in functions) (perhaps for v1 as well)
- AHK v2: String/ObjToString (print keys/values) (for arrays/maps)

==================================================

ALLOW AHK V1 CODE TO WORK IN AHK V2
- <> operator (as it was in AHK v1) [based on A_StringCaseSense, as are: < <= > >=]
- NumPut (same parameter order)
- VarSetCapacity [or equivalents: e.g. both StrSetCapacity (TChars) and StrSetSize (bytes)]

BACKPORT
- File object: Handle property
- #SuspendExempt, and Suspend() at start of a subroutine
- read-only A_AllowMainWindow/A_InitialWorkingDir
- writable 'A_' variables, or an Assign function (needed for A_AllowMainWindow/A_IconHidden/A_IconTip)
- FileInstall()
- perhaps: support for `s in hotstrings [versus: trailing 'space backtick']

BACKPORT (OBJECTS)
- perhaps:
- var := var%obj.key% [temporary variables are a workaround]
- obj.%property%
- obj.%method%() [switch statements are a workaround]
- obj.Has() method
- obj.Length and obj.Count properties

INSTALLER OPTIONS

- perhaps add options:
- checkbox: add 'open with' support for ahk files
- checkbox: add 'AutoHotkey Script' to the 'New' menu
- (possibly add checkboxes for other changes: e.g. Run Script/Edit Script for ahk file context menu)

==================================================

CONTENTS

>> FUNCTIONS

>> 'A_' VARIABLES

>> SYNTAX (FOR AHK V1/V2)
> GLOBAL KEYWORD + 'A_' VARIABLES
> BUILT-IN FUNCTIONS: REDEFINE BUT ACCESS ORIGINALS
> CALL FUNCTION ON HOTKEY / ON RETURN
> AHK_DHW (V/VH/H) AND AHK_MODE (S/C/Q/E/R)
> CUSTOM FUNCTION DIRECT TO OBJECT (LOW PRIORITY)
> ONE FUNCTION, MULTIPLE NAMES
> BINARY NUMBERS
> OPERATORS
> GUIS (GRAPHICAL USER INTERFACES)
> #INCLUDE
> OBJECTS
> THOUGHTS FOR V2.0
> MISCELLANEOUS IDEAS

>> SYNTAX (TWO-WAY COMPATIBILITY)
> LOOP
> ASSIGN TEXT (SINGLE LINE)
> ASSIGN TEXT (MULTI-LINE) (CONTINUATION SECTIONS)
> CONTAINS/IN/IS OPERATORS
> BACKPORT
> BACKPORT (OBJECTS)
> BACKPORT (LOW PRIORITY)
> COMPATIBILITY DIRECTIVE/FUNCTION

>> DEBUGGING (LOW PRIORITY)

>> PROTOTYPE FUNCTIONS (LOW PRIORITY)
>> MINOR SUGGESTIONS (LOW PRIORITY)
>> MY WISHED LIST (MY WISH CAME TRUE)

==================================================

>> FUNCTIONS

FUNCTIONS (I WROTE C++ CODE FOR)

- [ADD PARAM] Ceil(Num, DP:=0) [DP]
- [ADD PARAM] Floor(Num, DP:=0) [DP]
- [ADD PARAM] Log(Num, Base:=10) [Base]
- [NEW] Between(Num, Lim1, Lim2) [x <= y <= z, chained operators, would be fiddly and add ambiguity] [already in AutoHotkey_H]
- [NEW] NoOp(Params*) [e.g. useful for if/else ladders]
- [NEW] Pow(Num, Power) [for use with libraries that are maintained across multiple programming languages cf. mod operator, and useful for changing an object's default value]
- [NEW] Sign(Num) [using Sign(), instead of a calculation, makes the code's intention clearer]
- [NEW] StrCount(Haystack, Needle, CaseSen:=0, StartPos:=1) [or omit the StartPos parameter for now][note: StrReplace to do StrCount may not be optimised, and is confusing for newbies]
- [NEW] StrJoin(Sep, Params*) [perhaps accept a linear array to have an alternating separator]
- [NEW] StrRept(Text, Num) [note: Excel has 'Rept', and 'StrRepeat' is too long]

- [NEW][FURTHER] ATan2(NumY, NumX)
- [NEW][FURTHER] IsNum(Num) [if looks numeric] [a 2nd Options parameter could be added, such that only variables of Float/Integer type would qualify]
- [NEW][FURTHER] Num(Num, Default:="") [to number, cf. Integer/Float][if doesn't look numeric, error, unless default value is specified]

- [NEW][FURTHER] Base64Get/Base64Put [similar to StrGet/StrPut]
- [NEW][FURTHER] FloorMod(Dividend, Divisor) [when Divisor is positive, return value is positive(/zero)]
- [NEW][FURTHER] HexGet/HexPut [similar to StrGet/StrPut]

- [NEW][FURTHER] Product(Params*) [if people want this function, I'm neutral]
- [NEW][FURTHER] Sum(Params*) [if people want this function, I'm neutral]

FUNCTIONS (KEY)

- [ADD PARAMS] StrReplace(Haystack, SearchText, ReplaceText, OutputVarCount, Limit:=-1, StartPos:=1, CaseSen:=0) [StartPos, CaseSen]
- [MODIFY] GuiFromHwnd [take over a GUI window created via DllCall][e.g. create a window and specify the class name and no icon]
- [MODIFY] PixelGetColor/PixelSearch [add a BGR option to AHK v2][note: aids automatic conversion]
- [MODIFY] Sort [see SORT (IMPROVED), e.g. handle arrays, stable sort, reverse with no sort]
- [NEW] BaseToDec/DecToBase (Num, Base) [or equivalent][a 3rd parameter, Chars(/Symbols), could allow you to specify which characters correspond to 0 to 'base-1': a linear array allowing multiple-character strings]
- [NEW] OnEdit (or a writable variable A_EditFunc): specify the name of a function to use instead of the Edit command (for when you don't have access to the registry, or when running scripts from an external drive) [a less-good alternative: in AHK v1/v2, if a custom function called 'Edit' exists, it is called whenever Edit is used]
- [NEW] OnHotkey [see: 'CALL FUNCTION ON HOTKEY / ON RETURN']
- [NEW] Range [for a 'start end step' for loop, and potentially for doing mathematics (populating an array)][for i = a to b (step c)][based on Excel VBA for loop]
- [NEW] SwapBytes/NumSplit [or equivalent][see 'SwapBytesInt' lower down]

FUNCTIONS (DIALOGS)

- In general, options: *specify hFont*, timeout, window position/size.

- [MODIFY] InputBox/ToolTip font [an HFONT:hFont option would be sufficient IMO, perhaps also name/*size*/weight options]
- [MODIFY] Progress/SplashImage kept [very convenient for debugging, worth keeping in some form in AHK v2][ultimately, having them as 'semi-official' functions makes no sense: newbie-unfriendly/difficult to share code on the forum]
- [MODIFY] ToolTip/Progress/SplashImage timeout:
- ... option to make the window timeout (it appears and disappears, but you can do stuff in the meantime) (T option)
- ... option to make it persist until the timeout is complete, i.e. a sleep (it appears and disappears, but you can't do anything else with the script in the meantime) (S option) (versus 3-line, on/sleep/off)
- [MODIFY] ToolTip/Progress/SplashImage colours [consistently referred to as '0xABCDEF', not 'ABCDEF']

- [MODIFY] MsgBox via InputBox:
- A MsgBox option, e.g. I, could make the MsgBox be created via the InputBox template, and allow access to some(/all) of the InputBox options
- (InputBox has size/position options which MsgBox doesn't)
- HFONT:hFont option
- NoEdit option for no Edit control
- [note: MsgBox font size: if you change the system MsgBox font, this adversely affects multiple programs, e.g. Firefox, wxMaxima, installers, e.g. distorting status bars, and expanding windows beyond the size of the screen]
- button labels: perhaps the option to specify the button count, the button labels and the default button number

FUNCTIONS (BLANK/OMITTED PARAMETERS)

- [MODIFY] ControlGetLine [if Line omitted/blank, return text of current line]
- [MODIFY] ControlXXX [AHK v2: a blank Control parameter equivalent to omitting parameter (i.e. operate on control/window specified in WinTitle parameter), as in AHK v1]
- [MODIFY] SubStr [a blank Length parameter equivalent to omitting parameter]
- [MODIFY][FURTHER] RegWrite [perhaps: make it possible to omit the type, i.e. assume the existing type]

FUNCTIONS (SIMPLE WORKHORSE FUNCTIONS)

- [MODIFY] VarSetCapacity [maintain existing data by default, with an Options parameter or A_ variable to allow it to be discarded]
- [NEW] StrSetCapacity(Var, CapacityChars, FillChar) (capacity specified in TChars)
- [NEW] StrSetSize(Var, Size, FillByte) [create string intended to store binary data]
- [NEW] VarExist(VarNameAsStr) [check if a variable exists] [e.g. an object may contain 1000 constants, 10 of those appear in the script, as yet undefined, assign values to those 10 variables, don't create 1000 variables]
- [NEW] VarGetName(Var) [pass a variable, retrieve its name, useful for debugging/displaying]
- [NEW] VarSwap(Var1, Var2) or Swap() [and perhaps: ObjSwapKeys(/ObjSwapValues/ObjSwap)]
- [NEW][FURTHER] VarSet/Assign [OldValue := Assign(Var, NewValue)]

- see also: Base64Get/Base64Put/HexGet/HexPut, Between/FloorMod/Pow/Sign, IsNum(/Num), NoOp, ObjSetDefaultValue, Range, StrCount/StrJoin/StrRept

- (StrGetCapacity/)*StrSetCapacity*, [StrLen]/StrSetLen [unit: TChars]
- (VarGetCapacity/)[VarSetCapacity], SizeOf(/VarSetSize) [unit: bytes]
- *StrSetSize* [unit: bytes]
- [an A_ variable so that VarSetCapacity can maintain data]

FUNCTIONS (FURTHER) (LOW PRIORITY)

- [ADD PARAM] DateAdd(DateTime, Time, TimeUnits, Format:="yyyyMMddHHmmss") [add Format param]
- [ADD PARAM] FileGetShortcut(LinkFile, OutTarget, OutDir, OutArgs, OutDescription, OutIcon, OutIconNum, OutRunState, OutShortcutKey) [add OutShortcutKey param (cf. FileCreateShortcut)]
- [ADD PARAM] StatusBarGetText/StatusBarWait [add Control param (versus forced to use 'msctls_statusbar321')]
- [FIX] WinKill [use ProcessClose for the time being]
- [MODIFY] DateAdd [perhaps allow add months (e.g. + 3 months: 31 Jan -> '31 Apr' -> 30 Apr)]
- [MODIFY] Format [perhaps support an associative array: Format("{key1} {key2}", oArray)]
- [MODIFY] FormatTime [if possible, fix 'date and time elements together, they must not be intermixed']
- [MODIFY] Send ['{Sleep n}' option]
- [NEW] BinCopy(/MemCopy/NumCopy) (Dest, Source, Size) [cf. RtlMoveMemory/memmove]
- [NEW] BinCompare(Addr1, Addr2, Size, ByRef DiffOffset) [cf. RtlCompareMemory/memcmp][perhaps DiffOffset for StrCompare also]
- [NEW] BinSearch(Addr1, Addr2, Size) (perhaps)
- [NEW] MakeUInt64(Low, High) [or possibly MakeType(Type, Low, High), or MakeType(Low, High, Type), or MakeNum, or MakeUShort/MakeUInt]
- [NEW] MCeil/MFloor/MRound (Num, Mult) [round to nearest multiple]
- [NEW] ObjToString(Object)
- [NEW] ProcessGetPriority(PIDOrName, Opt:="") [return a word, perhaps specify Opt:="n" for a number]
- [NEW] RegCreateKey(KeyName) [create a key without creating a value cf. RegWrite]
- [NEW] WinGetEnabled [to complete '(Control/Win)(Get/Set)Enabled'][perhaps 'Is' rather than 'Get']
- [NEW] WinGetOwner/WinGetParent/WinGetNonChildParent ([WinTitle, WinText, ExcludeTitle, ExcludeText])
- [NEW] WinGetVisible [to complete '(Control/Win)(GetVisible/Hide/Show)'][perhaps 'Is' rather than 'Get']
- [NEW] WinSetOwner/WinSetParent (hWnd(Owner/Parent) [, WinTitle, WinText, ExcludeTitle, ExcludeText]) [a tricky decision, it may be better to mimic the order of SetParent/SetWindowLong, but that could mean losing the 'WWEE' parameters]
- [MODIFY][FURTHER] RegExMatch/RegExReplace ['ANSI mode': better support for 1-byte and 2-byte characters: e.g. binary/ANSI/UTF-8/UTF-16 searches][File object: ReadHex/HexRead might also be useful][other options: BinSearch, custom/built-in BytesToShort function, then apply RegEx]
- [MODIFY][FURTHER] Reload [perhaps an option to maintain the command-line parameters when reloading][and to not show a MsgBox when trying to reload][options could be specified when the script receives a message from another script, via the lParam value]
- [NEW][FURTHER] ControlGetChoiceString [ControlGetChoice split to ControlGetChoice (return index) and ControlGetChoiceString (return string), consistent with ControlChoose and ControlChooseString]
- [NEW][FURTHER] FileEmpty(Path) (or FileSetText/FileWrite)
- [NEW][FURTHER] FileGetEncoding(Path)
- [NEW][FURTHER] NumCompare [to match StrCompare] [there could be a version compare option or separate VersionCompare/VerCompare function]
- [NEW][FURTHER] PathGetPart(Path, Part) [or FileGetPart][similar to SplitPath, but direct output]
- [NEW][FURTHER] ProcessGetCommandLine(PIDOrName) [pretty useful]
- [NEW][FURTHER] ProcessIsAdmin(PIDOrName) (or ProcessIsElevated)
- [NEW][FURTHER] ProcessIs64Bit(PIDOrName) [pretty useful]
- [NEW][FURTHER] RegExMatchAll [at least a custom function in the documentation]
- [RENAME] Integer -> Int [or, if don't rename 'Integer', perhaps introduce Trunc, with a decimal places parameter like Round]
- [RENAME] String -> Str

==================================================

>> 'A_' VARIABLES

'A_' VARIABLES (I WROTE C++ CODE FOR)

- [FURTHER] A_OParen/A_CParen/A_Pct [ ( ) % ] [or: A_LParen/A_RParen]
- A_AhkDir/A_AhkName/A_AhkNameNoExt [AutoHotkey_H already has A_AhkDir]
- A_ChrSize/A_WA [2 or 1, W or A]
- A_Comma/A_DQ/A_SQ [ , " ' ] [or: A_Apos]
- A_LoopFileNameNoExt
- A_Recent [Recent folder] [or A_RecentDir]
- A_ScriptNameNoExt
- A_ScriptPID
- perhaps: A_ThisHotkeyHwnd (see lower down)
- (note: 3 NoExt variables: A_AhkNameNoExt, A_LoopFileNameNoExt, A_ScriptNameNoExt)

- A_LoopFileAttribValue
- A_LoopFileTimeAccessedUTC/A_LoopFileTimeCreatedUTC/A_LoopFileTimeModifiedUTC [and possibly a UTC option for FileGetTime]
- or perhaps instead: A_LoopFilePtr (pointer to a WIN32_FIND_DATA struct)

'A_' VARIABLES

- [KEY] A_DlgTitle(/A_GuiTitle/A_DefaultTitle) [keep A_ScriptName read-only/dependable][e.g. A_DlgTitle := (A_ScriptNameNoExt = "") ? A_AhkNameNoExt : A_ScriptNameNoExt]
- A_AhkVersionMain(/A_AhkMainVersion) [e.g. 1.0, 1.1, 2.0] [or A_AhkVersionPart1/2]
- ... A_OSVersionMain(/A_OSMainVersion) [e.g. 5.1/5.2 (XP), 6.0 (Vista), 6.1 (Windows 7)] [or A_OSVersionPart1/2]
- A_IconFileXXX: tray icons: specify hIcons for the 4 icons via a variable/function: Pause on/off, Suspend on/off (e.g. A_IconFile (already exists), A_IconFileP, A_IconFileS, A_IconFilePS)
- A_InputBoxResult [easier to replace 'if ErrorLevel', avoid ugly use of a ByRef InputBox parameter]
- ... A_MsgBoxResult [easier to replace 'IfMsgBox']
- A_MSecLast [the milliseconds at the time you last retrieved A_Now/A_NowUTC][another idea would be: update date variables, lock them so they can't change, unlock them]
- A_SortMode(/A_SortStable) [stable sort for Sort] [or it could just be made default, with a letter option to turn off stable sort]

- InputBox/ToolTip: an A_ variable/object to set the InputBox/ToolTip font size/properties e.g. A_InputBoxHFont/A_ToolTipHFont [or A_InputBoxFontSize/A_ToolTipFontSize]
- Thread/Critical: an option to cache/discard hotkeys pressed while any subroutine is running. Perhaps an 'A_' variable. E.g. A_HotkeyCache / A_CacheHotkeys / A_IgnoreHotkeys or something else.
- perhaps: Format: a way to change '{}' to other characters, perhaps a separate FormatEx function with an additional parameter at the beginning [perhaps A_FormatChars to affect Format, but perhaps not]

==================================================

>> SYNTAX (FOR AHK V1/V2)

ideas, any of these can be changed as desired

> GLOBAL KEYWORD + 'A_' VARIABLES

- allow lines of the form 'global A_XXX'
- this would facilitate backporting new A_ variables to old scripts

Code: Select all

;global A_Tab ;Error: Built-in variables must not be declared.
global A_XXX ;this would not cause a crash
if !A_XXX
	var := "A_XXX", %var% := value
> BUILT-IN FUNCTIONS: REDEFINE BUT ACCESS ORIGINALS

vChar := A_BIF.SubStr(vText, 1, 1)

> CALL FUNCTION ON HOTKEY / ON RETURN

- OnHotkey/OnReturn (perhaps: OnHotstring also)
- specify a function to execute each time a hotkey is triggered, or before a return is executed
- e.g. for usage data: the function called would make use of 'A_' variables to record hotkey/hotstring data (an A_ThisHotkeyHwnd variable would aid this)
- ('OnHotkey' would be preferable, I mentioned 'OnReturn' because, as a workaround, I've used a 'RetX' function (which uses Exit) where 'return' would be)

> AHK_DHW (V/VH/H) AND AHK_MODE (S/C/Q/E/R)

- if an hWnd is specified for the Control/WinTitle parameter, the function should handle that control/window, ignoring A_DetectHiddenWindows, however, 'ahk_opt V' (or equivalent) could force the function to check if the window is visible/hidden

- Since the letters HV and CEQRS don't overlap, ahk_mode/ahk_opt could be used to perform both roles.
- E.g. use A_DetectHiddenWindows unless H and/or V is seen.
- E.g. use A_TitleMatchMode unless one of S/C/Q/E/R is seen. Starts/Contains/Equals (Q)/Ends/RegEx.

- Note: Q v. X: StrEquals (Q) is more meaningful than StrExact (X) (and would be familiar to AHK, cf. AHK v1's 'IfEqual').
- Note: the letters S/C/Q/E/R could be used in other contexts such as a StrMatch function.
- And would correspond to potential functions: StrStarts/StrContains/StrEquals/StrEnds(/RegExMatch).

- e.g. if WinActive("Untitled ahk_class Notepad ahk_dhw H ahk_mode S")
- or if WinActive("Untitled ahk_class Notepad ahk_mode HS")
- this would search for a hidden window, with a title that starts with 'Untitled'

- (V/VH/H): visible/either/hidden
- (S/C/Q/E/R): starts/contains/equals/ends/RegEx
- (perhaps also a case sensitive/insensitive option)
- note: this is one of the few things in AutoHotkey that is always case-sensitive and thus causes confusion (perhaps, or perhaps not, case-insensitive should be the default)
- perhaps: ahk_xtitle, ahk_xtext (there is currently no 'ahk_title' or 'ahk_text')
- and: ahk_xclass, ahk_xexe, ahk_xgroup, ahk_xid, ahk_xpid
WinTitle & Last Found Window | AutoHotkey
https://autohotkey.com/docs/misc/WinTitle.htm
- in AHK v2, an integer signifies an hWnd (if the parameter type is integer), perhaps instead it should signify an hWnd if the parameter looks numeric (ahk_title could be used as a prefix to force interpreting a number as a string)

- uses:
- useful for #If
- useful to avoid the repeated use of A_DetectHiddenWindows/DetectHiddenWindows and A_TitleMatchMode/SetTitleMatchMode
- useful since many window (and control) classes now have patterns requiring RegEx
- note: an extra reason for ahk_dhw and ahk_mode:
DetectHiddenWindows bug? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=14&t=30010

- 'ahk_mode R' could be added for Control/WinTitle parameters, for pattern-based but inconsistent class names (or otherwise something like: ControlGetHwndRegEx/ControlGetClassNNRegEx).

> CUSTOM FUNCTION DIRECT TO OBJECT (LOW PRIORITY)
(and custom class direct to object) (low priority)

- something like this that can handle a complete function cf. fat arrow functions:

Code: Select all

oFunc := NewFunc(arg1, arg2, arg3)
{
	return arg1 arg2 arg3
}
- the same may be potentially useful for classes oClass := class ...
- otherwise you can get clashes with existing functions/classes for simple temporary code
- this would be very useful for comparison functions, for use with the Sort function

> ONE FUNCTION, MULTIPLE NAMES

- 'alias functions' (or any existent name that is common within the programming community)
- when defining functions, to be able to refer to the same function but by using a different name, e.g. Func2() invokes Func1()
- there are some alternatives for dynamically referring to functions at present, but this would be simple to understand and newbie-friendly
- perhaps one of these possibilities (or something quite different, I am not particularly concerned about what the exact syntax would be):

Code: Select all

;this:
alias Func2 as Func1

;or this:
alias Func2 Func1

;or this:
Func2()
{
	alias Func1
}
- a further point would be a way to have a function such as MyDirExist, and if DirExist didn't exist, DirExist would point to MyDirExist (so, if FuncA doesn't exist, FuncB will be accessible via both FuncA and FuncB) (a backup function definition)

> BINARY NUMBERS

Code: Select all

vNum := 0b10001 ;17 = 16 + 1
vNum := 0b101010 ;42 = 32 + 8 + 2
- The Format function could have a 'b' option.

> OPERATORS

- if (a op1 b) [a finite set of redefinable binary operators e.g. 10, based on 2-parameter functions]
- perhaps: if (a starts b) [cf. in/contains, or a StrStarts function]
- perhaps: if (a ends b) [cf. in/contains, or a StrEnds function]
- if (a % b) ['%', or perhaps 'mod'] [with perhaps '%%' for FloorMod]
- // (always floor division)
- /// or idiv (integer division) (or some other symbol)
- <> (I would hope to keep this with the AHK v1 behaviour)
- also: contains/in/is for AHK v1/v2

- [add operators/functions to make it possible to preserve formulas from other programming languages intact without having to add/remove parentheses e.g. mod, //, ///, Pow function]

- ternary operator: an invalid ternary operator could raise an error in AHK v1

> GUIS (GRAPHICAL USER INTERFACES)

- GUI objects: oGui.B / oGui.R (or oGui.Pos.B / oGui.Pos.R) (bottom/right)
- GUI control objects: oGui.HwndParent (or oGui.HParent), oGui.HwndNonChildParent
- [KEY] GUI menu objects: specify menu item ID numbers (e.g. for use with accelerator keys and compatibility with other programs)
- support for accelerator keys ('soft' hotkeys that can be overriden by other scripts, cf. 'hard' hotkeys)
- [KEY] Text/Value: the distinction between .Text and .Value is not clear, perhaps, in each case, .Value should be replaced with something more intuitive
- perhaps: GUI objects: increased support for setting the colour of a control (add it for more control types)

- For reference:
GUI - Complete Command & Property Listing - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=46420&p=213529#p213529

> #INCLUDE

- something like the following (the names aren't important):
- /inc switch: include files via the command line
Pre-execution Code - Page 2 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=13&t=40659&p=185907#p185907
- #IncludeDirList: specify which folders to check, blank for none, e.g. #IncludeDirList %A_ScriptDir%\Lib|%A_MyDocuments%\Lib|%A_AhkDir%\Lib|%A_AhkDir%\Lib\ExtraFuncs [note: A_AhkDir is in AHK_H but not currently in AHK_L]
- or less good: #IncludeNoAuto (or #IncludePrevent/#IncludeBlock): prevent any files from being auto-included, all files would require an explicit include

- perhaps: #IncludeAtEnd: insert code at the end of the script, rather than at the current point in the script
- perhaps: #IncludeIfArgContains: include a file if the nth command-line parameter contains a certain string

> OBJECTS

- loop-and-delete: perhaps a way to delete keys during a for loop, perhaps a reverse loop [this would be a big change for a small/medium-sized problem so ...]
- or alternatively/additionally: a function that just removes empty or non-existent keys from linear arrays, or that removes keys with a particular value (conditional Delete/RemoveAt) [the main problem for me is not speed, but simple tasks in functions that become verbose and dominate/muddy the code]
- a way to set the default value of an object (e.g. 0 instead of a blank string) e.g. ObjSetDefaultValue [or ObjDec/ObjInc]

> THOUGHTS FOR V2.0

- Re.:
v2-thoughts
https://autohotkey.com/v2/v2-thoughts.htm

- I mention some points re. ControlClick/MouseClick/Thread/VarSetCapacity here:
conversion logic, v1 = -> v1 := -> v2, two-way compatibility - Page 7 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=37&t=27069&start=120

- I mention some points re. ControlXXX functions here:
ControlXXX functions - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=37&t=43486
- E.g. ControlGetChoice split to ControlGetChoice (return index) and ControlGetChoiceString (return string), consistent with ControlChoose and ControlChooseString.

> MISCELLANEOUS IDEAS

- [KEY] IsPassed: perhaps for non-variadic functions, something similar to IsByRef: was the parameter passed/omitted [or a Null constant] [or A_ThisFuncParams.HasKey()]
- variadic and ByRef: perhaps variadic functions where all parameters are ByRef
- [KEY] if feasible, to make hotstrings more like hotkeys re. #If and the 'global variant': 'it will fire only if no other variant is eligible (this exception does not apply to hotstrings)'
- [KEY] continuation sections: allow longer strings (e.g. 4 times longer at least, perhaps even 10 times longer or more)
- make the default dialog title (e.g. for tray icons) 'NameNoExt' instead of 'NameNoExt.ahk' or 'NameNoExt.exe' [looks better, and may avoid script/exe differences]
- consistent function parameter order, consistency trumps other concerns:

Code: Select all

;oftentimes functions should be of the form 'XXX...(XXX, ...)':
ProcessSetPriority(PIDOrName, Priority) ;yes
ProcessSetPriority(Priority, PIDOrName) ;no
- Integer/String types should (almost) never matter in AutoHotkey:

Code: Select all

;proposals:

WinExist(1234) ;check for hWnd
WinExist("1234") ;check for hWnd (*not* title)
WinExist("ahk_title 1234") ;check for title

ControlChoose("1") ;choose 1st item (*not* item called '1')
ControlChooseString("1") ;choose item called '1'
- source code: consistent case for function names, e.g. XXXCapsLockXXX, in the source code and when retrieving function names via Func: Func("StrLen").Name
- source code: tidy indentation (whitespace) in AHK source code files
whitespace summary: frequency count of leading/trailing spaces/tabs - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=55048

==================================================

>> SYNTAX (TWO-WAY COMPATIBILITY)

> LOOP

- make 'Loop (Expression)' possible in AHK v1
- make 'LoopXXX' (no space) available in AHK v1/v2

Code: Select all

Loop Num ;[e.g. Loop 3]
Loop (Expression) ;[e.g. Loop (obj.Length())]
LoopFiles FilePattern [, Mode]
LoopParse String [, Delimiters, OmitChars]
LoopParseCSV String
LoopRead InputFile [, OutputFile]
LoopReg KeyName [, Mode]
- other notes on Loop:
- Loop-Parse: perhaps make the Delimiters parameter like the StrSplit parameter (the inconsistency is confusing)
- Loop-Files: perhaps allow arrays for the FilePattern/Mode parameters (to search multiple folders)
- ... i.e. search for file pattern array[n] using mode[n] (if mode is an array), or use the same mode for all file pattern array values (if mode is a string)
- for loop: perhaps allow: for vKey, A_LoopField in oArray

> ASSIGN TEXT (SINGLE LINE)

An operator to assign in the AHK v1 style e.g.:

Code: Select all

vTarget `= "%vPathExe%" "%vPath%" ;great for command-line strings for use with Run
vText `= `shello`s ;support for `s in both AHK v1 and AHK v2
vText `= abc ' def " ghi ;allow both ' and " in a string without escaping e.g. for use with html or replacing code lines before/after text
vList `= abc,def,ghi ;handy oft-modified comma-separated lists without needing double quotes
obj.key `= my string
Note: AHK v1 `= lines could handle `s, even if it wasn't handled elsewhere.

- some other ideas: e.g. this post considers Format handling variable/object key names
AHK v2 and strings - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=37&t=36833&p=173365#p173365

> ASSIGN TEXT (MULTI-LINE) (CONTINUATION SECTIONS)

- a two-way compatible way to assign verbatim multi-line text (perhaps a 'V' option)
- this works with expressions in AHK v1 and AHK v2, however, in AHK v1 double quotes need to be doubled up (" -> ""): (` Join`r`n
- (in AHK v1, all characters in an expression continuation section can be WYSIWYG except for double quotes)
- also, AHK v1 continuation sections could handle `" and `s, even if they aren't handled elsewhere
- (one use case: continuation sections consistent in both AHK v1/v2 are very useful for dynamic code that is going to be executed by another AHK process)

- a two-way compatible way to assign AHK v1-style text (perhaps an option letter)
- this would be handy, plus you could you make older scripts forwards compatible easily

> CONTAINS/IN/IS OPERATORS

- if (var contains list)
- if (var in list)
- if (var is type)

- On balance I think contains/in should treat a string as one item (not as a comma-separated list, or list of characters)

- [KEY] if they treat a string as one item, some handy syntax for handling a comma-separated/pipe-separated list string should be considered
- E.g. a custom one-liner can add a 'split' method for strings:
if var in/contains comma-separated list/array - Page 2 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=37&t=43593&p=247622#p247622

> BACKPORT

- File object: Handle property
- #If WinActive() (optimised)
- #SuspendExempt and Suspend() at start of a subroutine
- A_AllowMainWindow/A_IconHidden/A_IconTip, A_InitialWorkingDir, (writable 'A_' variables)
- FileInstall()
- if (var is type) [and contains/in when functionality decided]

> BACKPORT (OBJECTS)
- perhaps:
- var := var%obj.key% [temporary variables are a workaround]
- obj.%property%
- obj.%method%() [switch statements are a workaround]
- obj.Has() method
- obj.Length and obj.Count properties

> BACKPORT (LOW PRIORITY)

- AHK v2 functions to officially backport (ordered by priority):
- DateAdd/DateDiff, DirExist
- MsgBox function, Type, WinGetList

- Further:
- FormatTime function [to avoid unreliable 'A_' variable concatenation, handy in expressions]
- InputBox function
- ControlGetList ('ControlGetItems')/WinGetControls/WinGetControlsHwnd
- Random function [functions that can't easily be recreated via Winapi functions]
- ControlClick function [when it's finalised, the AHK v1 command is too fiddly]
- list of new AHK v2 functions for reference:
list of every command/function/variable from across all versions - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=27321&p=131642#p131642

> COMPATIBILITY DIRECTIVE/FUNCTION

- e.g. a SetAhkV2Mode function/A_V2Mode on/off variable (to make AHK v1 more like AHK v2) for the following functions:
- InStr/SubStr/RegExMatch/RegExReplace: handle negative values for positions as in AHK v2 [workaround: I use JEE_InStr/JEE_SubStr which are two-way compatible]
- RegExMatch (listed again): in AHK v2: object mode is the default, and the line break handling has changed [workaround: I use JEE_RegExMatch which is two-way compatible]
- StrPut: AHK v2: return a byte count, AHK v1: return a character count [workaround: I use JEE_StrPut which is two-way compatible]

- further ideas: the mode could also set:
- A_OSVersion: always return a number, not a friendly name ('WIN_XXX') [not needed if A_OSVersionMain introduced]
- A_LoopRegKey: root key\subkey (AHK v2), root key (AHK v1)

- further ideas: a directive could do this:
- [KEY] double quotes: disallow "" but do allow `" [a workaround would be an A_DQ variable]
- Loop: use expression style parameters [not needed if LoopXXX and Loop (Count) are introduced]
- set all default settings equivalent to AHK v2
- ... something similar could exist for optimal speed settings, e.g. #Speed

- further ideas: warnings:
- there could be warning messages for any AHK v1 legacy if-statements that were not forwards compatible with AHK v2 (and similar for: assignments, loops, incomplete ternary operators, variable names starting with a digit) e.g. #Warn Legacy
- (incomplete ternary operators could trigger an error in AHK v1 as standard)

==================================================

>> DEBUGGING (LOW PRIORITY)

- #Warn at loadtime (#Warn LocalSameAsGlobal):
- [KEY] if #Warn detects errors at loadtime, there isn't currently an easy way to exit the script, other than via Task Manager, or another AHK script via ProcessClose, note: the tray icon will not yet have showed
- perhaps the MsgBox could say: continue? Yes/No (default: Yes), instead of OK

- list all scripts:
- list all explicitly/implicitly included files (via #Include or via the presence of functions)

- list all functions/variables:
- e.g. via an object, be able to retrieve a list of all the functions/variables in the script, and information about them, including variables that are local to functions
- a way to retrieve a list of all built-in/custom functions, built-in ('A_')/global/local variables
- e.g. the script could check for variable names starting with 'WM_'/'xl' and then set the contents for those variables cf. indiscriminately creating variables for all possible constants (in effect a 'VarExist' function)

- variable information:
- scope: local/global/static/super-global (identify variables that cause #Warn errors)
- type: Float/Integer/Object (class/object)/String
- address (this would make possible pointer to variable/object name)
- case: list any variables where the case is inconsistent (useful when searching text and when converting to other languages)
- initialised: is/isn't initialised (has it been assigned a value)
- built-in: is/isn't an A_ variable/Clipboard/ErrorLevel/False/True (ClipboardAll/ComSpec/ProgramFiles)

- list main window information (ListLines/ListVars/ListHotkeys/KeyHistory):
- retrieving the line history, key history and hotkey list, direct to a variable/via an object/'A_' variable object, would also be useful
- the hotkey list is presently a little limited, having a count for each hotkey, and/or having a list of each hotkey label in each file might be useful
- ListVars: there could be an option to display more characters e.g. the first 256 characters (to display full paths), it could also *always* show certain key A_ variables e.g. A_Index/A_LoopField/A_LoopFileFullPath (to know how far a loop is progressing)

- parsing:
- list variables/functions in selected code
- code to summary e.g. var := Func(obj.key, var) -> VVV PP FFFF(OOO.KKK, VVV) [note: 'P' for operator]
- note: existing scripts: DebugVars and ScriptInfo

- hotkeys stop working:
- sometimes all of the hotkeys stop working, although the script keeps working as usual
- solutions could include:
- a function to reregister the 'forgotten' hotkeys (which could be triggered via OnMessage)
- a function to force reload a script (or an option added to the Reload command) (which could be triggered via OnMessage)
- a function to check if a script's hotkeys are still working
- (otherwise the script needs to be reloaded)

- more granularity re. 'Could not close the previous instance of this script. Keep waiting?':
- I have a workaround here:
avoid 'Could not close the previous instance of this script' warnings - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=59615
- e.g. WM_COMMAND with ID_FILE_RELOADSCRIPT/ID_TRAY_RELOADSCRIPT: the lParam could act as flags: (1) no warning MsgBox, (2) maintain command-line arguments
- (possibly also, a way to increase the delay between MsgBox prompts)
- (out of interest, it would be useful to understand why some scripts take longer to reload than others)

- main window: hidden Static/Edit control:
- a hidden control in the main window, perhaps a Static/Edit control, just for storing a handy message/information, a 'ticker', a 'status bar' [or: there could be a menu option like 'View, Console']
- this can be used to communicate information between scripts, or the user can use it to get an update on the script's progress
- note: one idea is to change the main window's title temporarily, but this is undesirable as scripts often use this to identify windows
- I've achieved a possible workaround here:
SetWindowText and Edit controls - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=38313&p=175935#p175935
- perhaps a 'Print' menu item, an area where things are printed
- note: there could be another such control to reliably store the script's path (instead of the main window's title which could change)

==================================================
==================================================
==================================================

>> PROTOTYPE FUNCTIONS (LOW PRIORITY)

LINKS TO PROTOTYPE FUNCTIONS (WORKHORSE FUNCTIONS/SUPER-FUNCTIONS)

- Some of these are Swiss army knife-style super-functions. Some of these versatile/powerful string/array functions, with many bits of functionality, cf. the Sort command, can be difficult to agree upon, but are worth considering.
- Sometimes simple but versatile functions can make a difference. E.g. NumOp(a, op, b) or StrOp(a, op, b), where you can specify an operator dynamically. Which would otherwise require a massive if/else ladder.

- SORT (IMPROVED)
- SortedString := Sort(String [, Options, Function])
- E.g. var := Sort(var, "D`n O`r", vFuncName)
- E.g. var := Sort(var, "D`n O`r", oFunc)

- String parameter: handle linear arrays
- (Options parameter: original options: C CL Dx F N Pn R Random U Z \, note: the F option was removed in AHK v2)
- possible options (different letters can be used):
- Options parameter: S1/S0/S (or T1/T0/T) option: stable sort [and a variable to make it on/off by default: e.g. A_SortMode(/A_SortStable), on at script start][if 2 items are considered identical, maintain their order]
- Options parameter: X option: null sort (e.g. null sort + existing R option = reverse without sorting)
- Options parameter: O option: omit characters
- Options parameter: XD option: no delimiters, sort individual characters (e.g. alphabetise/reverse/shuffle)

- (perhaps also: StrAlphabetize/StrReverse/StrShuffle) [or StrRandomize]
- (other minor features:)
Sort function + extra features - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=50431

- possibly: Sort(String [, Options, Function, Delimiters, OmitChars]), delim/omit params to match StrSplit, in addition to D option
- possible functionality: remove duplicates without sorting
- possible functionality: remove all duplicates/adjacent duplicates only

- note re. omit characters:
minor bug: Sort command's handling of LFs/CRLFs - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=14&t=59066

- IN/CONTAINS/STARTS/ENDS(/STRMATCH)
- StrStarts/StrContains/StrEquals/StrEnds [see also: A_TitleMatchMode]
- a separate function, StrMatch, could do all 4 and RegExMatch via S/C/Q/E/R options or MS/MC/MQ/ME/MR options, or StrEquals could have those options
- faster than RegEx (^exact$/contains/^starts/ends$)
- no RegEx escaping issues
- case sensitivity option
- numeric/string comparison option [or possibly a NumEquals function]
- Links:
simplest way to make a RegEx needle literal? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=30420&p=169211#p169211
if var in/contains comma-separated list/array - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=37&t=43593&p=209222#p209222
Improve InStr or IfInString - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=13&t=31812
- (The outputs could be done directly, and/or via a ByRef parameter.)

Code: Select all

StrContains(vHaystack, vNeedles, vOpt, ByRef vMatch)
StrEnds(vHaystack, vNeedles, vOpt, ByRef vMatch)
StrEquals(vHaystack, vNeedles, vOpt, ByRef vMatch)
StrStarts(vHaystack, vNeedles, vOpt, ByRef vMatch)

StrMatch(vHaystack, vNeedles, vOpt, ByRef vMatch)
- HEX AND BASE64
[Base64Get/Base64Put and HexGet/HexPut]
StrPut/StrGet + hex/base64 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=50528

- SEARCH OBJECTS FOR KEYS/VALUES
- get specific keys/values from an array
- [ObjGetVals]['ObjMatch']
object get keys/values prototype function - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=43253

LINKS TO PROTOTYPE FUNCTIONS

[BaseToDec/DecToBase]
BaseToDec / DecToBase - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=57772

[BinCopy/BinCmp]
Allow AutoHotkey to Handle Binary Data - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=13&t=61502&p=265140#p265140

[ControlGetHwndRegEx(/ControlGetClassNNRegEx)]
Being more generic when using WinActivate and ControlSetText - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=40896&p=186624#p186624

[DateGet][or A_NowMSec/A_NowMSecUTC][or A_MSecLast, the milliseconds at the time you last retrieved A_Now/A_NowUTC]
- you cannot reliably do vDate := A_Now A_MSec
- or concatenate any date variables
A_ variables - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=37&t=41870&p=191046#p191046

[FileGetPart/(PathGetPart)]
file get part (SplitPath alternative/short-form/long-form/correct case) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=47709

[FileSetText(/FileWrite), FileGetEncoding, FileEmpty]
file set text/empty/get encoding/force read with specific encoding - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=47084

[FloorDiv/FloorMod(/ModPsv)]
FloorDiv / FloorMod (and an 'always positive' Mod function) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=55751

[MsgBox/InputBox/InputBoxMulti/Progress/SplashImage/ToolTip/Borders (SplashBorder)]
slightly-improved dialogs - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=37&t=45220

[ProcessIsAdmin/ProcessIsElevated]
How to check if active window runs as admin? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=43417&p=197426#p197426

[Range][similar to Excel VBA for loop: start end step][e.g. -10 to 10 inclusive in 0.5 increments]
For loop question - Ask for Help - AutoHotkey Community
https://autohotkey.com/board/topic/66916-for-loop-question/#entry423515
traditional for loop: for i = a to b (step c) possibilities - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=43022&p=238737#p238737

[RegExMatchAll]
prototype 'RegEx match all' function - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=50012

[StrHatch/StrDelimit][add a string every n characters]
[StrPad][add characters to the start/end of a string]
slice string, pad characters - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=47079

[StrJoin (with alternating join string)]
StrUnused prototype function: find unused characters for use as delimiters/separators - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=43623&p=198312#p198312

[StrRept/StrCount]
StrRept and StrCount - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=13&t=34765

[StrUnused]
StrUnused prototype function: find unused characters for use as delimiters/separators - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=43623

[SwapBytesInt/NumSplit]
swap bytes - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=47081

[Combin/Permut]
combinations and permutations (and anagrams) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=34244&p=158871#p158871

[big integer functions]
Decimal to Base64 conversion + Custom character list - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=37465&p=174697#p174697

Num / IsNum / Int / Float / Str - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=13&t=64339

classic simple functions: Swap / Assign / Sign - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=13&t=64405

ALSO

[some simple but bold ideas][my prediction of the fundamental features that users will want]
objects/object classes: new features from a newbie-friendly perspective - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=42135&p=214283#p214283
Objects+ - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=37&t=58215

LINKS TO PROTOTYPE FUNCTIONS (C++)

C/C++ - AutoHotkey Community
https://www.autohotkey.com/boards/viewforum.php?f=75

C++: AHK source code: potential functions - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=23&t=54392

C++: AHK source code: potential A_ variables - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=23&t=54419

==================================================
==================================================
==================================================

>> MINOR SUGGESTIONS

MINOR SUGGESTIONS (DESERVE AT LEAST A MENTION):
- [note: some of the better ideas are marked '[PRIORITY]']
- [note: some deprecated ideas have been moved lower down and marked '[MINOR]']

- A_Bitness and/or A_Arch (or something like it) to give 64/32 and/or 64/86, which might be useful for use with #Include
- A_Extra1, A_Extra2, variables that could be set with something like a #Set directive based on a condition, for possible use with #Include
- A_MouseSwapMode(/A_MouseButtonsSwapped/A_MouseButtonSwap/A_MouseSwapButtons)
- A_Sp (v. A_Space), A_Field (v. A_LoopField) (in addition to the existing variables)
- [PRIORITY] A_ThisHotkeyHwnd: the matching (e.g. active) window at the time the hotkey was triggered
- [PRIORITY] A_ThisHotkeyRaw (hotkey names with/without the leading *~$) (could also apply to hotstring, to strip the leading ::/:*: etc) (also, could be used to return the exact case of the characters that triggered the hotstring)
- A_ZBIndex: zero-based index version of A_Index for loops [or A_ZIndex]
- control focus: in AHK v2, ControlGetFocus gets the focused control irrespective of the active window, applying ControlGetFocus relative to the active window, and failing if the focused control is not a control of the active window, might be useful
- delay: a general delay between line executions that can be turned on and off, e.g. Run Sleep Run Sleep
- [PRIORITY] FileGetBitness/FileGetInfo/ProcessGetBitness/ProcessIs64Bit: determine if a process/exe/dll is 64-bit/32-bit/16-bit [only FileGetBitness/FileGetBits is priority]
- FileRead/File object: consistent unknown character: ? v. Chr(0xFFFD)
- FileSetText(/FileWrite) function (and/or 'FileEmpty'/'FileGetEncoding' functions)
- GUI: create a control by specifying 'Static' rather than 'Text' or 'Picture', this always catches me out
- [PRIORITY] hotkey 'does not exist in the current keyboard layout': perhaps some alternative options for handling this (perhaps something in the #Warn directive to optionally prevent an error message)
- if (var is "ascii"), equivalent to: vIsAscii := !RegExMatch(vText, "[^[:ascii:]]")
- if (var is "longpath"), e.g. is it 260 chars+ [or another name]
- if (var is "validpath"), is it a valid path [or another name]
- if (var is "odd") / if (var is "even")
- Loop Files: allow arrays for FilePattern and Mode, to search in multiple folders
- [PRIORITY] OnWarn: specify a function to handle warnings (however, some messages would occur before the script had started)
- [PRIORITY] panic button: support(/documentation guidance) to help stop a script, start/stop a hotkey subroutine (with the same hotkey/with different hotkeys)
- [PRIORITY] PathGetCorrectCase function (or FileGetCorrectCase) [a FileGetPart/PathGetPart function could do this]
- registry loop: an option to retrieve keys (and perhaps values) in alphabetical order (e.g. a letter, 'A', cf. V/K/R, or an 'A_' variable) [StrJoinReverse or Sort 'reverse without sorting' would be good alternatives for reversing a list]
- RGBToBGR function, perhaps with an ARGB to BGRA option, or a more general swap bytes function (or NumSplit function)
- Send: {Event}/{Input}/{Play} options (and a {Sleep 100} etc option)
- #Speed directive (or equivalent functionality by some other means): set multiple defaults for increased speed
- StrReplace: perhaps allow StrReplace's SearchText/ReplaceText parameters to accept arrays, in order to do replace multiple string replacements
- trig functions (Sin/Cos/Tan/ASin/ACos/ATan): add a parameter to accept "d", to use degrees

- big integers: more general support for big integers (and/or infinite precision), perhaps by treating numbers as strings (note: AHK only supports Int64 natively, not UInt64, however, there are workarounds regarding UInt64)
- Combin/Permut functions (that can handle with/without repetitions).
- Fact function (factorial function).

- [MINOR] 'can be an expression': % %var% should work consistently across all parameters, currently in 'can be an expression' parameters, this is interpreted as % var, i.e. one would hope that if you prefix a parameter with '% ', you should be safe, you should get what you expect, it should work exactly as it would in a function parameter
- [MINOR] A_CoordModeControl [for use with ControlClick/ControlGetPos/ControlMove][AHK v1 uses Window coordinates, AHK v2 uses Client coordinates][Client is more useful, Window is hardly useful][I've created custom functions for the easy conversion of AHK v1 scripts (allowing X/Y values to be preserved)][EDIT: I've accepted that it might be better only to allow Client coordinates, as AHK v2 does]
- [MINOR] Between: Between(vNum, vLim1, vLim2, vOpt:="ii") where i/x indicates inclusive/exclusive (equivalent to <= / <), making the function 4 times more useful than the operator was. [EDIT: i/x might be too esoteric]
- [MINOR] continuation sections: LTrimS option (LTrim 'smart') (default behaviour in AHK v2)
- [MINOR] ControlGetFocusClass/ControlGetFocusClassNN/ControlGetClass
- [MINOR] def/func keyword required for all function definitions (cf. class keyword)
- [MINOR] defer functionality (or something similar)
- [MINOR] Deref function
- [MINOR] FloorDiv(Num1, Num2) and IntDiv(Num1, Num2) [note: Floor(Num1/Num2) and Integer(Num1/Num2) are already possible]
- [MINOR] for loop: a symbol, that if used for the key, prevents a variable being created for it: e.g. for ~, vValue in oArray [note: AHK v2 lets you omit the key parameter]
- [MINOR] FormatTime: 'FormatTime, vWDay, % vDate, WDay' gives 2 even when the date is invalid, but if that's just the behaviour of the Winapi function, then that's a legitimate argument to do nothing re. this
- [MINOR] func MyFunc(): equivalent to class MyClass (for function definitions) [def/func mentioned above]
- [MINOR] functions: option where if a function already exists, to ignore secondary definitions (rather than prevent a script from loading) (I can see potential arguments against this, although if the user opted to do this via a directive, it could potentially be a good idea)
- [MINOR] functions: the ability to refer to variables from the scope of where the variable was called e.g. to be able to create a Deref function in AHK v1/v2, note: RegExMatch variable mode and StringSplit also have this ability (cf. variables that are local to a function, global variables v. variables that are local to where the function was called from) (an alternative would be to restore the Deref function to AHK v2, and introduce it to AHK v1, the functionality already exists in AHK v1 via the Transform command)
- [MINOR] hotstrings: special hotstrings: define a hotstring in a similar way to a Send line (i.e. any key presses used with Send can be used to trigger a hotstring)
- [MINOR] InStrRev function: like InStr but that would search in reverse and accept positive values for positions
- [MINOR] not: 'not' could have the same precedence as ! (I don't use 'not')
- [MINOR] NumGet/NumPut/StrGet/StrPut: smart parameters could be removed (parameters are either used or omitted)
- [MINOR] NumGet/NumPut: 'Offset' could be removed (actually, it adds clarity sometimes)
- [MINOR] NumGet/NumPut: perhaps the ability to handle CLSIDs/GUIDs could be added
- [MINOR] object classes: obj := new %class%, perhaps a blank or other string to create a built-in array [actually, this is possible: obj := (class = "") ? {} : new %class%]
- [MINOR] objects: IsArray function (true if: empty array or contains only keys from 1 to .Length(), with/without gaps)
- [MINOR] RegExMatch: V mode, outputs the entire match to a variable [but unlike AHK v1, no other pseudo-array variables]
- [MINOR] Send: combine Send/ControlSend AHK v2 functions [or: optional control/window parameters for Send]
- [MINOR] StrLeft/StrRight/StrTrimLeft/StrTrimRight [StrStarts/StrEnds more important than StrLeft/StrRight]
- [MINOR] StrJoinReverse (could be handled by an improved Sort function and StrJoin instead)
- [MINOR] VarSetCapacity: 1-parameter mode, accept A_ variables [not needed since IsSet added]
- [MINOR] WinClick
- [MINOR] WinSetTransColor/WinSetTransparent: perhaps they should be combined
- [MINOR] WinXXX/ControlXXX functions etc: remove ExcludeTitle/ExcludeText parameters

[Wish List 1.0]
jeeswg's 3-item wish list (GUI class name+GUI no icon, A_ThisHwnd/A_ThisIfWinCriteria on hotkey launch, InputBox HFONT) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=13&t=26180

Thanks for reading.

==================================================
==================================================
==================================================

>> MY WISHED LIST (MY WISH CAME TRUE)
Spoiler
Last edited by jeeswg on 08 Nov 2019, 11:55, edited 520 times in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jNizM
Posts: 2510
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: Wish List 2.0

08 Sep 2017, 02:00

jeeswg wrote:>>> return/continue/break in multi-statements
- e.g. when the script runs, the original code:

Code: Select all

var1 := 1, var2 := 2, var3 := 3, return
would be converted by AHK to:

Code: Select all

{
	var1 := 1, var2 := 2, var3 := 3
	return
}
This one works:

Code: Select all

return, var1 := 1

jeeswg wrote:A_ScriptPID: the script's PID
it's already a one-liner -> MsgBox % DllCall("GetCurrentProcess")

jeeswg wrote:>>> ProcessIs64Bit
MsgBox % DllCall("IsWow64Process", "ptr", DllCall("GetCurrentProcess"), "int*", IsWow64) && IsWow64
[AHK] 1.1.30.03 x64 Unicode | [WIN] 10 Pro (Version 1903) x64 | [GitHub] Profile
Donations are appreciated if I could help you
just me
Posts: 6526
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Wish List 2.0

08 Sep 2017, 03:02

New features are outside the scope of AHK v2.0.
AutoHotkey v2 wrote:The focus of v2 is on changes that cannot be made in v1 due to backward compatibility. As such, new features which do not require a break in compatibility are outside the scope of v2. Most scripts written for AutoHotkey v1 will require some changes in order to run on AutoHotkey v2.
Helgef
Posts: 4008
Joined: 17 Jul 2016, 01:02
Contact:

Re: Wish List 2.0

08 Sep 2017, 03:10

Just me, I think 2.0 means that this is jeeswg's second wish list, not that these are intended (exclusively) for v2.
Jeeswg, I'll return if I have comments.

Cheers. :angel:
just me
Posts: 6526
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Wish List 2.0

08 Sep 2017, 03:18

Oops, I thought to be in the AutoHotkey v2 Development section. Sorry!
User avatar
jeeswg
Posts: 6841
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Wish List 2.0

08 Sep 2017, 03:21

@Helgef: Yes, you're quite right Helgef. I've added a title to the top to make it clearer. I had initially wanted the post to get straight into the action, no messing around. Looking forward to any responses.

@just me: Well, new features have been added though e.g. DirExist and Type. [EDIT:] No problem just me.

==================================================

@jNizM: Re. ProcessIs64Bit and A_ScriptPID. And A_ScriptNameNoExt/A_LoopFileNameNoExt which I didn't mention in the OP.

Re. ProcessIs64Bit. To check if a process is 64-bit:

Code: Select all

;To check if AutoHotkey is 64-bit:
MsgBox, % (A_PtrSize = 8)
;But for external processes you have to use OpenProcess e.g.:
JEE_ProcessIs64Bit(vPID)
{
	if !A_Is64bitOS
		return 0
	hProc := DllCall("kernel32\OpenProcess", UInt,0x400, Int,0, UInt,vPID, Ptr)
	DllCall("kernel32\IsWow64Process", Ptr,hProc, IntP,vIsWow64Process)
	DllCall("kernel32\CloseHandle", Ptr,hProc)
	return !vIsWow64Process
}
Re. A_ScriptPID. To get AutoHotkey's PID I use:
vPIDAhk := DllCall("kernel32\GetCurrentProcessId", UInt)
This was a subtle one re. whether to advocate for it, however I use this often enough, and I think for newbie friendliness and consistency with other AHK variables, a case could be made for its inclusion. My instinct would be to add it to AutoHotkey.

Two built-in variables I did consider, but didn't post above were:
- A_ScriptNameNoExt (for use with MsgBox/InputBox/GUIs)
- A_LoopFileNameNoExt
Because using SplitPath for this is inconvenient, even in AHK v2, since the outputs are ByRef variables, and not the direct output of a function.
However, a RegEx one-liner can obtain these:

Code: Select all

;path/name to name no extension
MsgBox, % vNameNoExt := RegExReplace(A_ScriptName, ".*\\|\.[^.]*$") ;remove dir and ext
MsgBox, % vNameNoExt := RegExReplace(A_ScriptFullPath, ".*\\|\.[^.]*$") ;remove dir and ext

;remove extension (path to path no extension) (name to name no extension)
MsgBox, % vNameNoExt := RegExReplace(A_ScriptName, "\.[^.\\]*$") ;remove ext
MsgBox, % vPathNoExt := RegExReplace(A_ScriptFullPath, "\.[^.\\]*$") ;remove ext
I did consider also, a sort of FileGetPart function, to pick one of SplitPath's output variables, but all of this can be done via a file loop or via RegExReplace, so I didn't feel it absolutely necessary. RegEx examples at:
jeeswg's RegEx tutorial (RegExMatch, RegExReplace) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=28031

Re. break/continue/return, yes that's true, but it only applies to return, and it only applies within functions.
One related thing that is possible: var1 := 1, var2 := 2, var3 := 3, Exit()
Last edited by jeeswg on 17 Feb 2019, 17:47, edited 1 time in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
SKAN
Posts: 384
Joined: 29 Sep 2013, 16:58

Re: Wish List 2.0

10 Sep 2017, 12:12

Nice list, jeeswg :)

Big-endian encoded number occurs mostly in files.
Something like: File.ReadHEX( Bytes ) would be very helpful.
While at it, I would also like to suggest File.BinSearch( needle as hex )
User avatar
jeeswg
Posts: 6841
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Wish List 2.0

12 Sep 2017, 08:07

@SKAN: Thanks for the positive comments. Yes, the idea re. BinSearch is interesting, perhaps similar to the RegExMatch 'ANSI mode' that I mentioned above.

Here's the best I have for binary search so far:
InBuf function currently 32-bit only (machine code binary buffer searching) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=28393
RegExMatch on binary data from FileRead - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=32393

==================================================

I've provided some example code here relating to FileSetText/FileEmpty. I suppose another approach would be to use AHK's FileDelete, and the GetFileTime/SetFileTime Winapi functions, if you wanted to keep the creation and/or modified dates.

Code: Select all

q:: ;file - empty file, set text, change encoding, keep original datestamps
vPath = %A_Desktop%\z %A_Now%.txt
FileAppend, % "version 1", % "*" vPath, UTF-8
FileGetTime, vDateM1, % vPath, M
Sleep 3000 ;to check that when we retrieve the modified date, it has the original date, not the date 3 seconds later
oFile := FileOpen(vPath, "rw")
;MsgBox, % oFile.Encoding ;e.g. CP1252/UTF-8/UTF-16
DllCall("GetFileTime", Ptr,oFile.__Handle, Int64P,vDateC, Int64P,vDateA, Int64P,vDateM)
oFile.Encoding := "UTF-16"
;oFile.Encoding := "UTF-8"
;oFile.Encoding := "CP0"
;oFile.Encoding := "CP1252"
oFile.Length := 0 ;empty file
if (SubStr(oFile.Encoding, 1, 4) = "UTF-")
	oFile.Write(Chr(0xFEFF)) ;oFile.Write overwrites characters
oFile.Write("VERS 2")
DllCall("SetFileTime", Ptr,oFile.__Handle, Int64P,vDateC, Int64P,vDateA, Int64P,vDateM)
oFile.Close()
FileGetTime, vDateM2, % vPath, M
MsgBox, % vDateM1 "`r`n" vDateM2
Run, % vPath
return
==================================================

[EDIT:] I've come up with a workaround script re. A_TimeIdlePhysical and ignoring mouse movement.
A_TimeIdlePhysical to detect any input but not mouse movement? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 50#p170250

[EDIT:] Btw Wish List 1.0 for anyone curious:
jeeswg's 3-item wish list (GUI class name+GUI no icon, A_ThisHwnd/A_ThisIfWinCriteria on hotkey launch, InputBox HFONT) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 13&t=26180
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6841
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Wish List 2.0

21 Sep 2017, 18:54

I've completed investigating issues relating to UInt64. It appears that you can specify UInt64 for DllCall/NumGet/NumPut, even though this is not stated explicitly for NumGet/NumPut. DllCall/NumGet/NumPut will then use/return an Int64.

It also appears that the Format command can already display an Int64 as a UInt64 (as dec or hex), but AFAIK AutoHotkey does not have a standard way to convert a dec/hex UInt64 number stored as a string to an Int64, although this can be done via mathematics and string manipulation.

I had wondered if Laszlo had said anything on the matter, and it turns out that indeed he had:
UInt64 <--> Int64: Using large unsigned hex/decimals - Scripts and Functions - AutoHotkey Community
https://autohotkey.com/board/topic/1688 ... xdecimals/
AHK cannot process UINT64 numbers directly. Literal integers larger than 2**63-1 are treated as overflow, and replaced by 0x7fffffffffffffff. If you get these numbers from other applications (like from majkinetor's hex viewer), you have to convert them to signed Int64 numbers, to let them wrap around (treating the leftmost bit as sign). After processing we can convert them back to UInt64. Here are functions for this.
Here is some collected code re. Int64/UInt64 issues.

Code: Select all

q:: ;UInt64 binary to Int64 number to UInt64 string
vText := Chr(65535) Chr(65535) Chr(65535) Chr(65535)
MsgBox, % NumGet(&vText, 0, "Int64")
MsgBox, % NumGet(&vText, 0, "UInt64")
vNum := NumGet(&vText, 0, "UInt64")
MsgBox, % Format("0x{:X}", vNum)
MsgBox, % Format("{:u}", vNum)
MsgBox, % JEE_FormatInt64(vNum)
MsgBox, % JEE_FormatInt64(vNum, "0x%I64X")

MsgBox
NumPut(-2, &vText, 0, "UInt64")
MsgBox, % NumGet(&vText, 0, "Int64")
MsgBox, % NumGet(&vText, 0, "UInt64")
vNum := NumGet(&vText, 0, "UInt64")
MsgBox, % Format("0x{:X}", vNum)
MsgBox, % Format("{:u}", vNum)

;doesn't work:
MsgBox
vNum := 0xFFFFFFFFFFFFFFFF
MsgBox, % vNum
MsgBox, % Format("0x{:X}", vNum)
MsgBox, % Format("{:u}", vNum)
MsgBox, % JEE_FormatInt64(vNum)
MsgBox, % JEE_FormatInt64(vNum, "0x%I64X")
return

w:: ;UInt64 string to Int64 number
;doesn't work:
MsgBox, % Format("0x{:X}", "0xFFFFFFFFFFFFFFFF")
MsgBox, % Format("{:i}", "0xFFFFFFFFFFFFFFFF")

;does work
x := "0xFFFFFFFFFFFFFFFF"
d := "18446744073709551615"
;code by Laszlo (modified to make it AHK v1/v2 two-way compatible)
MsgBox, % StrLen(x) < 18 ? x : (SubStr(x,1,StrLen(x)-1)<<4) + abs("0x" . SubStr(x,StrLen(x)))
MsgBox, % StrLen(d) < 19 ? d : SubStr(d,1,StrLen(d)-2)*100 + SubStr(d,StrLen(d)-1)
return

JEE_FormatInt64(vNum, vFormat:="%I64u")
{
	local vNum2
	VarSetCapacity(vNum2, A_IsUnicode?40:20, 0)
	DllCall(A_IsUnicode?"wsprintf":"sprintf", Str,vNum2, Str,vFormat, Int64,vNum)
	return vNum2
}
==================================================

[EDIT:] I had been concerned about bitshifting an Int into an Int64/UInt64, e.g. for POINT structures, but it turns out that AutoHotkey can already handle this situation.

Btw for a 'MakeUInt64' function (from low/high values), you have to be very careful re. the order in which you specify things, i.e. you have to remember the little endian nature of how the numbers are treated.

Code: Select all

q:: ;POINT structures e.g. WindowFromPoint and AccessibleObjectFromPoint
;vPosX := -1, vPosY := -1
;vPosX := 1, vPosY := 2
;vPosX := 0xFFFFFFFF, vPosY := 0xFFFFFFFF
;vPosX := 0xFFFFFFFE, vPosY := 0xFFFFFFFE
vPosX := A_ScreenWidth/2, vPosY := A_ScreenHeight/2

MsgBox, % (vPosX&0xFFFFFFFF)|(vPosY<<32)
MsgBox, % JEE_MakeUInt64(vPosX, vPosY)

hWnd1 := DllCall("WindowFromPoint", UInt64,(vPosX&0xFFFFFFFF)|(vPosY<<32), Ptr)
hWnd2 := DllCall("WindowFromPoint", UInt64,JEE_MakeUInt64(vPosX, vPosY), Ptr)
WinGetClass, vWinClass1, % "ahk_id " hWnd1
WinGetClass, vWinClass2, % "ahk_id " hWnd2
MsgBox, % hWnd1 " " vWinClass1 "`r`n" hWnd2 " " vWinClass2
return

;note: this actually returns an Int64 in AHK v1 (and probably in AHK v2)
JEE_MakeUInt64(vLow, vHigh)
{
	local vData
	VarSetCapacity(vData, 8)
	NumPut(vLow, &vData, 0, "UInt")
	NumPut(vHigh, &vData, 4, "UInt")
	return NumGet(&vData, 0, "UInt64")
}
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Helgef
Posts: 4008
Joined: 17 Jul 2016, 01:02
Contact:

Re: Wish List 2.0

27 Sep 2017, 17:51

Hello jeeswg, nice list, thanks for sharing your ideas :thumbup:. There are a few I don't get though :crazy: ;) .
Quite a few of the suggestions are probably trivial to implement in either script/binary code or ahk-source.

Cheers.
Helgef
Posts: 4008
Joined: 17 Jul 2016, 01:02
Contact:

Re: Wish List 2.0

31 Oct 2017, 13:15

helgef wrote:There are a few I don't get
For the sake of being fair, I will try to be more specific, and also make some comments :xmas:
I do not understand what is
  • Verbatim (or an alternative name)
    • Especially, but not limited to, a one-line continuation section
    • the options for creating certain strings, example?
  • SetAhkV2Mode, I understand the meaning, but I cannot realise the reason.
I comment on:
>> 'Could not close the previous instance of this script. Keep waiting?'
- make this error message less likely
Sounds like poor scripting, I (almost) never see that :D
I thought I would have more comments, I must have forgotten while reading. If I can cope, I might return :wave:

Cheers.

Edit
Regarding min/max functions, Ragnar-F has submitted such a function pair, see #84. :thumbup:
User avatar
jeeswg
Posts: 6841
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Wish List 2.0

31 Oct 2017, 15:12

- Verbatim
- There always comes a time when you need to paste text into a script verbatim. Sometimes it's convenience, sometimes it's necessity.
- var := "value" is great 90% of the time.
- var = value had some definite advantages, and could live on as a Verbatim 'command'.
- Continuation sections can achieve this, but you need 4 lines to define 1 line which is inconvenient.
- Continuation sections are also very inconvenient regarding script parsing and conversion, and for this reason I'm eliminating all continuation sections from my major scripts and using . "`r`n" instead. Ideally I would use . "`r`n" and a Deref function.
- The Verbatim command could be made more useful by adding some options, that make it, ironically enough, non-verbatim.
- One key usage would be for assigning paths e.g.

Code: Select all

Verbatim, "d%", vTarget, "%vPathExe%" "%vPath%"
Verbatim, "d{}", vTarget, "{vPathExe}" "{vPath}"
Verbatim, "d%", vTarget, "%obj.PathExe%" "%obj.Path%"
Verbatim, "d{}", vTarget, "{obj.PathExe}" "{obj.Path}"
Verbatim, "d%", vPath, %vDir%\%vNameNoExt%%vSfx%.%vExt%
Verbatim, "d% e1", vPath, C:\Users\%username%\Start Menu\Programs\Startup
- '"C:\MyFile"': single/double quotes can merge into each other. Indeed you can't tell whether it's single then double, or double then single. At least, you could tell if single quotes for assignments were dropped.
- The use of single quotes for assignments, a lot of people don't like this because they consider it unsightly. To be honest, AutoHotkey v2 would be better off without assigning text between single quotes, it's really really ugly. myvar := 'text'. I respect the rationale in introducing it, I believe it's fairly common in programming languages, however, I have had enough problems with parsing html because of the single/double quote duality, so I believe it would do more harm than good. Plus the rationale behind AutoHotkey version TWO, seems to be to prevent there being TWO ways of doing everything. [EDIT: I was basically joking here, I accepted a long time ago that single quote support would be added in.]
- When AutoHotkey or custom scripts parse the script, it's relatively straightforward to identify the Verbatim lines, which inevitably disobey some of the standard rules re. characters.
- See:
AHK v2 and strings - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 65#p173365

==================================================

- SetAhkV2Mode
- First of all the way InStr/SubStr/RegEx(Match|Replace) handle negative offsets was never ideal in my opinion, so this would fix AHK v1.
- Similarly A_OSVersion was flawed to use names and not numbers. Although I respect the rationale in making it newb-friendly. So this would again fix AHK v1.
- I don't know how feasible it would be to make Loop's behaviour variable, perhaps a directive is needed for this rather than a command, I'm not sure. However, I think people glibly underestimate sometimes the inconvenience of issues relating to conversion, and at the moment Loop is by far the biggest problem re. both conversion and two-way compatibility.
- I can replace commands with functions, but there are certain things I can't fix by myself. The way control flow statements/directives/functions work is beyond the user's control, plus other issues such as A_Args, double quote handling, a Deref function (variables and scope), and syntax generally.
- These changes would of course be very useful regarding two-way compatibility, otherwise you need some ugly workarounds:
- InStr:

Code: Select all

vIsV1 := !!InStr(1,1,1,0)
vPos := InStr(vText, vNeedle, 0, vIsV1-1)
Also things like RegExMatch with $ are workarounds.
- SubStr:

Code: Select all

vIsV1 := !!SubStr(1,0)
vOutput := SubStr(vText, vIsV1-4)

vOutput := SubStr(vText, StrLen(vText)-4+1)
Also things like RTrim or RegExReplace with $ are workarounds.
- RegExMatch:

Code: Select all

RegExMatch("", "", o)
vPfx := IsObject(o) ? "" : "O"
RegExMatch(vText, vPfx vNeedle, oMatch)

RegExMatch("", "", o)
vPfx := IsObject(o) ? "" : "O)"
RegExMatch(vText, vPfx vNeedle, oMatch)
- The sooner something like this were to be implemented, the sooner you could share good quality future compatible AHK v1 scripts without ugly workarounds. In effect I'm compromising my code at the moment, or over-thinking code, because I know how much bother it will cause newbs when they try to run/convert AHK v1-only scripts in AHK v2. I had thought about simply not submitting code to the forum until AHK v2 was released, but I believe my current approach is the lesser of two evils.

==================================================

- Min/Max
- That's great re. Min/Max, people are welcome to submit any of the proposals in Wish List 2.0 to GitHub.

==================================================
I (almost) never see that
Funnily enough, I've hardly seen it all recently. However, on my smaller laptop with hardly any resources, and sometimes when this PC's going at full pelt, all of the hotkeys stop working, and I often get that message when I try to reload scripts in such cases.

==================================================
If I can cope
Can't be as bad as when I attempted Puzzle 5.
Code Puzzle Thread - Page 2 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 22#p140122

Or reading the documentation on objects for the first time. #AChallenge.
Objects
https://autohotkey.com/docs/Objects.htm

Obviously I did a good job going over each item and clarifying it. Many thanks @Helgef.
Last edited by jeeswg on 07 Jan 2018, 00:37, edited 1 time in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
nnnik
Posts: 4279
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: Wish List 2.0

31 Oct 2017, 15:21

So instead of changing your language parser to properly parse your code you want to adjust the language?
Recommends AHK Studio
User avatar
jeeswg
Posts: 6841
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Wish List 2.0

10 Dec 2017, 11:29

- I will, at least I guess I will have to, extend my parser to handle any future syntax changes. The important point was to 'extol the vices' of single quotes, and yet at the same time, accept their arrival.
- Actually, adjusting the language due to parsing considerations, is a very important thing to do, and is a running theme behind some of the changes that are being made in AHK v2. Clearly, when you have situations where there are code lines that are ambiguous to parse, a lot of thought is put into that re. any necessary amendments to the syntax. I'm experiencing every tiny detail of script parsing, as I work on my script 'tidiers' and converters.

- Btw, while I'm here posting, I'd like to point out that although many of these suggestions are very simple, and can be made as custom functions, it's precisely their commonality that makes them candidates for inclusion as standard parts of AutoHotkey. Do I have to include functions XYZ, every time I want to do simple task ABC.
- The nature of anything is that things develop, and random simple obvious things (bits of functionality), get left out along the way. We could say for example that we could relegate WinGet-ProcessPath back to the status of custom function. Truncating numbers or repeating strings, these things are just so everyday, and for example, Excel has sheet functions for these. Before Format and StrReplace, some things were a real chore in AutoHotkey.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6841
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Wish List 2.0

07 Jan 2018, 00:53

Wish List 2.0: now simplified and restructured.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6841
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Wish List 2.0

15 Feb 2018, 17:37

Wish List 2.0: first half reordered, duplicated content reduced, occasional additional information/links added.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6841
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Wish List 2.0

07 Apr 2018, 00:15

I've added a 'BASICS' section, this is a collection of simple ideas mentioned elsewhere in the list, that are quite straightforward and uncontroversial. A core of suggested improvements to fill out AutoHotkey's functionality.

[EDIT:] Backup of BASICS section.

Code: Select all

==================================================

BASICS [ALSO LISTED LOWER DOWN]:

A_ VARIABLES
- A_AhkDir, A_AhkName
- A_AhkNameNoExt, A_LoopFileNameNoExt, A_ScriptNameNoExt
- A_CoordModeControl
- A_DlgTitle(/A_GuiTitle/A_DefaultTitle) (keep A_ScriptName read-only)
- A_ScriptPID

FUNCTIONS
- redefine a built-in function, but maintain access to the original

DATES
- DateAdd: add a Format parameter (default value: 'yyyyMMddHHmmss')

DIALOGS
- InputBox: Options parameter: specify HFONT:hFont
- InputBox: Options parameter: specify no Edit control (a MsgBox alternative)

FILES
- file loop: handle long filenames
- FileSetText (or FileWrite), and/or FileGetEncoding/FileEmpty

GUI
- GUI control objects: oGui.HwndParent
- GUI menu objects: specify menu item IDs (e.g. for use with accelerator keys and compatibility with other programs)
- GUI objects: oGui.Pos.B, oGui.Pos.R (bottom/right)
- GuiFromHwnd: take over a GUI window created via DllCall
- [bonus] GUI objects: create controls by class names, so 'Static' in addition to 'Text' and 'Picture'
- [bonus] GUI objects: increased support for setting the colour of a control (add it for more control types)

MATHS
- Between: e.g. Between(vNum, vLim1, vLim2)
- Ceil/Floor: a Places parameter consistent with Round

OBJECTS
- Count method

REGISTRY
- RegCreateKey

SEND
- [bonus] Send: combine Send/ControlSend AHK v2 functions
- [bonus] Send: {Event}/{Input}/{Play}/{Sleep n} options

SORT
- support for stable sort (a variable to make it default: A_SortMode/A_SortStable)
- [bonus] handle a linear array

STRINGS
- StrJoin
- StrRept StrRept StrRept
- SubStr: a blank Length parameter to mean infinity (equivalent to omitting the parameter)
- [bonus] FileGetPart (or another name): e.g. FileGetPart(vPath, "n") to get name, (n/d/x or e/nnx or nne/dr/pnx or pne)
- [bonus] StrCount
- [bonus] StrJoinReverse

WINDOWS/PROCESSES
- ControlGetFocusHwnd
- ProcessIs64Bit
- WinGetOwner, WinSetOwner
- WinGetParent, WinSetParent
- window criteria: ahk_dhw (V/VH/H) (DetectHiddenWindows)
- window criteria: ahk_mode (S/C/X/E/R) (SetTitleMatchMode) (E: ends)

WINDOWS (PIXELS)
- [bonus] PixelGetColor/PixelSearch: BGR option in AHK v2
- [bonus] and/or RGBToBGR function, perhaps with ARGB to BGRA option
- [bonus] or a swap bytes function

BACKPORT
- #SuspendExempt
- A_AllowMainWindow, A_IconHidden, A_IconTip
- A_InitialWorkingDir
- DateAdd, DateDiff
- DirExist
- FileInstall
- (writable 'A_' variables)

==================================================
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6841
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Wish List 2.0

01 Sep 2018, 00:41

- I have done a complete overhaul of the wish list in the OP.
- Here is a backup copy of the old one:
Spoiler
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6841
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Wish List 2.0

01 Oct 2019, 08:52

- The list hasn't changed much in the past year.
- However, I have reordered the initial content using 'IMPORTANT' sections.
- And I have reviewed the entire document, clarifying occasional points.

- With long path support added in AHK v1, my remaining priorities are generally pretty simple to implement. (And I've shared C++ code for most of them.)
- Things like IsInit/VarIsInit, A_ChrSize (2/1), StrSetCapacity (TChars) (cf. VarSetCapacity (bytes)), A_WA (W/A) would see massive productivity gains.
- I keep finding that having var `= value (AHK v1 style) one-liners could be very useful for assigning command-line strings in AHK v1/v2, for use with Run.
- Having built-in function equivalents for contains/in/is, in AHK v2, could be very advantageous for making old code forwards compatible, avoiding ugly workarounds, and making code easier to translate to other languages. (Coding is also eased by being able to do comparisons, all via functions, or all via operators.)
- If possible, something like IsPassed for AHK v1/v2 would be really useful, to know if a function parameter was passed or not (similar to IsByRef).
- One key stumbling block is Loop. I've suggested Loop (Count) and LoopXXX to make Loop completely two-way compatible. They could come with a warning in AHK v1, to not expect the functionality to be finalised, until AHK v2 is finalised.

- Enjoy. ;)
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 10 guests