Wish List 2.0

Propose new features and changes
User avatar
jeeswg
Posts: 5266
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: 2018-11-10]
[note: this list is regularly tweaked, so I would recommend taking a copy and using WinMerge to check for changes]

MOST PRESSING CHANGES

SYNTAX (TWO-WAY COMPATIBILITY)
> LOOP
> BACKPORT
> ASSIGN TEXT (SINGLE LINE)
> ASSIGN TEXT (MULTI-LINE) (CONTINUATION SECTIONS)

SYNTAX
> 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/X/E/R)
> CONTAINS/IN/IS OPERATORS

Also:
IsPassed or A_ThisFuncParams.HasKey() or equivalent
StrJoin and/or ObjToString [print keys/values]

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

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/X/E/R)
> CUSTOM FUNCTION/CLASS DIRECT TO OBJECT
> ONE FUNCTION, MULTIPLE NAMES
> BINARY NUMBERS
> OPERATORS
> ONE-LINERS: IF A THEN B
> ONE-LINERS: MULTI-STATEMENT WITH BREAK/CONTINUE/RETURN
> 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
> COMPATIBILITY DIRECTIVE/FUNCTION

>> DEBUGGING

>> PROTOTYPE FUNCTIONS
>> MINOR SUGGESTIONS
>> 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] ATan2(NumY, NumX)
- [NEW] Between(Num, Lim1, Lim2) [x <= y <= z, chained operators, would be fiddly and add ambiguity, although they could be used within StrOp/NumOP functions where 5 items implies a ternary operator]
- [NEW] IsNum(Num) [if looks numeric] [a 2nd Options parameter could be added, such that only variables of Float/Integer type would qualify]
- [NEW] NoOp(Params*)
- [NEW] Num(Num, Default:="") [cf. Integer/Float][if doesn't look numeric, error, unless default value is specified]
- [NEW] Pow(Num, Power) [useful for changing an array's default value, and for use with libraries that are maintained across multiple programming languages cf. mod operator]
- [NEW] Sign(Num)
- [NEW] StrCount(Haystack, Needle, CaseSen:=0, StartPos:=1) [or omit the StartPos parameter for now]
- [NEW] StrJoin(Sep, Params*) [perhaps accept a linear array to have an alternating separator]
- [NEW] StrRept(Text, Num)
- [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]
- [MODIFY] Sort [add a stable sort option, and a variable to make it default: A_SortMode(/A_SortStable)]
- [MODIFY] Sort [handle linear arrays]
- [MODIFY] StrGet/StrPut [handle hex and base64]
- [NEW] BaseToDec/DecToBase (Num, Base) [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] ControlGetHwndRegEx(/ControlGetClassNNRegEx) [or better: 'ahk_mode R' could be added for Control/WinTitle parameters, for pattern-based but inconsistent class names]
- [NEW] Range [for a traditional for loop, and for doing mathematics (populating an array)][for i = a to b (step c)]

FUNCTIONS (DIALOGS)

- [MODIFY] InputBox [Options parameter: specify no Edit control (useful for writing a custom MsgBox function)]
- [MODIFY] InputBox/ToolTip [an option/variable to specify the font name/*size*/weight or hFont, or perhaps: Options parameter: specify HFONT:hFont]
- [MODIFY] Progress/SplashImage [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] Progress/SplashImage/SplashTextXXX/ToolTip [option to make the window timeout]

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 window)]
- [MODIFY] SubStr [a blank Length parameter equivalent to omitting parameter]

FUNCTIONS (FURTHER)

