FindClick Pass a Variable Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
martipe1
Posts: 40
Joined: 05 Apr 2018, 10:42

FindClick Pass a Variable

Post by martipe1 » 27 Sep 2022, 17:13

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

User avatar
boiler
Posts: 17068
Joined: 21 Dec 2014, 02:44

Re: FindClick Pass a Variable  Topic is solved

Post by boiler » 27 Sep 2022, 17:25

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%)

martipe1
Posts: 40
Joined: 05 Apr 2018, 10:42

Re: FindClick Pass a Variable

Post by martipe1 » 27 Sep 2022, 17:54

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!!!!!

Post Reply

Return to “Ask for Help (v1)”