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

23 Feb 2017, 16:36

@guest3456
Interesting comments re. conversion, I inspected the before/after scripts for Gdip_All.ahk, and made some comments (nice comments) here:
conversion logic, v1 = -> v1 := -> v2, two-way compatibility - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 37&t=27069

Btw I agree with you re. multiple items on Return lines, I don't like it very much either, nice to agree about something regarding coding style.
guest3456 wrote:Because a single user can only have one instance of AHK installed on their machine. Either v1 or v2.
We probably both have at least 4 versions on the go, e.g. AHK v1/2 x32/x64, so I'm not sure what you meant here. Once in a blue moon I'll try something on AHK Basic, and for some of my functions I'll test them on AHK v1 ANSI, which I've never used.
guest3456 wrote:The only reason to worry about compatibility is for code that would be shared such as libraries, in which case its no big deal to have some extra code
I think my real world example about a user who just wants a simple way to get the last 2 characters and isn't interested in AHK version numbers is a pretty good example.

Btw people (including me) are still converting x32-only and Basic scripts from forums, and so converting AHK v1 scripts would be added to the mix, the easier conversion is for the beginner, the better. There are so many two-levels-above-my-ability things I tried to do as a beginner, and you don't want to ask someone else to help you all the time, I've done everything by myself for years, it's only now I'm asking for help on various things that I got really stuck on.
guest3456 wrote:But if you think these things are so necessary, then fork the AHK source code, and add the features in yourself, and then you'll have your own 2-way compatible AHK.
I'm thinking of doing just that, after I complete my GUI functions library and some non-IT projects. I don't really want to compete with AutoHotkey, because I like AutoHotkey, but I intend to do this. If only so that I can properly appreciate the amount of work required to add the changes I want, to see if it's not too bad or surprisingly/extremely difficult.

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

I might mention the idea of #AutoDeref for AHK v1, an optional, 'positional' or 'global' (if those are the correct words) directive for dereferencing variables, its function would be a kind of opposite to #NoEnv. Something like this: vPath := "%A_Desktop%\MyFile.txt" would be dereferenced as it would be in AHK v2, unless for example `%A_Desktop`% was used.

Using a Deref function in numerous places is another way of writing two-way compatible scripts. In AHK v1, it would dereference the example above, but AHK v2 does 'AutoDeref' as standard, so in AHK v2 the text would be dereferenced before Deref would try to dereference it. Anyhow, you end up with the same result in both versions.

