@Mrcbst, my best bet is that when the image appears elsewhere, it looks slightly different on a pixel level (for example antialiasing causes this in many programs and browsers). To test this theory out: capture a screenshot of the working image that can be found, and a screenshot of the non-working image. Then set search scope to the whole screen and check if both can be found.
Other possible causes: your search scope might be too small and the image appears outside of it. You can check that by drawing out the search range with FindText().RangeTip.
Of course there is a very slight chance of a bug in FindText, but since MultiColor search has worked so far without any bug reports it's unlikely...
Note: providing a test image to try your Text out with would also be of great help in debugging.
FindText tutorial
Re: FindText tutorial
Yea, that was it. Basically the image was slightly varying in each possible slot. Some images worked because the colors were so similar that setting a basic threshold seemed to capture it anyways, but images with strongly contrasting colors need to be searched for, for each slot individually, basically I was searching for 2 images, one was basically a brownish/orange, the other was white and purple, the brownish orange one worked wherever it popped up, the white/purple one requires me to append each possible image for each slot.Descolada wrote: ↑05 Jul 2022, 00:20@Mrcbst, my best bet is that when the image appears elsewhere, it looks slightly different on a pixel level (for example antialiasing causes this in many programs and browsers). To test this theory out: capture a screenshot of the working image that can be found, and a screenshot of the non-working image. Then set search scope to the whole screen and check if both can be found.
Other possible causes: your search scope might be too small and the image appears outside of it. You can check that by drawing out the search range with FindText().RangeTip.
Of course there is a very slight chance of a bug in FindText, but since MultiColor search has worked so far without any bug reports it's unlikely...
Note: providing a test image to try your Text out with would also be of great help in debugging.
It's working now though, so thanks Oh, it wasn't anti-aliasing in this case, I turned it all off and it made no difference.
Re: FindText tutorial
When I follow the getting started section and run the first test program I get the error:
Error at line 1879 in #include file "C:\Users\Me\Documents\AutoHotkey\Lib\FindText.ahk".
Line Text: Switch cmd
Error: This line does not contain a recognized action.
Any idea what I could do to fix this or what I've done wrong? Thank you!
Error at line 1879 in #include file "C:\Users\Me\Documents\AutoHotkey\Lib\FindText.ahk".
Line Text: Switch cmd
Error: This line does not contain a recognized action.
Any idea what I could do to fix this or what I've done wrong? Thank you!
Re: FindText tutorial
I've got another question regarding efficiency. How would this method compare in terms of efficiency/speed to pixel search, if you're searching a single pixel. Would it be noticeably faster? Not noticeably faster? For clarity, it would be searching somewhere between say 18 and 24 or so individual 1x1 locations.
Re: FindText tutorial
@Mrcbst, I haven't done any speed tests for that, since there are better options available for single pixel search. My guess is that it will be slower than PixelSearch with the Fast option if you take a new screenshot every time, but faster than PixelSearch if you search your 18-24 pixels on the same screenshot. If you decide to run the tests on that, be sure to share the results here
Also perhaps take a look at this thread and this library, they use similar methods as FindText does.
Also perhaps take a look at this thread and this library, they use similar methods as FindText does.
Re: FindText tutorial
Those look interesting, thanks. I've got another question. When using the multicolor search with the findmulticolor box ticked, and you are adding colors via clicking on each pixel. What happens/how does the script handle pixels you don't click to add that color to the search? Are those pixels left out of the search?
Re: FindText tutorial
@Mrcbst, yes, the pixels that were not selected should be ignored by FindText. That is to say that the script will look for a place on the screen that has your selected pixel colors at the same relative locations to each other.
So if you select two pixels right next to each other, then this would be similar to looking for the first pixel with PixelSearch, and then checking if the pixel next to that one matches as well; if not, then the next pixel will be searched that matches the first pixel color and so on.
So if you select two pixels right next to each other, then this would be similar to looking for the first pixel with PixelSearch, and then checking if the pixel next to that one matches as well; if not, then the next pixel will be searched that matches the first pixel color and so on.
Re: FindText tutorial
Alright, thanks for the info
Re: FindText tutorial
Hello,
Thank you for your very helpful tutorial!
How can i look at the current mouse position. Take there a small screenshot and stop click when the screenshot changes/ when the screen changes at that position?
Thank you!
Thank you for your very helpful tutorial!
How can i look at the current mouse position. Take there a small screenshot and stop click when the screenshot changes/ when the screen changes at that position?
Thank you!
Code: Select all
1::
MouseGetPos, StartX1, StartY1
FindText().ScreenShot(StartX1-20,StartY1-20,StartX1+20,StartY1+20)
return
2::
MouseGetPos, StartX1, StartY1
Loop,20 {
Text:="|<(IMAGE 1)>*20gfgfrdfd9534jdfd74313"
if (ok := FindText(X,Y,StartX1-20,StartY1-20,StartX1+20,StartY1+20,0.000001,0.000001, Text))
{
break
}
else
{
Click
}
} ;Loop Ende
}
return
Re: FindText tutorial
@John1, what you want might be possible with FindText, but it isn't built for that... I would recommend using another function such as ScrCmp by SKAN, much easier.
Re: FindText tutorial
@Descolada Thank you a lot for your reply!
Re: FindText tutorial
@Descolada
Hello,
i have another question.
At 8) FindText combination lookup. it says
Have a good day.
Hello,
i have another question.
At 8) FindText combination lookup. it says
My question is: is it possible to change the maximum of pixels in x-axis it can be away for example something to 1-5 pixels?where "key" can be a maximum of 20 pixels away from "auto" in the x-axis and 10 pixels away
Thank you!Text:="|<auto>*159$40.0000k000003000000A00DVUnw7lr6371nUAMAA630FUkkkAT63330rgMAAA1kFUkkkD363330wAAAA62vkvkkQtt1v1kS8"
Text.="|<hot>*152$29.U00010000200014000280004Hk7kzxktktVVUkX161V43A3286M24EAkA8UNUMF0lUUW1Xb1g31s1s"
MsgBox, Looking for "auto" and "hot"
ok:=FindText(X,Y,,,,,,,Text) ; FindText will return all locations of both "auto" and "key" separately
for k, v in ok
FindText().MouseTip(v.x, v.y)
MsgBox, Looking for "auto" followed by "hot"
ok:=FindText(X,Y,,,,,,,Text,,,1) ; FindText will return all locations of "auto" followed by "key", where "key" can be a maximum of 20 pixels away from "auto" in the x-axis and 10 pixels away in the y-axis
for k, v in ok
FindText().MouseTip(v.x, v.y)
Have a good day.
Re: FindText tutorial
@John1, yes, these can be changed by supplying the offsetX and offsetY arguments of the FindText function. By default (if not supplied) they are 20 and 10.
Re: FindText tutorial
@Descolada
Thank you for your reply!
Version 1: works fine
Version 2: works not. did i wrote it correct?
already when i just add one comma it works not.
Thank you for your reply!
Version 1: works fine
Code: Select all
if (ok := FindText(X,Y,0,0,0,0,0.000001,0.000001, Text,,0,["WORD 1 WORD 2"]))
{
MouseMove, X, Y, 0
}
Code: Select all
if (ok := FindText(X,Y,0,0,0,0,0.000001,0.000001, Text,,0,,,,20,10,["WORD 1 WORD 2"]))
{
MouseMove, X, Y, 0
}
Code: Select all
if (ok := FindText(X,Y,0,0,0,0,0.000001,0.000001, Text,,0,,["WORD 1 WORD 2"]))
{
MouseMove, X, Y, 0
}
Re: FindText tutorial
FindText has the following arguments: FindText(OutputX, OutputY, X1, Y1, X2, Y2, err1, err0, Text, ScreenShot, FindAll, JoinText, offsetX, offsetY, dir)
Version 1: FindText(X,Y,0,0,0,0,0.000001,0.000001, Text,,0,["WORD 1 WORD 2"]) you have set FindAll to 0 and JoinText to ["WORD 1 WORD 2"] (though you should set FindAll to 1 here, or leave empty)
Version 2: FindText(X,Y,0,0,0,0,0.000001,0.000001, Text,,0,,,,20,10,["WORD 1 WORD 2"]) you have given FindText too many arguments.
Correct: FindText(X,Y,0,0,0,0,0.000001,0.000001, Text,,,["WORD 1 WORD 2"], 20, 10)
Version 1: FindText(X,Y,0,0,0,0,0.000001,0.000001, Text,,0,["WORD 1 WORD 2"]) you have set FindAll to 0 and JoinText to ["WORD 1 WORD 2"] (though you should set FindAll to 1 here, or leave empty)
Version 2: FindText(X,Y,0,0,0,0,0.000001,0.000001, Text,,0,,,,20,10,["WORD 1 WORD 2"]) you have given FindText too many arguments.
Correct: FindText(X,Y,0,0,0,0,0.000001,0.000001, Text,,,["WORD 1 WORD 2"], 20, 10)
Re: FindText tutorial
@Descolada
Thanks a lot master!
Thanks a lot master!
Scaling clarification
Many thanks to OP (Descolada) for the excellent tutorials and to Feiyue for making this possible!
Just a clarification so that others don't get stumped like I did initially. OP had written that for the purposes of these tutorials, Windows DPI scaling should be set at "100%".
However, at 100% the Notepad OCR example (#9) simply doesn't work. It only works (like a charm in fact) at a "custom scaling" factor of 150% (under Advanced scaling settings). We all know Windows 10's DPI scaling options are still a bit messy, to say the least - in fact quite suboptimal for me, a Citrix sufferer.
Hope to double-check on the scaling so as to avoid anything inadvertently "misleading".
BTW, this package seems to be missing Citrix "slayer" I wish I had known years ago.
Warm regards and many thanks!
Just a clarification so that others don't get stumped like I did initially. OP had written that for the purposes of these tutorials, Windows DPI scaling should be set at "100%".
However, at 100% the Notepad OCR example (#9) simply doesn't work. It only works (like a charm in fact) at a "custom scaling" factor of 150% (under Advanced scaling settings). We all know Windows 10's DPI scaling options are still a bit messy, to say the least - in fact quite suboptimal for me, a Citrix sufferer.
Hope to double-check on the scaling so as to avoid anything inadvertently "misleading".
BTW, this package seems to be missing Citrix "slayer" I wish I had known years ago.
Warm regards and many thanks!
Re: FindText tutorial
@dox, thanks, fixed! The correct DPI is 150%.
Who is online
Users browsing this forum: No registered users and 42 guests