jeeswg's 3-item wish list (GUI class name+GUI no icon, A_ThisHwnd/A_ThisIfWinCriteria on hotkey launch, InputBox HFONT)

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

jeeswg's 3-item wish list (GUI class name+GUI no icon, A_ThisHwnd/A_ThisIfWinCriteria on hotkey launch, InputBox HFONT)

27 Dec 2016, 17:52

[see much altered updated version below in second post]
==================================================

[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
I have thought about automating the creation of such lines for every hotkey, but there are a lot of complications. Also such information is useful for keeping an ini log of which hotkeys were pressed when and how often, and is consistent with variables such as A_ThisHotkey and A_Gui.

- 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
}
Function versions of Continue() and Break() would be a nice idea, although I do not need them as much.

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.

==================================================
Last edited by jeeswg on 22 Aug 2017, 23:38, edited 4 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
jeeswg
Posts: 5939
Joined: 19 Dec 2016, 01:58
Location: UK

Re: jeeswg's 3-item wish list (GUI class name+GUI no icon, A_ThisHwnd/A_ThisIfWinCriteria on hotkey launch, InputBox HFO

20 Feb 2017, 23:03

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

REWORKED VERSION OF GENERAL WISH LIST

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

GUI

- MsgBox2 - version that doesn't use the MessageBox dll function.
- [KEY] InputBox - make the Font parameter function parameter, allow specifying an HFONT.
- ToolTip - specify font and background colour via a command/parameters/a global variable. (Especially important if 'Progress' is removed.)
- [KEY] Progress - keep this in AutoHotkey v2. Might as well keep SplashImage too. [EDIT: A version of SplashImage that could support more filetypes would be useful, possibly via Internet Explorer_Server controls.]
- [KEY] Gui command - allow specifying class name and no icon for a window.

Summary: MsgBox/InputBox/ToolTip/Gui are all broken in some way, and this has caused me enormous frustration ever since I first started using AutoHotkey. However Progress and SplashImage have worked perfectly since day one, are very versatile and can be used in many different ways.

