FindText - Capture screen image into text and then find it

Post a reply

Confirmation code
Enter the code exactly as it appears. All letters are case insensitive.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: FindText - Capture screen image into text and then find it

Re: FindText - Capture screen image into text and then find it

Post by feiyue » 22 Apr 2018, 23:47

I think you can do it like this :

Code: [Select all] [Expand]GeSHi © Codebox Plus

Re: FindText - Capture screen image into text and then find it

Post by Cantus » 22 Apr 2018, 22:13

I've spent hours looking at examples, and i'm totally lost.

I can run the original script that will detect and move mouse to the chosen image/text. I recognize how to remove the popup just before the mouse is automatically moved to the position of the found text/image.

My problem is creating a script that will run continuously, clicking on a default image every ~5 seconds. But, with a higher priority, the script should check for another image/text that is rare (not always visible), but should be clicked first, if it exists on screen.

Can anyone give guidance or help me in creating such a script?

Re: FindText - Capture screen image into text and then find it

Post by feiyue » 20 Apr 2018, 10:26

I think you want to cycle check the text in the chat window to automatically reply.
This can be achieved in this way:

Code: [Select all] [Expand]GeSHi © Codebox Plus

Re: FindText - Capture screen image into text and then find it

Post by Twisted_J » 19 Apr 2018, 01:00

Greetings everyone,

I am very new to AHK, but have dabbled with coding from time to time. My question I have is how can I get this to pass back TRUE or FALSE?

I have managed to get the script to find the small area I am looking for, but now I would just like to pass a TRUE statement that it found the text.

Code: [Select all]GeSHi © Codebox Plus

