Page 1 of 1

FindClick Pass a Variable

Posted: 27 Sep 2022, 17:13
by martipe1
I want to use the FindClick function, but instead of writing all path and image name, I would like to pass a variable containing that info but all my attempts end with an error message saying "The following variable contains an illegal character".

I know I'm missing the quotes, but my idea is something similar to:

Path = D:\Documents\AutoHotkey\Pictures\
Match = %Path%Image.png

FindClick(%Match%)

Thank you for your help

Re: FindClick Pass a Variable  Topic is solved

Posted: 27 Sep 2022, 17:25
by boiler
No % signs in expressions (normally), which function parameters always are. So to pass the value of your variable, it would be:

Code: Select all

Path = D:\Documents\AutoHotkey\Pictures\
Match = %Path%Image.png
FindClick(Match)
or using all expressions:

Code: Select all

Path := "D:\Documents\AutoHotkey\Pictures\"
Match := Path . "Image.png"
FindClick(Match)
The reason for the error message you received is that you tried to pass the value of a variable named D:\Documents\AutoHotkey\Pictures\Image.png, which can't be a variable name because it contains unallowable characters. It might help you to understand with this working example that implements a double-deref (or it might confuse you more):

Code: Select all

Path := "D:\Documents\AutoHotkey\Pictures\"
Match := Path . "Image.png"
Var := "Match"
FindClick(%Var%)

Re: FindClick Pass a Variable

Posted: 27 Sep 2022, 17:54
by martipe1
Thank you very much for your answer.

I wouldn't let the opportunity to pass without congratulating you on your outstanding work and helping many people.

Thanks!!!!!