- [ADD PARAM] DateAdd(DateTime, Time, TimeUnits, Format:="yyyyMMddHHmmss") [Format]
- [ADD PARAM] FileGetShortcut(LinkFile, OutTarget, OutDir, OutArgs, OutDescription, OutIcon, OutIconNum, OutRunState, OutShortcutKey) [OutShortcutKey][cf. FileCreateShortcut]
- [MODIFY] DateAdd [allow add months (e.g. + 3 months: 31 Jan -> '31 Apr' -> 30 Apr)]
- [MODIFY] FormatTime [if possible, fix 'date and time elements together, they must not be intermixed']
- [MODIFY] Send ['{Sleep n}' option]
- [NEW] MCeil/MFloor/MRound (Num, Mult) [round to nearest multiple]
- [NEW] MemCopy(/NumCopy/BinCopy) (Dest, Source, Size) [cf. RtlMoveMemory/memmove]
- [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] WinGetOwner/WinGetParent ([WinTitle, WinText, ExcludeTitle, ExcludeText])
- [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][oFile.HexRead might also be useful]
- [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), FileGetEncoding(Path)
- [NEW][FURTHER] FileGetPart(Path, Part) [or PathGetPart]
- [NEW][FURTHER] FloorMod(Dividend, Divisor) [when Divisor is positive, return value is positive(/zero)]
- [NEW][FURTHER] ProcessGetCommandLine(PIDOrName)
- [NEW][FURTHER] ProcessIsAdmin(PIDOrName) (or ProcessIsElevated)
- [NEW][FURTHER] ProcessIs64Bit(PIDOrName)
- [NEW][FURTHER] RegExMatchAll [at least a custom function in the documentation]
- [NEW][FURTHER] StrSetCapacity(Var, CapacityChars, FillChar) [possibly also: StrGetCapacity]
- [NEW][FURTHER] VarSetSize(Var, Size, FillByte) [possibly also: VarGetSize/SizeOf (and VarGetCapacity)]
- [RENAME] Integer -> Int
- [RENAME] String -> Str

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

>> 'A_' VARIABLES

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

- [FURTHER] A_OParen/A_CParen/A_SQ [ ( ) ' ]
- A_AhkDir/A_AhkName/A_AhkNameNoExt
- A_ChrSize/A_WA [2 or 1, W or A]
- A_Comma/A_DQ [ , " ]
- A_LoopFileAttribValue
- A_LoopFileNameNoExt
- A_LoopFileTimeAccessedUTC/A_LoopFileTimeCreatedUTC/A_LoopFileTimeModifiedUTC
- A_Recent [Recent folder]
- A_ScriptNameNoExt
- A_ScriptPID

'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]
- A_InputBoxResult [easier to replace 'if ErrorLevel', avoid ugly use of a ByRef InputBox parameter]
- A_MsgBoxResult [easier to replace 'IfMsgBox']
- A_OSVersionMain(/A_OSMainVersion) [e.g. 5.1/5.2 (XP), 6.0 (Vista), 6.1 (Windows 7)]
- A_SortMode(/A_SortStable) [stable sort for Sort]
- OnEdit (or 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]
- InputBox/ToolTip: perhaps a variable/object to set the InputBox/ToolTip font size/properties (or an object with multiple keys) e.g. A_InputBoxFontSize, A_ToolTipFontSize
- 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)
- Format: A way to change '{}' to other characters temporarily e.g. A_FormatChars

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

>> 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'

Code: Select all

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
- 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/X/E/R)

- Since the letters HV and CERSX don't overlap, ahk_mode 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/X/E/R is seen.

- 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/X/E/R): starts/contains/exact/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 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)

- useful for #If
- useful to avoid the repeated use of A_DetectHiddenWindows/DetectHiddenWindows and A_TitleMatchMode/SetTitleMatchMode
- useful since many window 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 ... 14&t=30010

> CUSTOM FUNCTION/CLASS DIRECT TO OBJECT

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

Code: Select all

oFunc := NewFunc(arg1, arg2, arg2)
{
	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

> 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
}
> BINARY NUMBERS

Code: Select all

vNum := 0b10001 ;17 = 16 + 1
vNum := 0b101010 ;42 = 32 + 8 + 2
> OPERATORS

- if (a op1 b) [a finite set of redefinable binary operators e.g. 10, based on 2-parameter functions]
- if (a starts b)
- if (a ends b)
- if (a mod b) [perhaps 'mod', since perhaps '%' would cause syntax confusion][very useful when converting to/from AutoHotkey, true for Pow() also][mod operator]
- // (always floor division)
- idiv (integer division) (or some other symbol)
- <> (I would hope to keep this with the AHK v1 behaviour)
- (make it possible to preserve formulas from other programming languages intact)
- also: contains/in/is for AHK v1/v2

> ONE-LINERS: IF A THEN B

- perhaps: if a then b

