I seem to recall that $(...) didn't use to work in target parameters of events but only the matchtext sections (ie. on *:text:$(...):#: would work but on *:text:*:$(...): wouldn't) - either I'm imagining it or it's been fixed, so disregard my post.
I also misunderstood what the script was doing.