if ((ok:=FindText(448, 605, 100, 100, 0, 0, "|Text"))
{
CoordMode, Mouse
X:=ok.1.1, Y:=ok.1.2, W:=ok.1.3, H:=ok.1.4, Comment:=ok.1.5, X+=W//2, Y+=H//2
; Click, %X%, %Y%
}


Bascially I am looking to have it confirm that text is populating as the program scrolls text down the window (DISCORD Server Chat window). What I am trying to do is when it matches the text and I get a valid hit, I would do something like:

Code: [Select all]GeSHi © Codebox Plus

If (FindText:= VarName)
{
send, Hello %VarName% {enter}
}


Thank you for any assistance.

Re: FindText - Capture screen image into text and then find it

Post by guest3456 » 11 Apr 2018, 07:24

ivill wrote:your script works great, except the different displayer issue


what does different "displayer" mean? obviously you would need to make sure everything is exactly the same on the other PC, otherwise you cant guarnatee that the graphics will be the same and therefore the imagesearch will not match. that text looks different because maybe the scaling % is different, or maybe you have ClearType fonts or something to make the fonts more smooth. either way i would definitely not expect this to work across different computers with different display settings.

Re: FindText - Capture screen image into text and then find it

Post by ivill » 11 Apr 2018, 00:07

Hi, FeiYue, i have a question, your script works great, except the different displayer issue, can you maybe make a fuzzy match setting at the next update?
here is my issue: the same image/text to find on different displayer will not work as the same, let's say i captured this on PC1:
__00000__________00_________________0________00000___________00_____
_0____00_________00_________________0_______00___00__________00_____
00____00___0000__00___0000___0000__000_____00_____00__00000_0000__00
_00_______00__00_00__00__00__0___0__0______00________00___00_00__00_
_00000___00____0_00_00____0_00______0______00_____________00_00__0__
____0000_0000000_00_0000000_00______0______00__________00000_00_0000
_______0_00______00_00______00______0______00________000__00_00_00__
00_____0_00______00_00______00______0______00_____00_00___00_00__0__
_00___00__00__00_00__00__00__0___0__0_______00___00__00__000_00__00_
__00000____0000__00___0000___00000__00_______00000____000000__00__00

it will not work on the PC2(with different displayer but the same resolution 1440x900), if i capture the image on PC2, it looks like this:
_00000___________0_________________0_________0000____________0______
0_____0__________0_________________0________0____0___________0______
0_____0___0000___0___0000____000__0000_____0______0___0000__0000__00
0________0____0__0__0____0__0___0__0_______0_________0____0__0___0__
_000_____0____0__0__0____0__0______0_______0______________0__0___0__
____000__000000__0__000000__0______0_______0___________0000__0___000
______0__0_______0__0_______0______0_______0__________0___0__0___0__
0_____0__0_______0__0_______0______0_______0______0__0____0__0___0__
0_____0__0____0__0__0____0__0___0__0________0____0___0___00__0___0__
_00000____0000___0___0000____000___000_______0000_____000_0__000__00

as you can see, the second one got a smaller size, i think it's the problem? or maybe i was misunderstanding about using the script?
thanks! FeiYue, and everybody in the forum.

Re: FindText - Capture screen image into text and then find it

Post by guest2 » 25 Mar 2018, 08:38

Great script. It takes about 60ms to find an image.

Now suppose I want to write a script to attach a note a specific image out of anyone of 200 images , to be run every half second.

Any comments from readers about best way? example run 200 scripts simultaneous etc

Re: FindText - Capture screen image into text and then find it

Post by garry » 28 Feb 2018, 14:52

@feiyue, thank you for your script

also this , your ahk-script :
AHK-Quellcode Encryptor v1.5 , url =
https://autohotkey.com/boards/viewtopic ... 28&t=42494

this is an encoded example ( contains a gui with a text and button to start url )
save this script as xy.ahk and run

Code: [Select all] [Expand]GeSHi © Codebox Plus

Re: FindText - Capture screen image into text and then find it

Post by feiyue » 16 Feb 2018, 16:36

Updated to the v5.7 version, I changed the way to capture,
Before, click the left button of the mouse, and then move the mouse out of 100 pixels.
Now, press down the right button of the mouse, and then move a certain distance and release the right button.
In addition, I updated the "Capture Image To Text" window,
allowing the use of tags to split the text at one time and generate multiple text libraries.

Re: FindText - Capture screen image into text and then find it

Post by pedroabs » 14 Feb 2018, 03:28

I am new to coding but I think this should be the code that you need.




t1:=A_TickCount

Text:="|<Up Arrow>*70$11.yTsTUS0M0004MMllrXz7yDwT"

if (ok:=FindText(1099, 559, 150000, 150000, 0, 0, Text))
{
CoordMode, Mouse
X:=ok.1.1, Y:=ok.1.2, W:=ok.1.3, H:=ok.1.4, Comment:=ok.1.5, X+=W//2, Y+=H//2
; Click, %X%, %Y%
Click, right, 822, 400
sleep 3000
Click, right, 1135, 339
return
}

; MsgBox, 4096,, % "Time:`t" (A_TickCount-t1) " ms`n`n"
; . "Pos:`t" X ", " Y "`n`n"
; . "Result:`t" (ok ? "Up Arrow Found !":"Up Arrow Not Found !"), 3
MouseMove, X, Y

Re: FindText - Capture screen image into text and then find it

Post by sigartrader » 09 Feb 2018, 14:27

Code: [Select all] [Expand]GeSHi © Codebox Plus



on this part
; MsgBox, 4096,, % "Time:`t" (A_TickCount-t1) " ms`n`n"
; . "Pos:`t" X ", " Y "`n`n"
; . "Result:`t" (ok ? "Up Arrow Found !":"Up Arrow Not Found !"), 3
MouseMove, X, Y
Click, 822, 400
sleep 3000
Click, 1135, 339
return

i try to eliminate message box, then after text/image is found, script will right click mouse at Click, 822, 400 then sleep 3 seconds then right cick again at Click, 1135, 339

is there something wrong, need help please, thanks

Re: FindText - Capture screen image into text and then find it

Post by Redeemed548 » 08 Feb 2018, 20:30

Thank you for your wonderful function feiyue!! This has solved something I've been desiring for years.

I would like to be able differentiate between black text on a yellow background as opposed to black text on a white background. Would it be possible to add the option for color dependent pattern recognition? For example, using the two-color mode when searching for patterns only, and multi-color for color contextual patterns. I was thinking of a color depth of 8-bit (256 colors) or less.

Re: FindText - Capture screen image into text and then find it

Post by ivill » 01 Feb 2018, 06:01

大神你好,打扰了,请问你的薇信多少,我有个很简单的脚本问题想请教一下您,方便的话可以加下我吗ivill66

Re: FindText - Capture screen image into text and then find it

Post by robodesign » 26 Jan 2018, 15:53

Hi!

It seems very nice... Can this script be used to detect the text cursor/caret on screen? Thank you.
Best regards, Marius.

Re: FindText - Capture screen image into text and then find it

Post by SOTE » 19 Dec 2017, 01:20

Looks like this would be good to use with desktop icons, so an automation script could always find and click them. Another use is in browsers, where it could click a particular image that is linked to a URL. The advantage being that it can be used as an alternative way to interact with programs, bypassing more complex methods that use COM, Chrome, Java, etc... I had something that was a bit like this, but you have created a far better script.

For screen resolution and browser magnification, seems like that could be put into the script to check if they match before starting the search. If it doesn't match, it won't start the search and give you an error right away. If it does match, then proceed with the search.

Re: FindText - Capture screen image into text and then find it

Post by r2997790 » 14 Dec 2017, 04:23

Thank you for the FindText() script! It is amazing.

I am trying to make a loop from it, to do this:

Load URL
FindText

LoadURL
FindText

etc

It works the first time, but not more than once. I can find multiple text/images on one page BUT as soon as I try to load a new URL the function stops working when I call it.

Does anyone have any idea how to fix this?

Many thanks
R

Re: FindText - Capture screen image into text and then find it

Post by feiyue » 06 Dec 2017, 04:51

hal123 wrote:
Would it somehow be possible to make it work on dynamic text (Taking the text to find from a file)

My idea is somehow to generate the image to find. First I capture all the letters in the alphabet, based on the text and captured letters I then generate the image.

Code: [Select all] [Expand]GeSHi © Codebox Plus



How can I merge the letters into an "image word" that I can search for?

Updated to the v5.6 version, Add a new Function: FindText2()
This function is used for combination lookup,
for example, a 0-9 text library has been set up, and any ID number can be found.
Use Pic(Text,1) and PicN(number) when using. The simple code:

Code: [Select all] [Expand]GeSHi © Codebox Plus

Re: FindText - Capture screen image into text and then find it

Post by MikeTheNumbers » 24 Nov 2017, 05:49

Hi Feiyue.
I'm new to ATH, and have no experience with coding what so ever.
But I have been looking for a way to use AutoHotkey as an Anti-AFK for a game.

I made a post in the ask for help part of the forum https://autohotkey.com/boards/viewtopic ... 18&t=40432

I've now been doing a little digging since that post, and I stumbled upon your work, and I actually think It might just work for the purpose I need It for, with a few adjustment, adjustment I'm not able to make myself.
I was wondering if you had the time, if you could check my request out, and if possible, maybe help me out.

/Mike

Re: FindText - Capture screen image into text and then find it

Post by burque505 » 23 Nov 2017, 10:42

Thank you, feiyue, for this script and all your continued work on it.
Regards,
burque505

Re: FindText - Capture screen image into text and then find it

Post by feiyue » 23 Nov 2017, 10:30

Updated to the v5.5 version, in order to identify a variety of color verification code, I improved the color model, now it can adapt to various colors. :D

Top