> ONE-LINERS: MULTI-STATEMENT WITH BREAK/CONTINUE/RETURN

- return/continue/break in multi-statements
- e.g. before the script runs, the original code:

Code: Select all

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

Code: Select all

{
	var1 := 1, var2 := 2, var3 := 3
	return
}
- allow lines of the form 'comma + control flow statement' in AHK v1/v2, as the move to functions in AHK v2 already makes possible multiple lines started by commas, and to avoid unnecessary curly braces, and to quickly add lines to code without needing to add curly braces
- such code is very tempting to write in AHK v2 where most lines can be preceded with a comma
- or perhaps allow them at the end of a (comma-separated) multi-statement

Code: Select all

Loop
{
	if cond1
		var := 1
		, MyFunc()
		, continue
	else if cond2
		var := 2
		, MyFunc()
		, break
	else if cond3
		var := 3
		, MyFunc()
		, return
}
> GUIS (GRAPHICAL USER INTERFACES)

- GUI objects: oGui.B / oGui.R (or oGui.Pos.B / oGui.Pos.R) (bottom/right)
- GUI control objects: oGui.HwndParent
- [KEY] GUI menu objects: specify menu item IDs (e.g. for use with accelerator keys and compatibility with other programs)
- GUI objects: perhaps increased support for setting the colour of a control (add it for more control types)
- support for accelerator keys ('soft' hotkeys that can be overriden by other scripts, cf. 'hard' hotkeys)

- For reference:
GUI - Complete Command & Property Listing - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 29#p213529

> #INCLUDE

- something like the following (the names aren't important):
- #IncludeAtEnd: insert code at the end of the script, rather than at the current point in the script
- #IncludeIfArgContains: include a file if the nth command-line parameter contains a certain string
- /inc switch: include files via the command line
- #IncludeNoAuto (or #IncludePrevent/#IncludeBlock): prevent any files from being auto-included, all files would require an explicit include
- or perhaps #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 not currently part of AHK)

> 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]
- ObjRawGet/ObjRawSet to make it possible to create/read integer key names with String type in AHK v2 (AHK v1 already allowed this)

> THOUGHTS FOR V2.0

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

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

- I mention some points re. ControlXXX functions here:
ControlXXX functions - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 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
- `s: support for `s in hotstrings in AHK v2 [`s is supported everywhere else AFAIK]
- [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)'

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

>> 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]
LoopRead InputFile [, OutputFile]
LoopReg KeyName [, Mode]
- perhaps allow: for vKey, A_LoopField in oArray

> ASSIGN TEXT (SINGLE LINE)

[on balance, I view this simple approach as the best way forward:]

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.
And if that was not sufficient, and verbatim text or something else was needed, a continuation section could be used.

[alternatively]

- a special 'command'
- an Options parameter, with a wide range of special options
- with some options, similar to AHK v1: vTarget = "%vPathExe%" "%vPath%"
- E.g.

Code: Select all

Assign Var, Opt, Text
Assign vTarget,, notepad.exe "C:\MyDir\MyFile.txt"
Assign vTarget,, notepad.exe "%A_ScriptFullPath%"
Assign vTarget,, "%vPathExe%" "%vPath%"
Assign vList,, abc,def,ghi,jkl,mno,pqr,stu,vwx,yz
Assign vText,, my html/SQL/command line/AHK code/general string with ' and "
- More details:
AHK v2 and strings - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 65#p173365
- note: the post also considers Format handling variable/object key names

> 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)

> CONTAINS/IN/IS OPERATORS

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

- I am unsure whether contains/in should treat a string as one item or a comma-separated list [I'm tempted to say one item]

- [KEY] if they treat a string as one item, some handy syntax for handling a comma-separated/pipe-separated list string should be considered
- 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 ... 22#p247622

> BACKPORT

- #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)

- also: DateAdd/DateDiff, DirExist

- further: FormatTime function [to avoid unreliable 'A_' variable concatenation], MsgBox function, Type, WinGetList
- further+: ControlGetList ('ControlGetItems')/WinGetControls/WinGetControlsHwnd, InputBox function, 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 ... 42#p131642

> COMPATIBILITY DIRECTIVE/FUNCTION

- e.g. SetAhkV2Mode function/directive (make AHK v1 more like AHK v2)
- a function and/or directive
- one mode, or granular settings, on/off, to make certain things function in AHK v1 more like they do in AHK v2
- [KEY] double quotes: disallow "" but do allow `"

- Also:
- 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: 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]
- Loop: use expression style parameters [not needed if LoopXXX and Loop (Count) are introduced]
- A_OSVersion: always return a number, not a friendly name ('WIN_XXX') [not needed if A_OSVersionMain introduced]

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