Some of the problems relating to GUI and AutoHotkey, including MsgBox/InputBox/ToolTip:
- Set InputBox font size. [KEY]
- Set MsgBox font size (but this would change the system setting, so instead a MsgBox2 function is preferable).
- Set ToolTip colour (it's too faint).
- Set ToolTip background colour.
- Gui command, specify icon/no icon. [KEY]
- Gui command, specify class name. [KEY]
- The presence of Gui commands causes Persistent, even if never used.
- Edit/Static controls window styles e.g. word wrap issues, incorrect sizing, ampersand handing, in InputBox/Progress.
- MsgBox: silent, add countdown, consistent appearance across OSes.
- MsgBox/InputBox awkward parameters.
- MsgBox/InputBox focus lost. [EDIT: the dialog boxes get hidden under other windows.]
- Know the size of a window before it is created.

Note: Regarding using the Gui command to replace existing commands in AHK v2:
Gui commands cause Persistent, if 'Thread, Priority' is on, you can't use SetTimer and a label, some methods such as creating the GUIs yourself using dll functions involve a callback function and checking the message queue, which can cause unnecessary complications for simple scripts, hence the strong desire for robust/versatile/flexible MsgBox/InputBox/ToolTip functions, and keeping the Progress command.

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

TWO-WAY COMPATIBILITY

AutoHotkey v2 (with backwards compatibility mind)
- [KEY] Keep the Progress command.
- [KEY] Keep StrTrimLeft/StrTrimRight. (Commonly used, also, the same argument for changing SubStr, applies to keeping StringTrimLeft.)
- [KEY] Keep StrLeft/StrRight (because SubStr with nonpositive param 2 is ambiguous, the Format function can cure some ills but not all).
- Announce proposals for In/Contains/Is Type functions in AHK v2, so that conversion can proceed. I.e. one can create a custom function with the same name as the function that will exist.

AutoHotkey v1/v2 (with two-way compatibility in mind)
- 'EASY TO SHARE' PARADIGM: two-way compatible scripts and bits of code should be easy to share on forums without additional functions.
- [KEY] ParamFirst / ParamLast functions, return the first/last item in a list. AHK v2 returns the last parameter in a list, rather than the first.
- InStr1/InStr2, SubStr1/SubStr2 - a solution to the InStr/SubStr inconsistency problem.
- Ability to check for/set A_ variables that don't currently exist, that may exist in future versions.
- Allow certain dummy commands/directives from old versions to be present and not cause errors if a certain 'no warning/compatibility' mode is on e.g. #NoEnv. [More important for directives than commands.]

AutoHotkey v1 (with forwards compatibility in mind)
- [KEY] Deref function. A useful way to write some AHK v2 style code in AHK v1 to speed up uptake e.g. vPath := Deref("%A_Desktop%\%vNameNoExt%.txt"). It is also useful generally in AHK v1 for certain situations. (The Deref function already exists in AHK v2.)
- [KEY] vText := "`"hello`"" (or let AHK v2 support """hello""") (or perhaps let AHK v1 support '"hello"'). A common way to achieve double quotes in AHK v1/v2.

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

GENERAL - MAJOR

- [KEY] A_ThisHwnd/A_ThisIfWinCriteria on hotkey launch. Because virtually all my hundreds of subroutines must/should check that the active window matches the #IfWin criteria. [See topic: 'log hotkeys, get extended hotkey info, interact with the *right* window'.][EDIT: The active window might match #IfWinActive, however, it might not be the window that triggered the hotkey.]
- [KEY] StrReplace with case sensitive parameter.
- [KEY] Get window list with visible/hidden V/H/VH parameter. [EDIT: ahk_dhw]
- TimeOfThisHotkey (versus TimeSinceLastHotkey) perhaps TimeOfThisHotkeyMSec, a 17-digit date with millisecond precision. [See topic: 'log hotkeys, get extended hotkey info, interact with the *right* window']
- `s to create spaces: e.g. multiple spaces are lost in html, and A_Space is too unwieldy.
- A way to escape colons, so that all colon hotstrings are possible.
- More special variables allowed with #Include.

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

GENERAL - FURTHER

- Can be done by custom functions, but common enough to warrant standard functions (some inspired by MS Excel):
- Dec2Hex - the Format function does this, although I've wanted a function called Dec2Hex for so long that I still want it. [EDIT: Format function is a little bit unwieldy for this.]
- StrRept - although StrReplace and the Format function can make this possible in a reasonably short form. [EDIT: It can be a bit undreadable sometimes.]
- StrCountOcc - the StrReplace function can do this reasonably succinctly, but not as the output value of a function. [EDIT: Or simply StrCount.]
- File loops (handle long filenames).
- Registry loops (alphabetical order).
- StrStarts/StrEnds functions cf. 'if var contains'.
- A_NowMSec (17-digit date, date now with milliseconds).
- A_Recent variable (Recent folder).
- True/False functions - return true/false, whatever you put into it.
- Traditional For loop, very useful when converting code from other languages. [EDIT: Provide an example function in the documentation. See topic: 'Traditional For loop (i.e., step through a sequence)'.][EDIT: See topic: 'jeeswg's documentation extension tutorial'.]

- Script interaction:
- To another script: hide/show tray icon. Get Icon/NoIcon status of another script.
- Add Open Containing Folder to a tray icon's menu. Less needed now that the Recent menu has 'Open file location'.

- Also:
- Break(), Continue(), Return() functions: still a nice idea. [EDIT: Why is this apparently 'impossible'?]

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

IMPROVE DOCUMENTATION

- Best way to move binary data in scripts made clear. [EDIT: See topic: 'jeeswg's documentation extension tutorial'.]
- Make clear where one approach is preferable to another, where methods are deprecated e.g. StringGetPos and FileReadLine are deprecated.
- List the source code details and dll functions/messages, for each function/command/variable, either on the help pages themselves or in a special place together.
- For the Edit command, mention that the program that edits the script is stored in: HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell\Edit\Command.
- Generally add in lots more examples to reduce the number of basic questions being repeatedly asked in the forums.

==================================================
Last edited by jeeswg on 22 Aug 2017, 23:48, edited 4 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
lexikos
Posts: 6212
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: jeeswg's 3-item wish list (GUI class name+GUI no icon, A_ThisHwnd/A_ThisIfWinCriteria on hotkey launch, InputBox HFO

21 Feb 2017, 02:00

KEY 2: GET HWND OF WINDOW THAT MATCHES #IFWIN CRITERIA
WinExist() returns the window which was found (past tense) by #IfWin.
GUIs [...] must have a number that doesn't clash with existing GUIs.
Wrong. See Gui, New.
To another script: hide/show tray icon. Get Icon/NoIcon status of another script.
Why? If you want a custom message box, make a custom message box. I don't think it's appropriate to reinvent MsgBox as a built-in feature. (Also, you may want to look into scripts using the "task dialog" API.)
- The presence of Gui commands causes Persistent, even if never used.
Already fixed in v2, and probably can't be fixed in v1 for compatibility reasons.
MsgBox: silent, add countdown, consistent appearance across OSes.
It has appearance consistent with all other message boxes across the system, which is how it should be.

To be continued...?
User avatar
Flipeador
Posts: 1044
Joined: 15 Nov 2014, 21:31
GitHub: Flipeador
Location: Argentina
Contact:

Re: jeeswg's 3-item wish list (GUI class name+GUI no icon, A_ThisHwnd/A_ThisIfWinCriteria on hotkey launch, InputBox HFO

21 Feb 2017, 07:51

I totally disagree on everything. What you want is 'two-way compatibility', just use one or other.

I think add more commands/functions that can do yourself without problem, is a huge error (totally unnecessary. Just create your own gui window).
I will never use MsgBox font parameter. I prefer to use TaskDialogIndirect.

Regarding gui, I think the current command syntax needs a huge change (rewrite completely), convert everything to a simple class (see here), I've always hated the way AutoHotkey works with GUI (GuiControl, GuiControlGet, Gui Default, Gui ListView, Gui TreeView ...).

That is the highest priority for me, along with this and update some commands (that are deprecated) as 'DirSelect' with the 'new vista dialog' (support for WIN_XP must be dropped).

(All this for AHKv2, of course.)
sorry for my bad english.
Windws 1♂ Pro 64-Bits I make scripts for AHKv2 (my v2 compiler) & WIN_7+ Spanish Argentina
(If any of my code written for v2 has stopped working, send me a private message. I appreciate that you correct my English.)
User avatar
jeeswg
Posts: 5939
Joined: 19 Dec 2016, 01:58
Location: UK

Re: jeeswg's 3-item wish list (GUI class name+GUI no icon, A_ThisHwnd/A_ThisIfWinCriteria on hotkey launch, InputBox HFO

21 Feb 2017, 10:05

@Flipeador and @Lexikos:
Thank you very much for your responses. Regarding TaskDialogIndirect, it doesn't appear to allow specifying an HFONT/LOGFONT, but thanks for the information.

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

@Lexikos:
- Many thanks for the information regarding getting the hWnd at the time the hotkey was triggered.
- However, there appears to be a difference when using '#IfWinActive' alone versus '#IfWinActive, MyCriteria', which unfortunately very much limits the usefulness of the method.

Code: Select all

#IfWinActive, ahk_class Notepad
q:: ;this will put the matching hWnd into WinExist
#IfWinActive
q:: ;warning: this will not put the matching hWnd into WinExist
;which makes the 'hWnd := WinExist()' technique essentially unreliable
;or at least it must be used with care if rewriting scripts and altering #IfWinActive labels
hWnd := WinExist()
WinGetClass, vWinClass, ahk_id %hWnd%
MsgBox % "[" hWnd "]`r`n" vWinClass

;Sleep 3000
;WinGet, hWnd2, ID, A
;MsgBox % hWnd " " hWnd2
Return
#IfWinActive
I couldn't find information on this at either of:
https://autohotkey.com/docs/commands/WinExist.htm
https://autohotkey.com/docs/misc/WinTit ... oundWindow
[EDIT:][I found it here:]
#IfWinActive / #IfWinExist
https://autohotkey.com/docs/commands/_IfWinActive.htm
The Last Found Window is set by #IfWinActive/Exist (though not by #IfWinNotActive/NotExist).

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

@Flipeador: REGARDING AHK V1/V2 CONVERSION
- Try converting some big libraries from AHK v1 to v2, even without trying to maintain two-way compatibility.
- I think you might appreciate being able to use ParamFirst/ParamLast, every time you have multiple parameters used with a Return command.
- [EDIT:] (Btw if the library was written by someone else, I may not want to add in custom functions, so either I use some gross workaround, or take advantage of any existing standard AutoHotkey functions/commands.)
- Also without InStr1/SubStr1/RegExMatch1/RegExReplace1 functions, some conversion will be a lot harder and will waste a lot of time.
- A lot of people at the moment are using SubStr("00" vNum, -1), or SubStr(vText, -1), to get the last 2 characters in a string, this will all break in AHK v2. StrRight(vText, 2), if added to AHK v1/v2, would allow for a consistent method, or SubStr1(vText, -1) would be an easy fix, if added in as a function to AHK v1/v2.
- It irks me that I'm sharing code on the forum at the moment, that I know will break, because basic things don't currently have a non-ugly, non-custom function, two-way compatible method.
- All the other comments I've mentioned re. conversion, (apart from a common AHK v1/v2 double quote method,) are to maintain functions across versions, rather than ask for new features.
- Frankly without seriously considering the 'EASY TO CONVERT' and 'EASY TO SHARE' paradigms, how many borderline and sceptical users are going to want to convert. I've done the work on conversion, I know what it's going to take to get people on board with AHK v2.

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

@Lexikos: REGARDING MSGBOX2
- [I am still investigating the issues, including Gui command/dll function tests, in order to make a custom MsgBox2 function.]
- For me MsgBox is unusable because the font is too small. If I change the system setting to make it bigger, it affects various programs in a negative way. If I try to create my own MsgBox via Gui/dll functions, for use in all my scripts, issues such as Persistent, and 'Thread, Priority', and message handling come into play, hence the ongoing investigations.
- Not that my opinion is particularly ardent here, but one could say that things are backwards, AutoHotkey should have a custom MsgBox like InputBox, and people can easily use the MessageBox dll function if they wish to. Also, MessageBox on Windows 7 is hard to read, it's bright white, I had to change the system settings to make it grey (gray), but this affects all windows/Edit controls.
Last edited by jeeswg on 06 Sep 2017, 16:34, edited 3 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
guest3456
Posts: 2496
Joined: 09 Oct 2013, 10:31

Re: jeeswg's 3-item wish list (GUI class name+GUI no icon, A_ThisHwnd/A_ThisIfWinCriteria on hotkey launch, InputBox HFO

21 Feb 2017, 10:23

jeeswg wrote: There appears to be a difference when using '#IfWinActive' alone
versus '#IfWinActive, MyCriteria', which unfortunately
very much limits the usefulness of the method.

Code: Select all

#IfWinActive, ahk_class Notepad
q:: ;this will put the matching hWnd into WinExist
#IfWinActive
q:: ;warning: this will not put the matching hWnd into WinExist
;which makes the 'hWnd := WinExist()' technique essentially unreliable


WinExist() isn't unreliable. it works exactly as documented.
your code makes no sense. poor code logic leads to unreliable code.

read the help page. #IfWinActive alone doesn't do anything.

perhaps turning off context sensitivity should be changed to #IfWinActive, off
Last edited by guest3456 on 21 Feb 2017, 10:30, edited 1 time in total.

User avatar
jeeswg
Posts: 5939
Joined: 19 Dec 2016, 01:58
Location: UK

Re: jeeswg's 3-item wish list (GUI class name+GUI no icon, A_ThisHwnd/A_ThisIfWinCriteria on hotkey launch, InputBox HFO

21 Feb 2017, 10:30

This script makes it clearer:

Code: Select all

#IfWinActive, ahk_class Notepad
q::
hWnd := WinExist()
WinGetClass, vWinClass, ahk_id %hWnd%
MsgBox % "[" hWnd "]`r`n" vWinClass
Return
#IfWinActive

#IfWinActive
w::
hWnd := WinExist()
WinGetClass, vWinClass, ahk_id %hWnd%
MsgBox % "[" hWnd "]`r`n" vWinClass
Return
#IfWinActive
[EDIT:] I said that a technique involving WinExist() appeared unreliable.

The concept of '#IfWinActive, Off' versus '#IfWinActive, AnyWindow' is an interesting distinction, that may explain the difference at present.
Last edited by jeeswg on 06 Sep 2017, 16:35, edited 3 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
guest3456
Posts: 2496
Joined: 09 Oct 2013, 10:31

Re: jeeswg's 3-item wish list (GUI class name+GUI no icon, A_ThisHwnd/A_ThisIfWinCriteria on hotkey launch, InputBox HFO

21 Feb 2017, 10:31

jeeswg wrote:This script makes it clearer:

Code: Select all

#IfWinActive, ahk_class Notepad
q::
hWnd := WinExist()
WinGetClass, vWinClass, ahk_id %hWnd%
MsgBox % "[" hWnd "]`r`n" vWinClass
Return
#IfWinActive

#IfWinActive
w::
hWnd := WinExist()
WinGetClass, vWinClass, ahk_id %hWnd%
MsgBox % "[" hWnd "]`r`n" vWinClass
Return
#IfWinActive
no it doesn't make anything clearer. actually it makes things more confusing: which is why you're confused.

there's no need to use #ifWinActive surrounding your w:: hotkey. its redundant and doesnt do anything and they should be removed. for the 2nd time: read the help page.

User avatar
jeeswg
Posts: 5939
Joined: 19 Dec 2016, 01:58
Location: UK

Re: jeeswg's 3-item wish list (GUI class name+GUI no icon, A_ThisHwnd/A_ThisIfWinCriteria on hotkey launch, InputBox HFO

21 Feb 2017, 10:52

There appears to be a difference when using '#IfWinActive' alone versus '#IfWinActive, MyCriteria'.

The aim of the subroutines is to retrieve the hWnd for the window that was active when the hotkey was triggered via hWnd := WinExist(), or any other method, if it is currently possible, with standard functions/commands.

Btw I'm aware that there were some redundant #IfWinActive lines in the example above. Sometimes when testing I add them in to prevent any interference with other #IfWinActive lines above/below.
Last edited by jeeswg on 06 Sep 2017, 16:36, 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
guest3456
Posts: 2496
Joined: 09 Oct 2013, 10:31

Re: jeeswg's 3-item wish list (GUI class name+GUI no icon, A_ThisHwnd/A_ThisIfWinCriteria on hotkey launch, InputBox HFO

21 Feb 2017, 11:16

jeeswg wrote:There appears to be a difference when using '#IfWinActive' alone
versus '#IfWinActive, MyCriteria'.
there is no 'appearance'. there is a clear difference.

for the 3rd time: do not post again until you READ THE FKN MANUAL

jeeswg wrote: The aim of the subroutines is to retrieve the hWnd for the window
that was active when the hotkey was triggered
via hWnd := WinExist(), or any other method,
if it is currently possible, with standard functions/commands.

Code: Select all

hwnd := WinExist("A")

User avatar
jeeswg
Posts: 5939
Joined: 19 Dec 2016, 01:58
Location: UK

Re: jeeswg's 3-item wish list (GUI class name+GUI no icon, A_ThisHwnd/A_ThisIfWinCriteria on hotkey launch, InputBox HFO

21 Feb 2017, 11:30

Thank you, but I want a consistent method to retrieve the hWnd for the window that was active *when the hotkey was triggered*, not for the window that is active now.

I have hundreds of subroutines that need to double-check that the active window matches the window active when the hotkey was triggered. As a second-best I can check that the active window matches the #IfWin criteria, but then I have to manually copy all the #IfWin criteria into a line that checks this, plus if multiple hotkeys point to the same subroutine, this becomes more difficult.

A secondary reason is that I would like to record each hotkey when it is pressed, so I would like to pass the hotkey label (A_ThisHotkey) and the #IfWin criteria for the most recent hotkey to a function. A second-best is to get the active window at the start of the subroutine, and record its class/process name.

Btw I did reread that bit of the manual (#IfWinActive).
Last edited by jeeswg on 06 Sep 2017, 16:42, 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
guest3456
Posts: 2496
Joined: 09 Oct 2013, 10:31

Re: jeeswg's 3-item wish list (GUI class name+GUI no icon, A_ThisHwnd/A_ThisIfWinCriteria on hotkey launch, InputBox HFO

21 Feb 2017, 11:39

jeeswg wrote:Thank you, but I want a consistent method to retrieve the hWnd for the
window that was active *when the hotkey was triggered*,
not for the window that is active now.
what is the difference? when you press a hotkey, you check what window is active now. its the same thing.

Code: Select all

#IfWinActive, ahk_class Notepad
q::
#IfWinActive
w::
   hWnd := WinExist("A")
   WinGetClass, vWinClass, ahk_id %hWnd%
   MsgBox % "[" hWnd "]`r`n" vWinClass
Return
jeeswg wrote: I have hundreds of subroutines that need to double-check that the active window
matches the window active when the hotkey was triggered.
why would you ever need to double check? give an example of how it would fail if you don't doublecheck

User avatar
jeeswg
Posts: 5939
Joined: 19 Dec 2016, 01:58
Location: UK

Re: jeeswg's 3-item wish list (GUI class name+GUI no icon, A_ThisHwnd/A_ThisIfWinCriteria on hotkey launch, InputBox HFO

21 Feb 2017, 11:53

Another window pops up immediately after triggering the hotkey, e.g. a system window, error message, or Restart.
The new window could be a different window with the same #IfWin criteria, so even checking the class/process name can fail sometimes.
[EDIT:] Also the user might click alt+tab just before the window check is done.
[EDIT:] Also two scripts communicating and creating windows for each other.
[EDIT:] What about a hotkey that was delayed and put in the queue?

The wish list requested a standard variable, this would negate the need even for the WinExist line, it would also be useful for recording hotkey information, at the end of the subroutine.

Potentially some other action would update WinExist() and so even that wouldn't work. E.g. multiple hotkey labels for one subroutine, and there is a separate WinExist after one hotkey label, before another hotkey label. There are issues with multiple hotkeys each with an WinExist() line beneath it, there are even issues if each WinExist() is preceded by a line that checks a variable. Also would launching another hotkey reset WinExist()?

Also for recording the hotkey, you would have to retrieve the information at the start, not the end of the subroutine, as the window might disappear.

Similarly I avoid using SendInput, I always send key presses using SendMessage or ControlSend.
[EDIT:] Besides if I provide a script for someone else it must be as reliable as possible, it must do the double checks.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
guest3456
Posts: 2496
Joined: 09 Oct 2013, 10:31

Re: jeeswg's 3-item wish list (GUI class name+GUI no icon, A_ThisHwnd/A_ThisIfWinCriteria on hotkey launch, InputBox HFO

21 Feb 2017, 12:43

can you give a real example and not a hypothetical? tell me exactly how to reproduce it

guest3456
Posts: 2496
Joined: 09 Oct 2013, 10:31

Re: jeeswg's 3-item wish list (GUI class name+GUI no icon, A_ThisHwnd/A_ThisIfWinCriteria on hotkey launch, InputBox HFO

21 Feb 2017, 13:09

you could also use TitleMatchMode, RegEx and have your #ifWin just match everything in order to trigger the LastFoundWindow

User avatar
jeeswg
Posts: 5939
Joined: 19 Dec 2016, 01:58
Location: UK

Re: jeeswg's 3-item wish list (GUI class name+GUI no icon, A_ThisHwnd/A_ThisIfWinCriteria on hotkey launch, InputBox HFO

21 Feb 2017, 13:45

Some script to reproduce the problem:

Code: Select all

;script 1
;I added in multiple hotkeys to avoid RSI
;when repeatedly pressing a hotkey,
;a count appears on each hotkey press,
;the date is updated each time the undesirable outcome occurs
#IfWinActive, ahk_class Notepad
q::
w::
e::
r::
t::
y::
u::
i::
o::
p::
a::
s::
d::
f::
g::
h::
j::
k::
l::
hWnd := WinExist()
hWnd2 := WinExist("A")
WinGetClass, vWinClass, ahk_id %hWnd2%
vCount++
if !(vWinClass = "Notepad")
	vDateX := A_Now
ToolTip %vWinClass% %vCount% %vDateX%
Return
#IfWinActive

;==================================================

;script 2
;warning: be sure that you have a way to end this subroutine,
;I have added Esc/x in order to end it
;possibly this script can be improved to increase the likelihood of the undesirable outcome in script 1
Loop
{
	if GetKeyState("Esc", "P") || GetKeyState("x", "P")
		break
	MsgBox, , , , % 0.01
	Sleep 10
}
Return
Interesting idea regarding RegEx.
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: 3981
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: jeeswg's 3-item wish list (GUI class name+GUI no icon, A_ThisHwnd/A_ThisIfWinCriteria on hotkey launch, InputBox HFO

21 Feb 2017, 13:58

Most of your requests don't make any sense except for making it easier on you personally for your coding style.
Though you could probably libraries that solve your issues you don't do that.. Why?
Recommends AHK Studio
Helgef
Posts: 3566
Joined: 17 Jul 2016, 01:02
Contact:

Re: jeeswg's 3-item wish list (GUI class name+GUI no icon, A_ThisHwnd/A_ThisIfWinCriteria on hotkey launch, InputBox HFO

21 Feb 2017, 15:59

jeeswg wrote:Some script to reproduce the problem:
I couldn't get different hWnd and hWnd2.
Seems very unlikely. And what stops the active window from changing when you double-check? Basically, with your reasoning, you can never do anything with the active window, since it might change as you do it :roll:
Maybe this can imitate what you are asking for,

Code: Select all

#If ((B_ThisIfWinCriteria:="ahk_class Notepad") &&  B_ThisHwnd:=WinActive(B_ThisIfWinCriteria))
q::f(B_ThisIfWinCriteria,B_ThisHwnd)
w::f(B_ThisIfWinCriteria,B_ThisHwnd)
f(B_ThisIfWinCriteria,B_ThisHwnd){
	MsgBox, % B_ThisIfWinCriteria "`n" B_ThisHwnd "`n" A_ThisHotkey
}
Inside the function, the variables B_ doesn't change, even if the execution of the function is interupted by another hotkey.

Good luck.
User avatar
jeeswg
Posts: 5939
Joined: 19 Dec 2016, 01:58
Location: UK

Re: jeeswg's 3-item wish list (GUI class name+GUI no icon, A_ThisHwnd/A_ThisIfWinCriteria on hotkey launch, InputBox HFO

21 Feb 2017, 16:00

@nnnik: Thanks for your comments. Apologies but I can't really agree with what you've stated.

Regarding functions, 'for my personal convenience' (words to that effect): I've written over a thousand functions, some of my libraries are: Address Space, AutoHotkey Itself, Dates, Gui, Hotstrings, Internet, Lists, Maths, Other [by other people], Shell, Sort Filters, Text, Utils, Words, YouTube API. All that I want to polish and release. [EDIT: I always distinguish between core/obscure functionality.]

More recently I've been working on AHK1FC, 'AutoHotkey v1 Forwards Compatibility' this basically extends/alters 'Commands As Functions' to provide AutoHotkey v2 functions for AutoHotkey v1. The list above doesn't include my scripts that I want to share, one which I'll mention: an AHK v1/v2 converter.

Every single thing here mentioned on the wish list, I've either programmed already, or tried to achieve the best possible workaround.

Many features I wanted have been added in, including: Unicode, objects/arrays/COM, ahk_exe, IniRead section, Gui control positioning, StrReplace function, Format function, A_ScriptHwnd, DateAdd/DateDiff, Trim/LTrim/RTrim, StrGet/StrPut, 64-bit, A_Args, variadic functions. Even DirExist, A_MsgBoxResult, A_InitialWorkingDir, A_ScreenDPI and Ord, and splitting up Process/WinGet/WinSet. So if you don't like my wish list requests, why don't you stop using those functions.

Anything that hasn't been added, it can often be because the people writing the source code don't need it, so you have to mention major issues that affect a lot of users. Also, many of my requests are basic features in other programming languages.

Regarding AutoHotkey v2: how many people have even looked at AHK v2, or thought about how new users are going to respond to transitioning to it and adapting old code. There's a difference between possible to convert and practical to convert.

Btw think about what's it like when you're a noob, and you want a MsgBox big font ('but it's a dll function so you can't), you want an InputBox big font ('yeah the parameter's there but not implemented yet'), just make a GUI ('when I make a GUI it interferes with things'), do it via dll functions ('that interferes with things too'), just use Progress ('it's being phased out'), just use ToolTip and WM_SETFONT and ignore the flickering, ('the font is too faint').

[EDIT:] Btw these comments weren't aimed at you personally, just that these are the kinds of things on my mind that you've prompted.
Last edited by jeeswg on 06 Sep 2017, 16:48, edited 2 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
jeeswg
Posts: 5939
Joined: 19 Dec 2016, 01:58
Location: UK

Re: jeeswg's 3-item wish list (GUI class name+GUI no icon, A_ThisHwnd/A_ThisIfWinCriteria on hotkey launch, InputBox HFO

21 Feb 2017, 16:17

@Helgef: In my function, if you see a datestamp, then a window sneaked in between a hotkey press and get hWnd. I found it happened if I pressed the keys, once when the count reached around 100, another time, when I made it more strict (with only one line: WinGetClass, vWinClass, A) before the 'if' line, when the count reached around 1000. AutoHotkey does seem very robust here, however, if something can slip through, then checking the class (i.e. the #IfWin criteria) is advisable.

You are right regarding, 'what stops the active window from changing [before] you double-check?' What I can do is think: 'well at least the window I'm operating on had the right class/process name'.

Your '#If' code is very interesting, #If is something I've never used, because I haven't needed to. I think it is actually quite simple to implement, I change all the #IfWinActive lines as required, and then I can always refer to the hotkey hWnd and hotkey #IfWin criteria via the 'B_' variables. For plain '#IfWinActive' lines, I suppose they would have to be altered somewhat and placed below other hotkey labels/subroutines.

This is a really really good solution, I think it does everything, I'm actually thinking that I might take this approach. Still some time before I do the full script conversions, AHK v1/v2 two-way compatibility conversions will be completed first.
Last edited by jeeswg on 06 Sep 2017, 16:49, 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

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 8 guests