Another suggestion would be to bring *all* the AHK v2 new functions into AHK v1, the ones that replicate AHK v1 functionality. (So far I've almost finished a library that brings them in as custom functions for AHK v1 only, in a library that should only be used on AHK v1 scripts.) Similarly I would keep String(Trim)Left/Right as StrLeft/StrRight, StrTrimLeft/StrTrimRight functions. If only a few functions (based on existing commands) were present in both in AHK v1 and v2 they would be, those 4 Str functions and Deref.

I don't know if adding built-in functions for existing commands is significantly harder in C++ than it is in AutoHotkey, so apologies for not being able to gauge that.

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

Btw to communicate between scripts, would sharing an object be a possible method, in order to avoid SendMessage?

If I am to replace MsgBox/InputBox/Progress/SplashImage/ToolTip, I can't use Gui because that would make scripts persistent, and I'm not changing hundreds of scripts just for that (e.g. replace Return with ExitApp etc). I'm planning to create a script called 'notify' that will replace these 5 commands using the Gui command or GUI functions. But that might mean I need to add an OnMessage function to all my scripts which is again no good. Plus potential issues regarding 'Thread, Priority'. I could create a temporary script every time I run a script, that starts with OnMessage and includes the script perhaps. This is the significance of the existing 'notify' commands handling messages etc behind the scenes versus the obstacles involved in taking over those roles.

This partly explains why InputBox(/MsgBox/ToolTip) with changeable font and keeping Progress/SplashImage, would be so beneficial to me.
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: 9592
Joined: 30 Sep 2013, 04:07
Contact:

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

23 Feb 2017, 23:13

jeeswg wrote:A: To make it safe for AutoHotkey v2 as well, do the following:
vIsAhkV1 := (SubStr(A_AhkVersion,1,2) = "1.")
vText := SubStr(vText, vIsAhkV1-2)
or
vText := SubStr(vText, (SubStr(A_AhkVersion,1,2) = "1.")-2)
Whichever one inspires you more, pretty isn't it? Beautiful beautiful AutoHotkey. I hope you like the handy one-line version.
It is unwise to write code that depends on version numbers to determine behaviour, especially when AutoHotkey v2 hasn't even reached a beta release let alone final release, and there is a perfectly good alternative.
A: Well there is another way:
vText := SubStr(vText, StrLen(vText)-1)
Q: Yeah, but sometimes I'll be adding in text to the front of the variable at the same time.
Now you're just being picky. If AutoHotkey never had the negative indexing mode, you'd be calculating the index whatever way necessary, like in many other languages. If you don't want two StrLen calls, concatenate into one variable first.

Is the suffix going to be less than two characters? There's no reason to prefix a string if that string is never going to be included because the suffix is always at least two characters. It's easy to come up with these hypothetical cases, but retrieving the last n characters of the concatenation of multiple strings is really not something that users do frequently.
Q: What about a function version of StringRight? Has anyone suggested that?
vText := StrRight(vText, 2)
A: That's not a standard function and never will be, as an AutoHotkey veteran I think that's a stupid idea, absolutely shouldn't be added to the source code, I don't know why you even bothered to suggest it. Clearly if you like that idea it's because you never listen to anyone. Furthermore you don't know how to propose ideas, anyway feature requests are stupid and pointless.
Q: Wasn't AutoHotkey an AutoIt feature request that never happened, why are you using the language?
A: See you never listen, btw did you read the manual?
That's ridiculous, and doesn't help your position at all.
One thing to think about if AHK ever gets that far:
You can't possibly take into account the next eight major compatibility-breaking releases of AutoHotkey before they are even conceived, if compatibility with those versions would even be possible. Anyway, that's just another reason to avoid relying on version number checks.
Btw will AutoHotkey v2 always allow both of these?
It does. They are both string comparisons, because one value is non-numeric.
I might mention the idea of #AutoDeref for AHK v1, an optional, [...]
Using a Deref function in numerous places is another way of writing two-way compatible scripts.
Such things are unnecessary. "100`%" and "X" Y "Z" are already two-way compatible.
Btw to communicate between scripts, would sharing an object be a possible method, in order to avoid SendMessage?
See ObjRegisterActive.
guest3456
Posts: 3463
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

23 Feb 2017, 23:55

jeeswg wrote: I might mention the idea of #AutoDeref for AHK v1, an optional, 'positional' or 'global' (if those are the correct words) directive for dereferencing variables, its function would be a kind of opposite to #NoEnv. Something like this: vPath := "%A_Desktop%\MyFile.txt" would be dereferenced as it would be in AHK v2, unless for example `%A_Desktop`% was used.
Are you fking serious:

vPath := A_Desktop . "\MyFile.txt"

Now I'm done reading your posts. You are just rambling and not even thinking. I'm tempted to accuse you of intentionally wasting everyone's time and blatantly trolling us, but I know you're not, and you're just this dense. How do I know? Because you came here and told us how you were run out of stackoverflow for the exact same stuff.

Much better:

http://imgur.com/a/Bnvmp

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

24 Feb 2017, 07:17

@guest3456
Slight overreaction there. That was a simple example outlining the principle of Deref and how AHK v2 handles variables. A few months ago for example, I wasn't fully aware of either.
(1) I only found out that AHK v1 had 'Transform, Deref' shortly after writing a Deref function myself.
(2) When I first came across 'command style' variables within 'expression style' syntax in AHK v2, it was such a surprise to see it, I didn't realise what was happening.

Two options re. two-way compatibility, although the first is longer, I find it preferable, because it is more readable, (currently Deref is only in AHK v2, although for the line below, Deref *would* be needed in AHK v1, and *wouldn't* be needed in AHK v2, although it would do no harm in AHK v2):
vPath := Deref("%vDir%\New Text Document%vSuffix%.txt")
vPath := vDir "\New Text Document" vSuffix ".txt"

Btw I've enjoyed many of your posts even when you're somewhat impolite, but sometimes it seems like you're wilfully trying to undervalue what I say and it could have the opposite effect, because people will always form their own opinions.

Re. Stack Overflow, like others there, you can be fine for a good while and then you get a surprise:
https://sergworks.wordpress.com/2012/09 ... low-sucks/
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: 4500
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

24 Feb 2017, 07:54

The way you handled that QA was both really annoying and felt really insulting.
If you don't want to trigger such responses don't write posts like that.
It seems you still haven't understood why we want to reject StrRight and other suggestions that revolve around making translating (or creating 2 way compatability ) easier.
Yet I also enjoyed this discussion and hope you will keep searching for a better way to find what you look for.
Recommends AHK Studio
User avatar
jeeswg
Posts: 6902
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

24 Feb 2017, 08:13

lexikos wrote:It is unwise to write code that depends on version numbers to determine behaviour
I agree, and it seems like you are saying that if required to write a two-way compatible script you would use:
vText := SubStr(vText, StrLen(vText)-1)
However, what about InStr, RegExMatch and RegExReplace:
vIsAhkV1 := (SubStr(A_AhkVersion,1,2) = "1.")
vPos := InStr(vText, " ", 0, vIsAhkV1-1)
Or perhaps to search from the last character backwards:
vPos := InStr(vText Chr(1), vNeedle, 0, -1) ;where Chr(1) is not in the needle
But there could be some complications regarding choosing an appropriate dummy character.

To establish a version number I could check for whether a built-in variable/command exists, but that too could be unreliable.
lexikos wrote:There's no reason to prefix a string if that string is never going to be included because the suffix is always at least two characters.
This happens all the time with padding spaces/zeros, however I recently found out that the Format function can do this. It's true that there aren't too many other examples for this, at least that I can think of off the top of my head, although I do do some complicated things regarding word lists and word endings.

Thanks re. 'both string comparisons' and ObjRegisterActive. TYFR.

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

@nnnik
Your post is much appreciated. My sample Q&A was based on real-life events, I definitely do not think that it represents the typical AHK veteran at all btw. I actually did not wish to offend anyone, it was to illustrate how I and possibly many others perceive some of the posts on this topic.

Whether people like the ideas or not, I do hope that they come across as carefully considered, and aiming to fit within the nature of existing functions, and also that they aim to combine minimal changes with convenience/practicality and maintaining the purity/beauty of the AHK v2 ideals.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

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

24 Feb 2017, 08:26

Instant of waste tons of hours to make it compatible for v1.1 and v2[*] just release 2 scritps...

MyScript.ahk
MyScript_v2.ahk

FIN


*v2 is still alpha and there can be many more changes till final / stable release and break your script again
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
nnnik
Posts: 4500
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

24 Feb 2017, 09:09

jNizM wrote:Instant of waste tons of hours to make it compatible for v1.1 and v2[*] just release 2 scritps...

MyScript.ahk
MyScript_v2.ahk

FIN


*v2 is still alpha and there can be many more changes till final / stable release and break your script again
As some background information it might be said that he is not working on a script.
He is working on a script that creates a 2 way compatible scripts.
Recommends AHK Studio
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

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

24 Feb 2017, 09:11

nnnik wrote:As some background information it might be said that he is not working on a script.
He is working on a script that creates a 2 way compatible scripts.
As long v2 is alpha I see no real reason for this ^^
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
nnnik
Posts: 4500
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

24 Feb 2017, 09:22

jNizM wrote:
nnnik wrote:As some background information it might be said that he is not working on a script.
He is working on a script that creates a 2 way compatible scripts.
As long v2 is alpha I see no real reason for this ^^
Me neither xD
Recommends AHK Studio
guest3456
Posts: 3463
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

24 Feb 2017, 09:25

jNizM wrote:Instant of waste tons of hours to make it compatible for v1.1 and v2[*] just release 2 scritps...

MyScript.ahk
MyScript_v2.ahk

FIN
which is what the v1 -> v2 script converter does. i suppose this could be modified to make things 2 way compatible and perhaps that should be an option. but i don't really care enough

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

24 Feb 2017, 09:38

I thought I would share an example, regarding Progress plus Input.

Code: Select all

;using Progress and Input to bring up a list of Recent items
;to select item: type in item number and press Enter
;to cancel: press Esc
q::
vLimit := 20
vPrompt := ""
VarSetCapacity(vPrompt, 100000*2)

;path of Recent folder on Windows 7
vDir1 = C:\Users\%A_UserName%\AppData\Roaming\Microsoft\Windows\Recent
if !FileExist(vDir1)
	vDir1 = C:\Documents and Settings\%A_UserName%\Recent

Loop, %vDir1%\*.*, 0, 0 ;(0/1/2=files/both/folders, 0/1=recurse no/yes)
{
	vPathLnk := A_LoopFileFullPath
	FileGetShortcut, % vPathLnk, vPath
	SplitPath, vPath, vName, vDir, vExt, vNameNoExt, vDrive
	vPrompt .= "(" A_Index ") " vName "`r`n"
	vPath%A_Index% := vPath
	if (A_Index = 20)
		break
}

Progress, zh0 b c0 fs18 w600, % vPrompt
Input, vNum, L3 T8 M, {Enter}{Esc}
vRet := ErrorLevel
Progress, Off

if InStr(vRet, "EndKey:Enter")
&& RegExMatch(vNum, "^\d+$") ;'is digit'
&& (vNum >= 1) && (vNum <= vLimit)
&& FileExist(vPath%vNum%)
{
	MsgBox, 3, , % vPath%vNum% "`r`n[choose Yes to open]"
	IfMsgBox Yes
		Run, % vPath%vNum%
}
Return
==================================================

@jNizM
Scripts can have two versions, but what about sharing code on the forum? I'll choose AHK v1 methods for the time being, using the more forwards compatible methods where they are available, but sticking to AHK v1 code if the two-way compatible code would be ugly.

Also, I would state this as a fact, from having converted a lot of my own code:
- Converting AHK v1 to AHK v2.
- Converting AHK v1 to two-way compatible.
Same level of difficulty/effort.

The only problem right now, is the quite ugly, least-worst solutions for dealing with double quotes.

I always go for what in the long-term is the least time-consuming option, my instincts, and now my experiences too, say two-way compatibility for definite. Primarily because any code corrections will only have to be done once, but also because the additional conversion effort is minuscule.

[EDIT:]
Btw I think one thing is clear about AHK v1/v2, people should be made aware of the likely changes from AHK v1 to AHK v2, because it might affect how they write their AHK v1 code *now* in order to avoid certain conversion issues in the future. I will publish a summary as such regarding best practice.
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: 9592
Joined: 30 Sep 2013, 04:07
Contact:

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

24 Feb 2017, 18:59

jeeswg wrote:However, what about InStr, RegExMatch and RegExReplace:
Why would anyone use one method for SubStr and another method for the other three functions? They all work the same way.
Or perhaps to search from the last character backwards:
vPos := InStr(vText Chr(1), vNeedle, 0, -1) ;where Chr(1) is not in the needle
I don't see the purpose of Chr(1) or what it has to do with the discussion.

In this case, StrLen(vText)-n would index relative to the end of vText, which could be useful in its own right without taking into account Chr(1). If you want to take Chr(1) into account, it's a simple matter of +1.
To establish a version number I could check for whether a built-in variable/command exists, but that too could be unreliable.
That's even worse. Obviously in the case of using StrLen with SubStr, there's no need to know the version number. You just write code that works on both. That's the point.

You can, for example, check for the existence of a built-in function by using Func(), or check for a variable by using a double-deref. The purpose of that would be to determine if that function or variable exists, not to determine the version number of AutoHotkey.
User avatar
jeeswg
Posts: 6902
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

24 Feb 2017, 19:22

lexikos wrote:In this case, StrLen(vText)-n would index relative to the end of vText
Yes but that would search in the forward direction, right? What if you want to search backwards?
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: 6902
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

25 Feb 2017, 02:26

Some example scripts defending Progress and SplashImage:

Code: Select all

;IN DEFENCE OF PROGRESS (AND SPLASHIMAGE)
;Some example scripts.

;I expanded on my Progress command example earlier.
;If there's going to be no more Progress
;command, then at least everybody in the community
;can miss it like I would miss it.
;Btw imagine how you would feel if
;MsgBox/InputBox/ToolTip/FileSelectFile/FileSelectFolder
;were taken away.

;Some of the benefits of Progress:
;- do MsgBox/Progress, InputBox/Progress, Input/Progress at the same time
;- you can change the contents/properties of the Progress window
;while it is visible, without using SetTimer
;- you can change the Static control DT flags, e.g. word wrap on/off
;see: DrawText function (Windows)
;https://msdn.microsoft.com/en-us/library/windows/desktop/dd162498(v=vs.85).aspx
;- you can use DrawText to measure the necessary window size in advance
;- you can choose any font style/size
;- you can choose any background colour
;- Progress doesn't cause persistence (#Persistent),
;thus you can include scripts that use Progress in your libraries
;without side effects (cf. the Gui command)
;- I've found that I can do everything I need to do for normal scripts with either:
;MsgBox/InputBox/Progress/SplashImage/ToolTip,
;- and I've not felt particularly that anything has been *missing* that was needed
;- I've found that I don't need the Gui command apart from for full 'software' GUI scripts

;Note:
;SplashImage is useful for producing borders around windows,
;as demonstrated in one of the examples below.
;Progress can also be used to block an area of the screen,
;such as a changing timestamp on a video,
;it can also be used to preview colours to see what they will look like.

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

;list of example hotkeys:
;q:: ;Progress as a menu (e.g. Recent items)
;w:: ;get words by numbers
;e:: ;flash text with colourful background (warning: potential seizure issues)
;r:: ;change volume level (up)
;t:: ;change volume level (down)
;y:: ;view pixel maps of OCR characters
;u:: ;notify toggle status (e.g. notify toggle capslock)
;i:: ;tooltip big font
;o:: ;tooltip big font, alternative tooltip function code
;p:: ;do other things while the clock is ticking
;a:: ;do other things while the clock is ticking (temporary message)
;s:: ;do other things while the clock is ticking (turn off)
;d:: ;display date + free space
;f:: ;notification message example 1
;g:: ;notification message example 2
;h:: ;notification message example 3
;j:: ;borders around control under cursor (uses SplashImage)
;k:: ;borders around window under cursor (uses SplashImage)

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

;using Progress and Input to bring up a list of Recent items
;to select item: type in item number and press Enter
;to cancel: press Esc
q:: ;Progress as a menu (e.g. Recent items)
vLimit := 20
vPrompt := ""
VarSetCapacity(vPrompt, 100000*2)

;path of Recent folder on Windows 7
vDir1 = C:\Users\%A_UserName%\AppData\Roaming\Microsoft\Windows\Recent
if !FileExist(vDir1)
	vDir1 = C:\Documents and Settings\%A_UserName%\Recent

Loop, %vDir1%\*.*, 0, 0 ;(0/1/2=files/both/folders, 0/1=recurse no/yes)
{
	vPathLnk := A_LoopFileFullPath
	FileGetShortcut, % vPathLnk, vPath
	SplitPath, vPath, vName, vDir, vExt, vNameNoExt, vDrive
	vPrompt .= "(" A_Index ") " vName "`r`n"
	vPath%A_Index% := vPath
	if (A_Index = 20)
		break
}

Progress, zh0 b c0 fs18 w600, % vPrompt
Input, vNum, L3 T8 M, {Enter}{Esc}
vRet := ErrorLevel
Progress, Off

if InStr(vRet, "EndKey:Enter")
&& RegExMatch(vNum, "^\d+$") ;'is digit'
&& (vNum >= 1) && (vNum <= vLimit)
&& FileExist(vPath%vNum%)
{
	MsgBox, 3, , % vPath%vNum% "`r`n[choose Yes to open]"
	IfMsgBox Yes
		Run, % vPath%vNum%
}
Return

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

w:: ;get words by numbers
vList := "retain retaken retaliation retardation retention reticulation retighten retorn retraction retrain retransformation retranslation retransmission retribution retroaction retrocession retrodden retroflection retrogression retrospection retroversion retune return"
vPrompt := ""
Loop, Parse, vList, % A_Space
{
	vPrompt .= A_Index "-" A_LoopField " "
	vOpt%A_Index% := A_LoopField
}

vFormat := "zh0 b1 c0 fs18 w1000 y25"
Progress, % vFormat, % vPrompt

InputBox, vItem, , , , , 100
Progress, Off
MsgBox % vOpt%vItem%
Return

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

;04:50 25/02/2017
e:: ;flash text with colourful background (warning: potential seizure issues)
;e.g. yellow/green/yellow/green, 800 millisecond gap
vList := "FF0000,FFFF00,00FF00,0000FF"
vList := "FFFF00,00FF00"
vList .= "," vList
Loop, Parse, vList, `,
{
	vCol := A_LoopField
	;vFormat := "zh0 b1 c0 fs18 cw" vCol
	vFormat := "zh0 b1 fs18 cw" vCol
	vText := "`r`nnew AutoHotkey update available`r`n"
	Progress, % vFormat, % vText
	Sleep 800
	Progress, Off
}
Return

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

r:: ;change volume level (up)
t:: ;change volume level (down)
;if (A_TimeIdle > 200)
;	Return

SoundGet, vNum
vNum := Round(vNum) ;remove decimal part
vDiff := 10
if InStr(A_ThisHotkey, "r")
{
	vNum += vDiff
	if (vNum+vDiff > 100)
		vNum := 100
}
if InStr(A_ThisHotkey, "t")
{
	vNum -= vDiff
	if (vNum-vDiff < 0)
		vNum := 0
}
SoundSet, % vNum

Progress, zh0 b fs18 w70, % vNum
Sleep 300
Progress, Off
SoundBeep
Return

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

y:: ;view pixel maps of OCR characters
vText = ;continuation section
(
### # # ### ### # # ### ### # # ### # #
# # # #  #  # # # # # #  #  # # #   # #
### # #  #  # # ### # #  #  ##  ### ###
# # # #  #  # # # # # #  #  # # #    #
# # ###  #  ### # # ###  #  # # ###  #
)
;vText := StrReplace(vText, "#", "@")
;vText := StrReplace(vText, "#", "|")
;vText := StrReplace(vText, "#", "-")
;vText := StrReplace(vText, "#", "\")
;vText := StrReplace(vText, "#", "0")
;vText := StrReplace(vText, "#", "1")
;vText := StrReplace(vText, "#", "H")
;vText := StrReplace(vText, "#", "~")
;vText := StrReplace(vText, "#", "▓") ;Chr(9619)
vText := StrReplace(vText, "#", "█") ;Chr(9608)

Progress, zh0 b c0 fs24 w1000, % vText, , , Courier New
Sleep 1000
Progress, Off
Return

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

u:: ;notify toggle status (e.g. notify toggle capslock)
vFormat := "zh0 b1 c0 fs18 x1000 y100 w150"
Loop
{
	vState := GetKeyState("CapsLock", "T") ? "on" : "off"
	if !(vState = vState2)
		Progress, %vFormat%, capslock %vState%
	vState2 := vState
	Sleep 100
}
Return

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

i:: ;tooltip big font
vFormat = zh0 b1 c0 fs18 ;border + left
Progress, %vFormat%, HELLO WORLD
WinGet, hWnd, ID, %A_ScriptName% ahk_class AutoHotkey2
Sleep 1000
ControlSetText, Static1, Hello World, ahk_id %hWnd%
Sleep 1000
ControlSetText, Static1, hello world, ahk_id %hWnd%
Sleep 1000
Progress, Off
Return

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

o:: ;tooltip big font, alternative tooltip function code
JEE_Progress2("AUTO", -1)
Sleep 500
Progress, Off

JEE_Progress2("AUTOHOTKEY", 500)

;vText := "AutoHotkey"
vText := "AUTOHOTKEY"
vText2 := ""
Loop, Parse, vText
{
	vText2 .= A_LoopField
	JEE_Progress2(vText2, 250)
}

;vText := "Au to Hot key"
vText := "AU TO HOT KEY"
vText2 := ""
Loop, Parse, vText, % A_Space
{
	vText2 .= A_LoopField
	JEE_Progress2(vText2, 500)
}
Return

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

;vFormat := "zh0 b c0 fs18" ;no border + left-aligned text
;vFormat := "zh0 b1 fs18" ;has border + centred text
;vFormat := "zh0 b1 c0 fs18" ;has border + left-aligned text
JEE_Progress2(vText, vSleep=500, vFormat="zh0 b1 c0 fs18")
{
global vJeeProgressFormat
if !(vJeeProgressFormat = "")
	vFormat := vJeeProgressFormat
Progress, % vFormat, % vText
if (vSleep = -1)
	Return
Sleep, % vSleep
Progress, Off
Return
}

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

p:: ;do other things while the clock is ticking
FormatTime, vTime, , HH:mm:ss
vFormat = zh0 b1 c0 fs18 x1000 y100 w150 ;border + left-aligned text
Progress, %vFormat%, %vTime%
SetTimer, Change_Progress, 1000

MsgBox % "a"
MsgBox % "b"
MsgBox % "c"
Return

Change_Progress:
WinGet, hWnd, ID, %A_ScriptName% ahk_class AutoHotkey2
if !hWnd
	Return
FormatTime, vTime, , HH:mm:ss
if !(vTime = vTime2)
	ControlSetText, Static1, %vTime%, ahk_id %hWnd%
vTime2 := vTime
Return

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

a:: ;do other things while the clock is ticking (temporary message)
SetTimer, Change_Progress, Off
ControlSetText, Static1, MESSAGE, ahk_id %hWnd%
SetTimer, Change_Progress, On
Return

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

s:: ;do other things while the clock is ticking (turn off)
SetTimer, Change_Progress, Off
Progress, Off
Return

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

d:: ;display date + free space
vDate := A_Now
FormatTime, vDate1, % vDate, ddd
FormatTime, vDate2, % vDate, HH:mm dd/MM/yyyy
DriveSpaceFree, vDriveSpaceFree, C:\

vText := vDate1 " " vDate2 "`r`n" vDriveSpaceFree " MB" "`r`n" "more info" "`r`n" "more info"
JEE_Progress2(vText, 1000)
Return

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

f:: ;notification message example 1
Progress, zh0 b1 fs10 y300, `r`nctrl+z disabled for Explorer windows`r`n, , , Tahoma
Sleep 500
Progress, Off
Return

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

g:: ;notification message example 2
vFormat := "zh0 b1 fs18" ;has border + centred text
JEE_Progress2("`r`nsave blocked`r`n", 500, "zh0 b1 fs18 w240")
Return

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

h:: ;notification message example 3
JEE_Progress2("note:`r`ncontains lone Chr(13)s", 1000)
Return

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

j:: ;borders around control under cursor (uses SplashImage)
MouseGetPos, , , hWnd
WinGetPos, vPosX, vPosY, vPosW, vPosH, A
JEE_Borders(vPosX, vPosY, vPosW, vPosH)
Return

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

k:: ;borders around window under cursor (uses SplashImage)
MouseGetPos, , , , hCtl, 3
WinGetPos, vPosX, vPosY, vPosW, vPosH, ahk_id %hCtl%
JEE_Borders(vPosX, vPosY, vPosW, vPosH)
Return

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

;show borders around a window/control/point

JEE_Borders(vPosX, vPosY, vPosW=0, vPosH=0, vTime=1000, vCol="FFFF00")
{
CoordMode, Pixel, Screen
vBorderH := 5 ;height of border
vBorderW := 5 ;width of border
SplashImage, 1:, % "B W" vPosW+(2*vBorderW) "H" vBorderH "X" vPosX-vBorderW "Y" vPosY-vBorderH "Cw" vCol, , , SP1 ;top
SplashImage, 2:, % "B W" vPosW+(2*vBorderW) "H" vBorderH "X" vPosX-vBorderW "Y" vPosY+vPosH "Cw" vCol, , , SP2 ;bottom
SplashImage, 3:, % "B W" vBorderW "H" vPosH+(2*vBorderH) "X" vPosX-vBorderW "Y" vPosY-vBorderH "Cw" vCol, , , SP3 ;left
SplashImage, 4:, % "B W" vBorderW "H" vPosH+(2*vBorderH) "X" vPosX+vPosW "Y" vPosY-vBorderH "Cw" vCol, , , SP4 ;right
Sleep % vTime
SplashImage, 1: Off
SplashImage, 2: Off
SplashImage, 3: Off
SplashImage, 4: Off
Return
}

;==================================================
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: 9592
Joined: 30 Sep 2013, 04:07
Contact:

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

25 Feb 2017, 18:12

Progress and SplashImage were removed on the premise that they can be easily re-implemented using the Gui commands, which allows the user to customise it however they want. Having more done in script means more code for users to learn from, and far more "developers" available to maintain or improve on the code. Another point is to have two less redundant commands with unique syntax to learn (although that would probably be negated by including them as part of the stdlib).

None of your examples utilise the full range of functionality of Progress or SplashImage, so are even easier to implement with the Gui command than Progress and SplashImage would be to re-implement in whole.
;Btw imagine how you would feel if
;MsgBox/InputBox/ToolTip/FileSelectFile/FileSelectFolder
;were taken away.
ToolTip/FileSelect/DirSelect (v2) are impossible to implement with the Gui commands, and non-trivial to implement with DllCall.

MsgBox is extremely trivial to implement with DllCall. I wouldn't be overly bothered by its removal, except that it is used very, very frequently.

InputBox is trivial to implement with Gui. I wouldn't be overly bothered by its removal.
Yes but that would search in the forward direction, right? What if you want to search backwards?
Right you are. However, that only applies to InStr, and still doesn't explain the purpose of Chr(1).
User avatar
jeeswg
Posts: 6902
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

25 Feb 2017, 19:53

It's easy to create custom GUIs that *look* like the 'notify' commands, but my issue is that they should *act* like the 'notify' commands.

Let's say I want to have a custom MsgBox/InputBox function, in a library used by hundreds of scripts, and I don't want to modify those scripts. A script should be able to call MyMsgBoxFunc, as easily as it would the default MsgBox command. I.e. without becoming Persistent, or having to take over handling for the message queue, or using OnMessage, or using SetTimer, or having issues with 'Thread, Priority'.

I haven't been more vocal on this yet, because I want to perform tests that require my GUI via dll functions project to be complete.

I believe that the argument for removing Progress/SplashImage, was to save space in the AutoHotkey exe file, currently around 1.2MB for the x64 v1 version.

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

I had felt reasonably satisfied that:
vIsAhkV1 := (SubStr(A_AhkVersion,1,2) = "1.")
vPos := InStr(vText, vNeedle, 0, vIsAhkV1-1)
would be an effective workaround to perform a backwards search. However, you were casting doubt on almost all methods to determine vIsAhkV1.

So assuming there is no reliable method, if searching from the last character backwards a hack is to add a character, not contained in the needle, to the end, giving the following two-way compatible approach:

Code: Select all

Loop, 65535
if !InStr(vNeedle, vChar := Chr(A_Index))
	break
vPos := InStr(vText vChar, vNeedle, 0, -1)[/c]
That is a first attempt, but I don't know if there is a more general solution for this, if it is assumed that you cannot determine vIsAhkV1 reliably.
Last edited by jeeswg on 25 Feb 2017, 20:58, 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
lexikos
Posts: 9592
Joined: 30 Sep 2013, 04:07
Contact:

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

25 Feb 2017, 20:55

However, you were casting doubt on almost all methods to determine vIsAhkV1.
No, I was suggesting that relying on "vIsAhkV1" in the first place is unwise, whichever way you determine it. Perhaps it is a necessary evil for InStr-in-reverse.
A script should be able to call MyMsgBoxFunc, as easily as it would the default MsgBox command. I.e. without becoming Persistent,
I suggest that you read v2-changes, a few times if necessary, and actually use v2 more, before making further "suggestions".

I'm telling you Progress and SplashImage can be easily re-implemented with the Gui commands in v2. As I've already told you, the persistence issue has already been fixed in v2-alpha. Also, any function/command can be called with either command or function syntax.

Currently having a Gui visible keeps the script persistent in v2-alpha, but it would be trivial to offer an option to opt-out of persistence for a specific Gui, in case the author relies on the script exiting without having first hidden the Progress/SplashImage window.
or having to take over handling for the message queue
I don't recall seeing any scripts that do this, or know of any reason to do this.
or using OnMessage
Aside from persistence, what problem do you have with OnMessage, and why would it be required for Progress/SplashImage? Perhaps you are unaware that you can register multiple monitors for a given message.
or using SetTimer
What problem do you have with SetTimer, and why would it be required for Progress/SplashImage?
or having issues with 'Thread, Priority'.
You mentioned this before, but I ignored it. I don't even want to know what problems you imagine having with it. If you never change a thread's priority, you won't have "issues with 'Thread, Priority'".
Thread wrote:Due to its ability to buffer events, the command Critical is generally superior to Thread Priority.
I believe that the argument for removing Progress/SplashImage, was to save space in the AutoHotkey exe file
What's your point?
Progress and SplashImage: Although these are more convenient than GUI in some cases, perhaps their removal can be justified by the fact that it would be quite a big reduction in code size, and their syntax is a bit clumsy. Also, maintainability is a factor because if these commands are kept, they'll have to be kept in sync with any changes in Vista and future OSes. Finally, people could continue to run such scripts with v1 if they really need those features. On the other hand, Progress/Splash are clearly convenient in some cases, and code size has become less of a concern due to the capabilities of modern hardware.
-> Perhaps a volunteer can be found to write up a function-substitute for Progress/Splash, because coming up with an exact substitute would be costly in development time.
Source: AutoHotkey v2
That was Chris. However, I alone made the decision and implemented the change.
if searching from the last character backwards a hack is to add a character, not contained in the needle, to the end, giving the following two-way compatible approach:
Firstly, you did not add Chr(1) to the needle in your previous post; you added it to the haystack.

Secondly, your new code does not work.

If you add a character which isn't in the haystack to the needle, the result will always be 0. If you append a character which isn't in the needle to the haystack, it will never have any effect. If you append to both, the string will only ever be found at the very end of the haystack.
User avatar
jeeswg
Posts: 6902
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

25 Feb 2017, 22:04

Re. InStr:
vChar is appended to the haystack, I fixed it above. The effect of adding a character to the end of Haystack relates to StartingPos:
InStr(Haystack, Needle, CaseSensitive, StartingPos)
Haystack := "12345D"
Needle := "5"
StartingPos := -1
In AHK v1, a StartingPos of -1 will start searching from 5 backwards.
In AHK v2, a StartingPos of -1 will start searching from D backwards.
Where Needle does not contain D (the dummy character).

Re. GUIs:
I had read that *using* the Gui command would cause persistence in a script, and that the finer details where yet to be settled. However, I stated I wanted to do further tests (and reading) before commenting further.

I first wanted to achieve the 'MyMsgBoxFunc' functionality in AHK v1, and that would require creating GUIs via dll functions. I find it absolutely astonishing that no-one wants to have GUI windows in library scripts that do not interfere with the scripts that call them.

Issues with Critical are that hotkeys can be triggered while MsgBox is on and that hotkeys are buffered and not discarded. At least from my perspective as a beginner at the time, to me Critical means that no hotkey should be able to interrupt it. Anyhow the 'MyMsgBoxFunc' would have to be able to handle both Critical and Thread (e.g. issues with a function calling another a function while in that mode, but again, I want to check further before commenting further).

If it ain't broke, don't fix it. I'd put a warning on the documentation for Progress if and when there was a problem with it. I do not find the saving in disk space an overwhelming and compelling argument. Also removing it must be weighed against the disruption and inconvenience. Has anyone made the replacement custom GUIs yet? There is an argument for discarding code, when it's not needed, when scripts are compiled, but I find compiled exes to be reasonably small as they are, it's not a personal priority of mine but I respect the motivations behind it.
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: 6902
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

26 Feb 2017, 00:44

vIsAhkV1 := SubStr(1,0)
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 48 guests