FindText - Capture screen image into text and then find it
-
- Posts: 2
- Joined: 03 Sep 2020, 01:26
Re: FindText - Capture screen image into text and then find it
I'm having trouble running a script including FindText.ahk...I can run the GUI just fine, but when importing it into another script, it breaks...I'm on version 1.1.33.02 (most recent version)...This is the error I get. I copied it directly from the OP multiple times and it gives me the error every time.
Re: FindText - Capture screen image into text and then find it
Try either to comment the line like: ; #Include "D:\Documents\Lib\FindText.ahk"
or comment the function like:
or comment the function like:
Code: Select all
/*
;===== Copy The Following Functions To Your Own Code Just once =====
;--------------------------------
; FindText - Capture screen image into text and then find it
…
-
- Posts: 2
- Joined: 03 Sep 2020, 01:26
Re: FindText - Capture screen image into text and then find it
When I comment out the #Include line, it no longer gives an error, but it obviously also doesn't do anything. Something about loading the script is messing up ahk...could it be formatting errors when copying it to a text file from the OP? I've deleted the file and copied the OP to a new file multiple times, but with no change...What's really weird is that even when I delete everything in the file except for a blank FindText(){} function, it still gives the same error...When loading a different script, it gives no error, but loading this script even once seems to doom the file holding it to eternal errors...this is really hurting my brain lol. I've loaded scripts in the past, and have never had this issue...I've tried stripping down the script to absolutely nothing except for a blank file that used to hold the script, and an #Include <BlankScript> line, and it gives the same error...starting fresh with a new blank file works, but once I copy in the code from the OP, that file never seems to load anymore and gives me this same error, no matter what the contents is...rommmcek wrote: ↑03 Sep 2020, 02:14Try either to comment the line like: ; #Include "D:\Documents\Lib\FindText.ahk"
or comment the function like:Code: Select all
/* ;===== Copy The Following Functions To Your Own Code Just once ===== ;-------------------------------- ; FindText - Capture screen image into text and then find it …
Re: FindText - Capture screen image into text and then find it
Error: Functions cannot contain functions.
eg:
a() {
b() {
}
; or #Include <FindText>
}
eg:
a() {
b() {
}
; or #Include <FindText>
}
-
- Posts: 29
- Joined: 20 Jun 2020, 22:27
Re: FindText - Capture screen image into text and then find it
@feiyue Hello Feiyue, Very nice script!!!!. I have a question tho. I tried using it on a certain game and it didn't work. Ive tried putting some simple script like Msgbox with your findtext script and its not working. do you have any workaround for this?
Re: FindText - Capture screen image into text and then find it
How to use this tool to detect "2018-07-19" form date, I want to find how many dates on the left and right.Before 2020, I count how many "20" on the left and on the right, enter the year of 2020 it no longer works.
Re: FindText - Capture screen image into text and then find it
Hi feiyue! Is it possible to run FindText() on an inactive window? If yes, can you show me how? Appreciate and thanks a lot mate.
-
- Posts: 3
- Joined: 27 Sep 2020, 20:38
Re: FindText - Capture screen image into text and then find it
What are the returned coordinates relative to? I'm searching for an image which appears on another monitor. The coordinates returned are on the wrong monitor but if the monitor was overlapped and scaled it could be the correct position. How can I convert these?
For this example the returned coords are 1253, 376. And the WindowCoords are 3014, -106. The actual icon I'm looking for appears at screen coords 3202, 566 (I'm using 3 monitors)
For this example the returned coords are 1253, 376. And the WindowCoords are 3014, -106. The actual icon I'm looking for appears at screen coords 3202, 566 (I'm using 3 monitors)
Code: Select all
#SingleInstance,Force
#Include <FindText>
SetMouseDelay,-1
SetTitleMatchMode, 2
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
SetTitleMatchMode, 2
SetControlDelay -1
DetectHiddenWindows On
SetWorkingDir, %A_ScriptDir%
Loop
{
SysGet, TopX, 76
SysGet, TopY, 77
SysGet, VirtualWidth, 78
SysGet, VirtualHeight, 79
WinActivate, BlueStacks
WinGetPos, winX, winY,,, BlueStacks
t1:=A_TickCount, X:=Y:=""
Text:="|<mauler>*141$41.wDUT1w7kC7XVkDUAF8l0D01DQU0Q04qYW0s2/BYU0k0YlZ0101G188202Y3EE40582Y0Dy+E19TzwEEG3zzwYl97zzsYYGDzzl5/8zzzl6MVzzyF025zzs0UMFzzUUVV1zy0F241zs0m4E1zU3Y9k1zU7cGk3z0RkxUDz1zVnUz"
if (ok:=FindText(TopX, TopY, VirtualWidth, VirtualHeight,0,0,Text))
{
;CoordMode, Mouse
CoordMode, Mouse, Screen
X:= ok.1.1, Y:= ok.1.2, W:= ok.1.3, H:= ok.1.4
mousemove, %X%, %Y%
}
MsgBox, 4096, Tip, % "Found :`t" Round(ok.MaxIndex())
. "`n`nTime :`t" (A_TickCount-t1) " ms"
. "`n`nPos :`t" X ", " Y ", " W ", " H
. "`n`nWindowCoords:`t" winX ", " winY
. "`n`nResult:`t" (ok ? "Success !" : "Failed !")
MouseGetPos, MouseX, MouseY
ToolTip, "Mouse pos:" %MouseX% %MouseY%
}
Re: FindText - Capture screen image into text and then find it
I've been working with this great script for a few days now and everything worked out fine. Today the script starts without any content in the two big textboxes. Capture, Test, Get Range, etc... work fine but in the end I get no output in the main window. AHK runs fine, other scripts too.I rebooted the computer and downloaded and started the script several times, but unfortunately without success.
Does anyone have a solution to the problem?
versions:
AutoHotkey v1.1.33.02
FindText 7.5
Update:
Now the script works again - it could be that it was related to the changed height and width, unfortunately I could not reproduce the error despite much "playing around". But as mentioned before: THANK YOU for the great script.
Does anyone have a solution to the problem?
versions:
AutoHotkey v1.1.33.02
FindText 7.5
Update:
Now the script works again - it could be that it was related to the changed height and width, unfortunately I could not reproduce the error despite much "playing around". But as mentioned before: THANK YOU for the great script.
Re: FindText - Capture screen image into text and then find it
Hi, I use this code, but now i need change clicking coordinates, so it must click not on center of finding image. What i need add to code?
I see this commands:
offsetX, offsetY --> Set the Max text offset for combination lookup
; ruturn --> the function returns a second-order array
; containing all lookup results, Any result is an associative array
; {1:X, 2:Y, 3:W, 4:H, x:X+W//2, y:Y+H//2, id:Comment},
but how use it?
Code: Select all
X:=ok.1.x, Y:=ok.1.y, Comment:=ok.1.id
Click, %X%, %Y%
offsetX, offsetY --> Set the Max text offset for combination lookup
; ruturn --> the function returns a second-order array
; containing all lookup results, Any result is an associative array
; {1:X, 2:Y, 3:W, 4:H, x:X+W//2, y:Y+H//2, id:Comment},
but how use it?
Re: FindText - Capture screen image into text and then find it
Where do you want to click?
To see the content of the ok array you can use:
To see the content of the ok array you can use:
Code: Select all
MsgBox % txtArr(ok)
txtArr(r, i:=" ", d:=0, b:="") {
For k, v in r
c.= IsObject(v)? b k ":`n" txtArr(v, i, d+1, b i): b k ": " v "`n", d>0? "": t:=c
Return d>0? c: t
}
Re: FindText - Capture screen image into text and then find it
@rommmcek
In practice, I need to find one color pixel, and move the click point slightly. You can look on the screenshot http://prntscr.com/usri85
It clicks where the red arrow shows, right after the word look before the comma.
Code: Select all
q::
; #Include <FindText>
Loop
{
t1:=A_TickCount, X:=Y:=""
Text:="|<>0xFF9632@1.00$1.k"
if (ok:=FindText(714-150000, 375-150000, 714+150000, 375+150000, 0, 0, Text))
{
X:=ok.1.x, Y:=ok.1.y, Comment:=ok.1.id
Click, %X%, %Y%
sleep 500
Send {Enter}
Sleep 500
Send {Right}
Sleep 500
Send {Backspace}
sleep 500
Send {LCtrl Down}{sc22}{LCtrl Up}
}
else if !(ok:=FindText(714-150000, 375-150000, 714+150000, 375+150000, 0, 0, Text))
Send {WheelDown}
}
return
It clicks where the red arrow shows, right after the word look before the comma.
Last edited by reluct on 04 Oct 2020, 00:53, edited 1 time in total.
Re: FindText - Capture screen image into text and then find it
This will click ten pixels to the right:
Code: Select all
Click, % X+10 "," Y
Re: FindText - Capture screen image into text and then find it
Second % is redundant!
Code: Select all
Click, % X+10 "," Y-30
Re: FindText - Capture screen image into text and then find it
@feiyue
Hey fantastic script. It works wonders where imagesearch doesn't work. I was writing a script that runs and then exits and I found that when incorporating FindText into the script that the same script stays open. Is there a way for the script to exit after finding the image?
Thanks for the help,
Dillweed
Hey fantastic script. It works wonders where imagesearch doesn't work. I was writing a script that runs and then exits and I found that when incorporating FindText into the script that the same script stays open. Is there a way for the script to exit after finding the image?
Thanks for the help,
Dillweed
Re: FindText - Capture screen image into text and then find it
Is it possible to get the Text in a simpler way?
I made a program to find the Text on the screen and do something after. The problem is that everytime I open the program the image will be different.
It's getting annoying to capture, grayscale, center and then copy the Text to my own code everytime i use it.
Isn't there a better way to do it?
is it possible to just Right click on my desired place and that gives me the Text on clipboard without having to do all the rest?
Code: Select all
Text:="|<>0xFF9632@1.00$1.k"
It's getting annoying to capture, grayscale, center and then copy the Text to my own code everytime i use it.
Isn't there a better way to do it?
is it possible to just Right click on my desired place and that gives me the Text on clipboard without having to do all the rest?
Re: FindText - Capture screen image into text and then find it
@JavierBO You can do this:
Code: Select all
#Include <FindText>
^RButton::
w:=10, h:=6
CoordMode, Mouse
MouseGetPos, x, y
KeyWait, RButton
s:=FindText_GetTextFromScreen(x-w, y-h, x+w, y+h)
Clipboard=if (ok:=FindText(0,0,150000,150000,0,0,"%s%"))
MsgBox, 4096,, Copy OK !, 0.5
return
Last edited by feiyue on 04 Nov 2020, 14:24, edited 1 time in total.
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: Wala27 and 102 guests