>> DEBUGGING

- 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)

- 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

- 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

- 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?'
- e.g. longer retry periods
- e.g. MsgBox only once (and if fail, terminate the process and reopen)
- (it would be useful to understand why sometimes this box can appear 10 times, and then finally work)

- 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 ... 35#p175935
- perhaps a 'Print' menu item, an area where things are printed

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

>> PROTOTYPE FUNCTIONS

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

- 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 pursuing.
- If super-functions aren't created, simpler building block functions would facilitate short readable code for sharing on the forum. E.g. NumOp(a, op, b) or StrOp(a, op, b), where you can specify an operator dynamically.

- SORT
- stable sort e.g. alphabetise
- null sort e.g. reverse (null sort + existing R option = reverse without sorting)
- specify no delimiter (sort characters) e.g. alphabetise/randomise/reverse
- handle linear array
- remove duplicates without sorting
- (or perhaps: StrAlphabetize/StrRandomize/StrReverse) [or StrShuffle]
Sort function + extra features - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=50431

- IN/CONTAINS/STARTS/ENDS(/STRMATCH)
- faster than RegEx (^exact$/contains/^starts/ends$)
- no RegEx escaping issues
- case sensitivity option
- numeric/string comparison option
- (or perhaps: StrContains/StrExact, StrStarts/StrEnds)
simplest way to make a RegEx needle literal? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 11#p169211
if var in/contains comma-separated list/array - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 22#p209222
Improve InStr or IfInString - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 13&t=31812

Code: Select all

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

StrMatch(vHaystack, vNeedles, vOpt, ByRef vMatch)
- HEX AND BASE64
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

[ControlGetHwndRegEx(/ControlGetClassNNRegEx)]
Being more generic when using WinActivate and ControlSetText - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 24#p186624

[DateGet][or A_NowMSec/A_NowMSecUTC][or A_MSecLast, the milliseconds at the time you last retrieved A_Now]
- you cannot reliably do vDate := A_Now A_MSec
- or concatenate any date variables
A_ variables - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 46#p191046

[FileGetPart]
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 ... 37&t=45220

[ProcessIsAdmin/ProcessIsElevated]
How to check if active window runs as admin? - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 26#p197426

[Range][traditional for loops]
For loop question - Ask for Help - AutoHotkey Community
https://autohotkey.com/board/topic/6691 ... ntry423515
traditional for loop: for i = a to b (step c) possibilities - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=43022

[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 ... 12#p198312

[StrRept/StrCount]
StrRept and StrCount - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 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]
swap bytes - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=47081

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 ... 83#p214283

LINKS TO PROTOTYPE FUNCTIONS (C++)

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

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

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

>> MINOR SUGGESTIONS

