==================================================
[updated: 2017-01-25][multiple changes]
KEY 1: GUI SPECIFY CLASS NAME AND NO ICON
- GUI (create GUI specifying a custom class name and no icon, or possibly a WNDCLASS struct).
One could say that it doesn't matter if: you can have any GUI class name as long as its AutoHotkeyGUI. And that now that AutoHotkey has ahk_exe it's less needed. In short, this feature is absolutely necessary, and I have seen similar features addressing related GUI problems added in, and I believe the code complexity is at the very simplest end of the scale. I've made GUIs via Winapi from scratch and it's just the WNDCLASS parameters that determine the class name and icon (specify HICON 0 for no icon).
- This speech is my recital, this feature's very vital ...
It's tricky to GUI, to GUI with no icon, it's tricky. -
==================================================
KEY 2: GET HWND OF WINDOW THAT MATCHES #IFWIN CRITERIA
- A_ThisHwnd (cf. A_ScriptHwnd, A_ThisHotkey) and A_ThisIfWinCriteria.
For safety, every script should absolutely confirm that the active hWnd matches the #IfWin criteria before proceeding. One script I have has 486 hotkeys, and code such as that below, should be added to every hotkey, which is made more complicated when multiple #IfWin criteria point to the same subroutine:
Code: Select all
#IfWinActive, ahk_class IEFrame
^q::
WinGet, hWnd, ID, A
WinGetClass, vWinClass, % "ahk_id " hWnd
if !(vWinClass = "IEFrame")
return
- Load up on class, bring your winds. -
==================================================
KEY 3: INPUTBOX LARGE FONT
- InputBox (take HFONT in Font parameter) (cf. HBITMAP/HICON and ImageSearch/SplashImage, see Image Handles in Help).
Workarounds:
- Use a Progress window, but these will be removed in AutoHotkey v2.
- Use a GUI, but I want a big InputBox for all my scripts, and GUIs cause persistence, and must have a number [EDIT: or name, I knew this but deliberately left it out] that doesn't clash with existing GUIs. (Re. clash the Gui command added a 'GuiHwnd%:Default' option.)
- Have a secondary script that resets the fonts to bigger, however this can cause a slight delay in the InputBox appearing, and text is not sent to it. Or you press enter to close it, but the text didn't arrive in time.
- Hack the AutoHotkey.exe, I tried to but it didn't work.
- Create an InputBox via GUI functions, DllCall, I haven't perfected this yet, and it interferes with the message queue.
- A workaround provided like that that was provided for ToolTips?
- Oh Lord, won't you buy me a box with large text.
I bet AutoIt has it, we must make amends. -
==================================================
ADD PARAMETERS TO EXISTING FUNCTIONS/COMMANDS:
To end annoying issues in relation to A_StringCaseSense and A_DetectHiddenWindows.
StrReplace: add CaseSensitive parameter,
before/after:
OutputVar := StrReplace(Haystack, SearchText, ReplaceText, OutputVarCount, Limit)
OutputVar := StrReplace(Haystack, SearchText, ReplaceText, OutputVarCount, Limit, CaseSensitive)
[EDIT: a good solution to this is the ahk_dhw proposal][0/1/2 V/VH/H]
WinGet's List subcommand: add Visible(0)/Both(1)/Hidden(2) parameter,
before/after:
WinGet, OutputVar, Cmd, WinTitle, WinText, ExcludeTitle, ExcludeText
WinGet, OutputVar, Cmd, WinTitle, WinText, ExcludeTitle, ExcludeText, Mode
[EDIT: a good solution to this is the ahk_mode proposal][1/2/3/RegEx S/A/E/R][start/anywhere/end/RegEx]
IfWinActive: add TitleMatchMode parameter:
IfWinActive, WinTitle, WinText, ExcludeTitle, ExcludeText
IfWinActive, WinTitle, WinText, ExcludeTitle, ExcludeText, TitleMatchMode
==================================================
CAN BE DONE VIA CUSTOM FUNCTIONS BUT SEEM LIKE NATURAL AUTOHOTKEY COMMANDS/FUNCTIONS
- File loops (handle long filenames when path needle begins with \\?\). (I've done the work, I've tried to program this.)
- Registry loops (alphabetical order option). (Imagine shuffling the entire backwards-collected registry back into order, I've tried to write functions for this.)
- StrStarts/StrEnds: if var starts/ends. (I have my own functions that do this, it's so frequently useful.)
- StrRept (cf. Loop and append via :=).
- StrCountOcc (cf. StringReplace and UseErrorLevel). [EDIT: Or simply StrCount.]
- Dec2Hex (and also Hex2Dec) [EDIT: The Format function can do this although it is a little unwieldy for this particular task.]
==================================================
AUTOHOTKEY COMMANDS/FUNCTIONS/VARIABLES (ADDITIONAL):
- A_Recent, path of Recent folder.
- A method to set an 'A_' variable globally, that will work if the special variable doesn't exist, and that will have no effect if the special variable does exist. [EDIT: I.e. so that the same script can be used on older and newer versions: use the 'A_' variable if it exists, or create a custom global variable if it doesn't.
- Allow defunct directives/commands to reside in a script without crashing the script, and if commands are called upon, to do nothing (to act like dummy commands). [EDIT: E.g. #NoEnv]
- A_NowMSec / A_NowMSecUTC, because %A_Now%%A_MSec% is unreliable. [EDIT: Provide an example function in the documentation. See topic: 'log hotkeys, get extended hotkey info, interact with the *right* window'.][EDIT: See topic: 'jeeswg's documentation extension tutorial']
- To another script: hide/show tray icon. Get Icon/NoIcon status of another script. [EDIT: Use TrayIcon.ahk or JEE_TBButtonSetVisible to hide the systray icon.]
- Add Open Containing Folder to a tray icon's menu. (Less needed now that the Recent menu has 'Open file location'.) [EDIT: See topic: 'Setting tray icon; detecting pause/suspend.']
- NumCopy to copy large amounts of data from one variable to another. Optimised default function or an explanation in the help file. [EDIT: Provide an example function in the documentation. E.g. RtlMoveMemory or memmove.][EDIT: See topic: 'jeeswg's documentation extension tutorial']
==================================================
AUTOHOTKEY V2: [RESOLVED]
[Turns out AutoHotkey v1 can already do this since v1.1.09.]
Add the ability in AutoHotkey v1 to assign default values for functions via := as well as =, in order to make it forwards compatible with AutoHotkey v2, and allow for two-way compatible library scripts.
==================================================
AUTOHOTKEY V2 (ADDITIONAL):
Variables that would avoid the need for the most drastic of script conversion issues.
[EDIT: I now favour the InStr1/InStr2, SubStr1/SubStr2 approach, as it avoids ambiguity and is a trivial text conversion.]
An 'AutoHotkey v1' negative offset global variable which can turn the following off:
- A negative StartingPos for InStr, SubStr, RegExMatch and RegExReplace is interpreted as a position from the end, starting at 1. Position -1 is the right-most character (in v1 this was position 0), and position 0 is invalid.
[EDIT: I now favour the ParamFirst/ParamLast (or FirstParam/LastParam) function approach, it involves some conversion, but it avoids ambiguity.]
An 'AutoHotkey v1' multi-statement global variable which can turn the following off:
- The result of a multi-statement expression such as x(), y() is the last (right-most) sub-expression instead of the first (left-most) sub-expression.
[EDIT: I generally favour approaches via functions, and not via special variables that can be turned on and off.]
And any other similar variables where required. I actually think that the AutoHotkey v2 changes are the right way to go, however, for the sake of keeping scripts compatible with both versions, the variables would be necessary.
For example to get the last 500 characters, currently I'd do:
SubStr(vText, 1-500).
==================================================
DOCUMENTATION:
- A guide to preferred syntax/functions/commands for AutoHotkey v1.0/v1.1 code, in readiness for AutoHotkey v2 code, to ease the transition.
- Clear information on functions that have been deprecated e.g. InStr over StringGetPos, parse loop over FileReadLine. (E.g. here the use of the word 'recommended': https://autohotkey.com/docs/commands/LoopFile.htm)
- Paragraph explanations of the code and dll functions behind each function/command. (I have needed this ultimately for most functions and have been collecting such information.)
- Up-to-date 'AutoHotkey\Extras\Editors\Syntax' text files (updated say once a year, with version number specified). [EDIT: MOSTLY RESOLVED, see link below, 'list of every command/function/variable ever'.][EDIT: Resolved.]
- Possibly add to #Persistent help entry: 'Any script that uses the GUI command anywhere is automatically persistent (even if the GUI command is never actually executed). It is also single-instance unless the #SingleInstance directive has been used to override that.'
list of every command/function/variable ever - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 75#p127875
CUSTOM FUNCTIONS: [RESOLVED]
- Up-to-date Functions.ahk for all commands (allowing you to bunch up many commands into one line, and reduce the need for brackets for just 2 lines of code).
- I've since created this:
Commands As Functions (Titan's/polyethene's Functions.ahk update) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=26900
DOWNLOAD:
- Put links to Acc.ahk, AccViewer, Gdip.ahk (and a future updated Functions.ahk) at the Standard Tools section on the ahkscript.org homepage. Plus, update the link to iWB2 Learner.
==================================================
2-LINE MANIFESTO, A GOOD SUMMARY, PLUS REMEMBER: DON'T FORGET THE BEGINNERS!:
The Future of the AutoHotkey Programming Language - AHKScript (an AutoHotkey Forum)
https://autohotkey.com/boards/viewtopic.php?t=6969
As far as I know there is no official statement of the design goals, but Chris' and Lexikos' posts on the forums cause me to believe this is close:
• make it easy to automate Windows and Windows programs that were not designed with automation in mind
• make it easy for novice programmers to learn
==================================================
THE FUTURE OF AUTOHOTKEY:
I think these areas should be a priority:
manipulate/retrieve text from:
- windows/controls (i.e. more control types) (Acc.ahk, UI Automation ...)
- webpages (directly or support common go-between software) (IE/Firefox/Chrome/Edge ...)
- Windows desktop/folder windows (XP/Vista/7/8/10 ...)
==================================================
FINALLY: Notes on Continue(), Break(), Return()
A Return() function would be quite useful, but I think it can be done quite easily:
(Note: this acts similarly to but is not the same as a theoretical Return function.)
[EDIT: The Exit function, is similar to Return in most cases, but for example won't work with Gosub.]
Code: Select all
;I believe a function version of Return() can be simply:
Return()
{
Exit
return
}
Code: Select all
;=============== horrible (too many brackets)
if (vTemp = "")
{
vOutput .= "`r`n"
continue
}
;=============== acceptable halfway house
if (vTemp = "")
if (1, vOutput .= "`r`n")
continue
;=============== ideal (currently not valid code)
if (vTemp = "")
vOutput .= "`r`n", Continue()
;===============
Thank you so much for reading.
Any/all comments are welcome.
==================================================