Page 1 of 2

Hotstring Bug?

Posted: 30 Nov 2018, 09:12
by jmeneses
Not work in AHK v1.1.30.01 64-bit/Unicode but work fine in v1.1.30.00 64-bit/Unicode

Code: Select all

#NoEnv
#SingleInstance force
SetTitleMatchMode 2
SetKeyDelay, -1
#Persistent

#If isExplorerActive() 
Hotstring(":*X:" "T1" , "MisHostrings" ) 
#If

Return

MisHostrings() {
  MsgBox 0x40000, % A_ThisFunc, % "Què!! " A_ThisHotkey
}

IsExplorerActive() {
ControlGetFocus, focusedControl, A
Return (WinActive("ahk_class CabinetWClass")&&(focusedControl=="Edit1"))
}

Re: What am I doing wrong?

Posted: 01 Dec 2018, 12:12
by CyL0N
Works fine on my v1.1.30.01 64-bit/Unicode, Win7Ultimate X64.

Re: What am I doing wrong?

Posted: 01 Dec 2018, 13:27
by jmeneses
CyL0N wrote:
01 Dec 2018, 12:12
Works fine on my v1.1.30.01 64-bit/Unicode, Win7Ultimate X64.
really? I don't understand, you get the msgbox? :crazy:

Re: What am I doing wrong?

Posted: 01 Dec 2018, 18:23
by CyL0N
:facepalm: Apologies that was late night clumsiness,i glazed over the MsgBox, i saw a literal replacement & i guess thought that was meant to be the case.

This must be the cause though: Recent Changes To 1.1.30.01...
  • 1.1.30.01 - November 11, 2018
    • Fixed escape sequences in one-line hotstrings with 'X' option.
I tried a number of variations,but i don't know how the change is supposed to work,if at all it didn't break the X option,because it looks like it did,'X' is just being ignored.

Possibly Rename this thread to 1.1.30.01 - Hotstring Bug?.

Re: Hotstring Bug?

Posted: 02 Dec 2018, 04:36
by jmeneses
Thank you
I'll take care of you

Re: Hotstring Bug?

Posted: 06 Dec 2018, 13:56
by jmeneses
Someone has obtained the msgbox with the latest version of AHK?

Re: Hotstring Bug?

Posted: 06 Dec 2018, 14:21
by safetycar
Looks buggy.

Out of this:

Code: Select all

:X:T1::MisHostrings()
Hotstring(":X:T2", MisHostrings)
Hotstring(":X:T3", MisHostrings())
Hotstring(":X:T4", "MisHostrings")
Hotstring(":X:T5", "MisHostrings()")
Only T1 shows the MsgBox.

Re: Hotstring Bug?

Posted: 06 Dec 2018, 14:27
by FanaticGuru
safetycar wrote:
06 Dec 2018, 14:21
Looks buggy.

Out of this:

Code: Select all

:X:T1::MisHostrings()
Hotstring(":X:T2", MisHostrings)
Hotstring(":X:T3", MisHostrings())
Hotstring(":X:T4", "MisHostrings")
Hotstring(":X:T5", "MisHostrings()")
Only T1 shows the MsgBox.
I agree. I can't get the "X" option to work when creating a hotstring with the Hotstring function.

FG

Re: Hotstring Bug?

Posted: 07 Dec 2018, 11:07
by jmeneses
It's a bug

Re: Hotstring Bug?

Posted: 07 Dec 2018, 12:14
by swagfag

Re: Hotstring Bug?

Posted: 07 Dec 2018, 13:12
by Helgef
safetycar wrote:
06 Dec 2018, 14:21
Looks buggy.

Out of this:

Code: Select all

:X:T1::MisHostrings()
Hotstring(":X:T2", MisHostrings)
Hotstring(":X:T3", MisHostrings())
Hotstring(":X:T4", "MisHostrings")
Hotstring(":X:T5", "MisHostrings()")
Only T1 shows the MsgBox.
See auto execute .

Re: Hotstring Bug?

Posted: 07 Dec 2018, 14:02
by FanaticGuru
Helgef wrote:
07 Dec 2018, 13:12
safetycar wrote:
06 Dec 2018, 14:21
Looks buggy.

Out of this:

Code: Select all

