A_ThisFunc not working!

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User
Posts: 407
Joined: 26 Jun 2017, 08:12

A_ThisFunc not working!

29 Dec 2018, 15:16

A_ThisFunc does not work in the code below! Any suggestions?

Code: Select all

test()


test()	;____________________ function _________________
{
static x := A_ThisFunc


msgbox, % x
}
gregster
Posts: 9111
Joined: 30 Sep 2013, 06:48

Re: A_ThisFunc not working!

29 Dec 2018, 15:34

Works as advertised, I would say.
My understanding is, solely based on the information available in the AHK docs, that A_thisFunc is only available at the time a function is executing:
A_ThisFunc
The name of the user-defined function that is currently executing (blank if none)
But expressions in static variables are looked-up much sooner, before any function can be executed:
Static var := expression is supported. All such expressions are evaluated immediately before the script's auto-execute section in the order they are encountered in the script.
(https://autohotkey.com/docs/Functions.htm#static)

Hence, x is blank here.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, Google [Bot], peter_ahk and 367 guests