MINOR SUGGESTIONS (DESERVE AT LEAST A MENTION):
- [note: some are not recommended as wish list requests]
- '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
- A_Bitness (or something like it) to give 64/32, otherwise 64/86, which might be useful for use with #Include
- 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)]
- 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)
- A_ThisHotkeyHwnd: the matching (e.g. active) window at the time the hotkey was triggered
- A_ThisHotkeyRaw (hotkey names with/without the leading *~$) (could also apply to hotstring, to strip the leading ::/:*: etc)
- 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.
- Combin/Permut functions (that can handle with/without repetitions).
- ControlGetFocusClass/ControlGetFocusClassNN/ControlGetClass
- Deref function
- delay: a general delay between line executions that can be turned on and off, e.g. Run Sleep Run Sleep
- FileGetBitness/FileGetInfo/ProcessGetBitness/ProcessIs64Bit: determine if a process/exe/dll is 64-bit/32-bit/16-bit
- FileSetText(/FileWrite) function (and/or 'FileEmpty'/'FileGetEncoding' functions)
- FloorDiv(Num1, Num2) and IntDiv(Num1, Num2) [note: Floor(Num1/Num2) and Integer(Num1/Num2) are already possible]
- for loop: a symbol, that if used for the key, prevents a variable being created for it: e.g. for ~, vValue in oArray
- 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
- 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)
- 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)
- GUI: create a control by specifying 'Static' rather than 'Text' or 'Picture', this always catches me out
- 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)
- hotstrings: special hotkeys: define a hotkey/hotstring the same way you would define a Send line
- if (var is "ascii") equivalent to: vIsAscii := !RegExMatch(vText, "[^[:ascii:]]")
- InStrRev function: like InStr but that would search in reverse and accept positive values for positions
- integers: 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)
- NumGet/NumPut: remove ByRef handling, expect an address as StrGet/StrPut do (old scripts would trigger an error message)
- objects: %class%: obj := new %class%, perhaps a blank or other string to create a built-in array
- OnWarn: specify a function to handle warnings (however, some messages would occur before the script had started)
- panic button: support(/documentation guidance) to help stop a script, start/stop a hotkey subroutine (with the same hotkey/with different hotkeys)
- PathGetCorrectCase function
- 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
- Send: {Event}/{Input}/{Play} options
- Send: combine Send/ControlSend AHK v2 functions [or: optional control/window parameters for Send]
- #SingleInstance prompt (or dialog): explicitly specify to show a dialog box (the default behaviour when #SingleInstance is not used)
- StatusBarGetText: option to specify a control other than 'msctls_statusbar321'
- StrJoinReverse (could be handled by an improved Sort function and StrJoin instead)
- StrReplace: perhaps allow StrReplace's SearchText/ReplaceText parameters to accept objects, 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
- VarGetCapacity
- WinClick
- 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 ... 13&t=26180

Thanks for reading.

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

>> MY WISHED LIST (MY WISH CAME TRUE)

MY WISHED LIST (MY WISH CAME TRUE) 1 OF 3

