lunacy471 wrote: ↑
% "image " . (number - A_Index + 1) . png
% means variable right
A
% followed by a space at the beginning of a command parameter means we are
forcing an expression, so this parameter will be an expression rather than using command (or legacy) syntax.
lunacy471 wrote: ↑
so in the case my images are all saved into C:desktop\folder\, and the names are just 10.png down to 1.png, where would i put that in? im assuming (number-A_Index+1) takes care of the image names, but where do I add the rest of the path in?
would it be like this?
ImageSearch, FoundX, FoundY, 0, 0, 1000, 400, % "C:desktop\folder\ " . (number - A_Index + 1) . "png"
Yes, exactly — except I accidentally left the dot out of the extension, so it would be ".png" on the end instead of "png". You also left out the \ after the drive letter, so it would be:
Code: Select all
ImageSearch, FoundX, FoundY, 0, 0, 1000, 400, % "C:\desktop\folder\ " . (number - A_Index + 1) . ".png"
…but usually there is the username in a desktop path, so that should be in there too, but instead of explicitly putting all that in there, we can just use the built-in variable to the desktop, like this:
Code: Select all
ImageSearch, FoundX, FoundY, 0, 0, 1000, 400, % A_Desktop . "\folder\ " . (number - A_Index + 1) . ".png"
lunacy471 wrote: ↑
so in the case i select 10 as my number does it count down from 10 or up towards 10? I am still pretty new to ahk and haven't really seen this kind of use for image search yet
The built-in variable
A_Index contains the number of the loop iteration, so in this case it is 1 the first time through, then it becomes 2, then 3, all the way to 10. That’s why I put the math into the expression (number - A_Index + 1), which will be 10 the first time through the loop (10 - 1 + 1), then 9 the next time through (10 - 2 + 1), and so on until the last time where it is (10 - 10 + 1), which equals 1.