:X:T1::MisHostrings()
Hotstring(":X:T2", MisHostrings)
Hotstring(":X:T3", MisHostrings())
Hotstring(":X:T4", "MisHostrings")
Hotstring(":X:T5", "MisHostrings()")
Only T1 shows the MsgBox.
See auto execute .
I don't believe that was meant as a literal working example. T2, T3, T5 will not even run as they throw a syntax error.

The point being that the Hotstring function appears to now be expecting a Function Reference like produced by Func to work at all and running a subroutine by label appears to not be an option.

This works: Hotstring(":*X:" "T1" , Func("MisHostrings") ).

It is fine to work like this but it needs to be documented that is how it works now and it is somewhat incomplete.

This is how it works in v2 and probably the way it should work in v1.

Code: Select all

Hotstring(":*X:" "T1" , "HS1")  ;  function because only function exist
Hotstring(":*X:" "T2" , Func("HS2"))  ; function because function reference
Hotstring(":*X:" "T3" ,"HS3") ; label because only label exist
Hotstring(":*X:" "T4" ,"HS4") ; label because function and label exist but defaults to label
Hotstring(":*X:" "T5" , Func("HS4")) ; function because function reference

Esc::ExitApp

HS1() 
{
  MsgBox("Function: " A_ThisFunc)
}

HS2() 
{
  MsgBox("Function: " A_ThisFunc)
}

HS4() 
{
  MsgBox("Function: " A_ThisFunc)
}

HS3:
  MsgBox("Label: " A_ThisLabel)
return

HS4:
  MsgBox("Label: " A_ThisLabel)
return
FG

Re: Hotstring Bug?

Posted: 18 Dec 2018, 18:17
by swagfag
so whats the consensus on this?

Re: Hotstring Bug?

Posted: 31 Dec 2018, 13:29
by JnLlnd
I found the bug mentioned earlier after upgrading from 1.1.28.00 to v1.1.30.01. But is was intermittent. If found that the X command is ignored at the first load of the Hotstring but is executed after the Hotstring is turned OFF and ON again.

Code: Select all

#SingleInstance force

strHotstring := ":X*:#go#"
firstTime := true

MsgBox, Press Alt + L to load the hostring`n`n(requires v1.1.30.01 to show the bug)

!l:: ; load
Hotstring(strHotstring, "Go", "On") ; this type "Go" instead of executing the label "Go:"
if (firstTime)
	MsgBox, Hotstring "%strHotstring%" turned ON.`n`nTry it: type "#go#". Instead of eXecuting the hotstring, it will type "Go" (as would do a non "X" hotstring).`n`nThen, press Alt + R to reload the hostring (turn OFF and ON again).
else
	MsgBox, Hotstring "%strHotstring%" turned ON again.`n`nTry it again: type "#go#". Now, it will work.
return

!r:: ; reload
Hotstring(strHotstring, "Go", "Off") ; this type "Go" instead of executing the label "Go:"
MsgBox, Hotstring "%strHotstring%" turned OFF
firstTime := false
gosub, !l
return

Go:
MsgBox, The hotstring "%A_ThisHotkey%" was eXecuted!
return

Re: Hotstring Bug?

Posted: 31 Dec 2018, 13:48
by FanaticGuru
JnLlnd wrote:
31 Dec 2018, 13:29
I found the bug mentioned earlier after upgrading from 1.1.28.00 to v1.1.30.01. But is was intermittent. If found that the X command is ignored at the first load of the Hotstring but is executed after the Hotstring is turned OFF and ON again.

Code: Select all

#SingleInstance force

strHotstring := ":X*:#go#"
firstTime := true

MsgBox, Press Alt + L to load the hostring`n`n(requires v1.1.30.01 to show the bug)

!l:: ; load
Hotstring(strHotstring, "Go", "On") ; this type "Go" instead of executing the label "Go:"
if (firstTime)
	MsgBox, Hotstring "%strHotstring%" turned ON.`n`nTry it: type "#go#". Instead of eXecuting the hotstring, it will type "Go" (as would do a non "X" hotstring).`n`nThen, press Alt + R to reload the hostring (turn OFF and ON again).
else
	MsgBox, Hotstring "%strHotstring%" turned ON again.`n`nTry it again: type "#go#". Now, it will work.
return

!r:: ; reload
Hotstring(strHotstring, "Go", "Off") ; this type "Go" instead of executing the label "Go:"
MsgBox, Hotstring "%strHotstring%" turned OFF
firstTime := false
gosub, !l
return