MOST PRESSING CHANGES:
- assume local: cf. assume global, the word local by itself in the function would mean that all non-parameter variables not declared as global are assumed local [KEY: this is probably the most important idea on this list.]
- #Include: support more 'A_' variables (A_Desktop, A_AhkPath, A_UserName, possibly 'A_Args##') [KEY: users can't implement this]
- file loop: handle long paths (when listing files/backing up files etc, there's no particular reason to omit files/subfolders with long paths) [otherwise users could unexpectedly fail to back up/copy files/folders]

PRIORITY - INCREASE FUNCTIONALITY:
>>> #Include: support more 'A_' variables [also mentioned by other people]
- support: A_Desktop, A_AhkPath, A_UserName, possibly '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' or '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
[IMPLEMENTED AS: 'Added support for all built-in variables in #Include.' 'All built-in variables are valid, except for ErrorLevel, A_Args and the numbered variables.']

FURTHER:
>>> Hotstring function
- a function to create hotstrings dynamically cf. the Hotkey command

BRING OVER CERTAIN AHK V2 ADDITIONS TO AHK V1:
- A_Args
- A_ComSpec

BRING OVER CERTAIN AHK V2 ADDITIONS TO AHK V1:
When loops are finalised in AHK v2:
- A_LoopFilePath

MINOR SUGGESTIONS (ALSO COVERED IN THE A_ VARIABLES THREAD):
- A_TimeIdlePhysical: option to ignore mouse movements, i.e. the value is not reset to 0 by mouse movements
[IMPLEMENTED AS: A_TimeIdleKeyboard and A_TimeIdleMouse.]

MINOR SUGGESTIONS:
- Min/Max functions: get the smallest/biggest number in a list: Min(a,b) cf. (a<b?a:b)
- hotstrings with colons: make all hotstrings possible, at present, some hotstrings containing colons can't be created (perhaps some way to escape colons for hotstrings)
- WinWait/WinWaitActive functions in AHK v2: return an hWnd.

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

MY WISHED LIST (MY WISH CAME TRUE) 2 OF 3

LONG DESCRIPTIONS

>>> objects: count keys [also mentioned by other people]
- count all of the keys within an object (i.e. with numeric or string names)
- e.g. an 'ObjCount' function, possibly an obj.Count() method
- or an additional parameter added to ObjLength
- e.g. when listing the keys/values in an object, ObjCount could help you prepare a large enough variable
- also, perhaps an obj.Len() method could be added to standard arrays cf. obj.Length()

>>> file loop: handle long paths
- allow file loops to handle long paths (perhaps by specifying the '\\?\' prefix, or having an 'L' option cf. 'FDR')
- when backing up/moving files/getting file info/trying to list files with long filenames, there is no reason why long filenames (and long folder names) should be excluded from the results
- arguably the current behaviour is newbie-unfriendly and breaks the principle of least astonishment
- note: long name support was added for AHK's registry loops (v1.0.48 - February 25, 2009)

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

MY WISHED LIST (MY WISH CAME TRUE) 3 OF 3

CHANGES THAT I THOUGHT ABOUT BUT DIDN'T ADD TO MY LIST (OR MENTIONED ELSEWHERE):
- note: for AHK v1, AHK v2, or both
- Changed a-z to mean vk41-vk5A when absent from the keyboard layout, except with Raw mode or when sending single unmodified characters. This allows hotkeys and sent keyboard shortcuts to work more intuitively on certain non-English keyboard layouts.
- Added {Text} mode for Send and T option for hotstrings. These are like the Raw mode, but more reliable.
- Replaced A_CaretX/Y with CaretGetPos(x, y).
- [AHK v2] Changed bitwise-NOT (~) to always treat number as 64-bit.
- [AHK v2] Changed string->integer conversion to allow overflow consistent with arithmetic operations. ... now true: ... 0xFFFFFFFFFFFFFFFF == -1
- Added A_ListLines.
- Added hotstring E option to execute instead of auto-replace. [it's now X]
- Changed WinMenuSelectItem to treat menu 0& as the window's system menu.
- Added MaxParts parameter to StrSplit.
- Added WinGetClientPos.
- Added Hotstring("Reset") for manually resetting the hotstring recognizer.
- Fixed Control ChooseString to send WM_COMMAND even if the control's ID is 0. [e.g. to notify Notepad's Save As dialog]
- Added ObjGetBase(Obj) and ObjSetBase(Obj, BaseObj).
- Added ObjRawGet(Obj, Key).

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

MY WISHED LIST (MY WISH CAME TRUE) OCT 2018

[implemented as: ControlGetFocus][the old ControlGetFocus became ControlGetClassNN]
- [NEW] ControlGetFocusHwnd([WinTitle, WinText, ExcludeTitle, ExcludeText]) [or ControlGetHwnd could return the focused control if Control omitted/blank, not the topmost control]

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

MY WISHED LIST (MY WISH CAME TRUE) NOV 2018

[bug fix] Fixed Control Choose to send WM_COMMAND even if the control's ID is 0.
[bug fix] Fixed `` escape sequence preceding a ; comment flag.

==================================================
Last edited by jeeswg on 11 Nov 2018, 02:00, edited 347 times in total.
User avatar
jNizM
Posts: 2333
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: Wish List 2.0

08 Sep 2017, 02:00

>>> 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

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

>>> ProcessIs64Bit
MsgBox % DllCall("IsWow64Process", "ptr", DllCall("GetCurrentProcess"), "int*", IsWow64) && IsWow64
[AHK] 1.1.30.00 x64 Unicode | [WIN] 10 Pro (Version 1803) x64 | [GitHub] Profile
Donations are appreciated if I could help you
just me
Posts: 5573
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.
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: 3221
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: 5573
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: 5266
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, PtrP,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()
User avatar
SKAN
Posts: 320
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: 5266
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
User avatar
jeeswg
Posts: 5266
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")
}
Helgef
Posts: 3221
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: 3221
Joined: 17 Jul 2016, 01:02
Contact:

Re: Wish List 2.0

31 Oct 2017, 13:15

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: 5266
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.
User avatar
nnnik
Posts: 3453
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: 5266
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.
User avatar
jeeswg
Posts: 5266
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.
User avatar
jeeswg
Posts: 5266
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.
User avatar
jeeswg
Posts: 5266
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)

==================================================
User avatar
jeeswg
Posts: 5266
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

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 5 guests