Go:
MsgBox, The hotstring "%A_ThisHotkey%" was eXecuted!
return
Interesting.

This does at least provide a work around as shown below.

Code: Select all

Hotstring(":*X:" "T1" , "HS1")  ;  function because only function exist
Hotstring(":*X:" "T1" , "HS1", "On")  ; WORKAROUND function because only function exist

Hotstring(":*X:" "T2" , Func("HS2"))  ; function because function reference

Hotstring(":*X:" "T3" ,"HS3") ; label because only label exist
Hotstring(":*X:" "T3" ,"HS3", "On") ; WORKAROUND label because only label exist

Hotstring(":*X:" "T4" ,"HS4") ; label because function and label exist but defaults to label
Hotstring(":*X:" "T4" ,"HS4", "On") ; WORKAROUND label because function and label exist but defaults to label

Hotstring(":*X:" "T5" , Func("HS4")) ; function because function reference

Esc::ExitApp

HS1() 
{
  MsgBox % "Function: " A_ThisFunc
}

HS2() 
{
  MsgBox % "Function: " A_ThisFunc
}

HS4() 
{
  MsgBox % "Function: " A_ThisFunc
}

HS3:
  MsgBox % "Label: " A_ThisLabel
return

HS4:
  MsgBox % "Label: " A_ThisLabel
return
For string function and label references to work you just need to do an On command for the hotstring. You don't have to turn it Off in order for this to work.

With the workaround all the Hotstrings work as expected in the example above.

FG

Re: Hotstring Bug?

Posted: 31 Dec 2018, 14:59
by JnLlnd
FanaticGuru wrote:
31 Dec 2018, 13:48
For string function and label references to work you just need to do an On command for the hotstring. You don't have to turn it Off in order for this to work.

With the workaround all the Hotstrings work as expected in the example above.
In my example, it is a label (Go:) and it would not work until, after the hotstring is created, it is turned OFF and turned ON again.

Re: Hotstring Bug?

Posted: 31 Dec 2018, 18:32
by FanaticGuru
JnLlnd wrote:
31 Dec 2018, 14:59
FanaticGuru wrote:
31 Dec 2018, 13:48
For string function and label references to work you just need to do an On command for the hotstring. You don't have to turn it Off in order for this to work.

With the workaround all the Hotstrings work as expected in the example above.
In my example, it is a label (Go:) and it would not work until, after the hotstring is created, it is turned OFF and turned ON again.
No need to turn it Off, just create and then turn On in two separate commands:

Code: Select all

strHotstring := ":X*:#go#"
Hotstring(strHotstring, "Go") ; first to create
Hotstring(strHotstring, "Go", "On") ; then again with On to fix bug
return

Go:
  MsgBox, The hotstring "%A_ThisHotkey%" was eXecuted!
return
You could do it this way:

Code: Select all

Hotstring(strHotstring, "Go", "On") ; first to create
Hotstring(strHotstring, "Go", "On") ; then again to fix bug
The point being that you have to use "On" with a pre-existing Hotstring. Turning it Off is irrelevant. It is the "On" with an existing hotstring that makes it work. You can turn a Hotstring On that is already On.

Not to get side tracked though, this is definitely buggy. And this is only a in an emergency do-it-twice workaround but if you really need it then it should work and not break the script once the bug is fixed.

FG

Re: Hotstring Bug?

Posted: 31 Dec 2018, 19:33
by JnLlnd
FanaticGuru wrote:
31 Dec 2018, 18:32
The point being that you have to use "On" with a pre-existing Hotstring. Turning it Off is irrelevant. It is the "On" with an existing hotstring that makes it work. You can turn a Hotstring On that is already On.

Not to get side tracked though, this is definitely buggy. And this is only a in an emergency do-it-twice workaround but if you really need it then it should work and not break the script once the bug is fixed.
Thanks FG, I got you. And, as you said, this should be fixed anyway (thanks to Lexikos).

Re: Hotstring Bug?

Posted: 01 Jan 2019, 06:55
by jmeneses
Thaks everybody and appy good year forever friends

Re: Hotstring Bug?  Topic is solved

Posted: 21 Apr 2019, 17:46
by lexikos
This was fixed in v1.1.30.02 (thanks to Helgef).