Page 33 of 55

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

Posted: 19 Feb 2021, 11:06
by feiyue
Updated to 8.1 version - 2021/02/19 :beer: :dance:
.... 1. Add: since all the input and output coordinates of the FindText function are relative to the screen,
....... You can use the following functions to convert coordinates to relative window coordinates:
....... WindowToScreen(), ScreenToWindow(), ClientToScreen(), ScreenToClient().
.... 2. Modify: previously, the binding window could not be moved beyond the screen range,
....... otherwise it would not be found. Now this problem has been fixed.

@chaoscreater Now you can change the coordinates yourself. :D

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

Posted: 19 Feb 2021, 20:24
by Avastgard
I'm getting an error message when I try to run the latest version:
---------------------------
FindText Tool.ahk
---------------------------
Error: Call to nonexistent function.

Specifically: WindowToScreen(dx:=0, dy:=0, id), x-=dx, y-=dy

Line#
1102: SetTimer,,Off
1103: }
1107: {
1108: WinGetPos,winx,winy,,,id ? "ahk_id " id : "A"
1109: x+=Floor(winx), y+=Floor(winy)
1110: }
1113: {
---> 1114: WindowToScreen(dx:=0, dy:=0, id), x-=dx, y-=dy
1115: }
1118: {
1119: if (!id)
1120: WinGet,id,ID,A
1121: VarSetCapacity(pt,8,0), NumPut(0,pt,"int64"), DllCall("ClientToScreen","Ptr",id,"Ptr",&pt), x+=NumGet(pt,"int"), y+=NumGet(pt,4,"int")
1124: }
1127: {

The program will exit.
---------------------------
OK
---------------------------

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

Posted: 19 Feb 2021, 21:00
by feiyue
@Avastgard
Fixed it! Thank you for your feedback.

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

Posted: 23 Feb 2021, 03:55
by Avastgard
You're welcome.

This is such a great tool!

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

Posted: 03 Mar 2021, 11:53
by feiyue
Updated to 8.2 version - 2021/03/03 :dance: :beer:
1. Add: Added a search direction (dir = 5): From the Center to all around.
2. Modify: The size of machine code is reduced.

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

Posted: 07 Mar 2021, 19:24
by Qhimin
Hello Feiyue,

Is this function supposed to work with AHK_H ? Cause I'm trying to make it work there to get the text codes but just after I run the .ahk nothing happens.

Thank you!

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

Posted: 08 Mar 2021, 00:34
by feiyue
@Qhimin
Maybe this is a BUG of Ahk_H version, you can try like this:

Code: Select all

Gui(cmd, arg1:="")
{
  ;--  local  ;--  Comment out or remove this line
  static

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

Posted: 08 Mar 2021, 05:54
by Qhimin
feiyue wrote:
08 Mar 2021, 00:34
@Qhimin
Maybe this is a BUG of Ahk_H version, you can try like this:

Code: Select all

Gui(cmd, arg1:="")
{
  ;--  local  ;--  Comment out or remove this line
  static
Thank you very much @feiyue ! It does worked!

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

Posted: 08 Mar 2021, 13:07
by denysy1
Thanks for posting this.

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

Posted: 08 Mar 2021, 13:21
by gregster
denysy1 wrote:
08 Mar 2021, 13:07
Wanted to point out, I'm getting an error with the latest version:

[indent=]Error at line 1368.

Line Text: Switch cmd
Error: This line does not contain a recognized action.
Your AHK version is too old, update it - switch was a relatively recent addition.

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

Posted: 08 Mar 2021, 18:18
by denysy1
I'm testing out this script. I've encountered some weird behavior:

When trying to run the script to recognize some text in a program that if running in full-screen mode, the script does find the text, but when I try to move the mouse to the reported co-ordinates, it moves to some to a wrong location. What's even more interesting is that the offset from the correct location is not consistent. Depending on where on the screen the text appears, the offset is different. Any suggestion on what could be causing this behavior?

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

Posted: 08 Mar 2021, 20:53
by feiyue
@denysy1 you can change the coordinates yourself. :D

All the input and output coordinates of the FindText function are relative to the screen,
You can use the following functions to convert coordinates to relative window coordinates:
WindowToScreen(), ScreenToWindow(), ClientToScreen(), ScreenToClient().

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

Posted: 12 Mar 2021, 18:34
by Dillweed
Hello there. I need to search for an image that is bigger than 50 x 50. How can I do that?

Also what is the difference between Capture and CaptureS?

Thanks for the continued work on this script!

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

Posted: 15 Mar 2021, 09:21
by DoriTos_
Dillweed wrote:
12 Mar 2021, 18:34
Hello there. I need to search for an image that is bigger than 50 x 50. How can I do that?

Also what is the difference between Capture and CaptureS?

Thanks for the continued work on this script!
I'm also wanting this, i've tried to put a higher value but doesn't work

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

Posted: 15 Mar 2021, 21:05
by feiyue
@Dillweed
Although there is no detailed explanation, but you can touch more to understand each function,
as long as the mouse moves to each control, there will be a function prompt.

Expand the size of the selection box to adjust the width and height of the main interface and click apply.
The CaptureS function is used with hotkeys to capture pictures, and the screenshot hotkeys are also set in the main interface.

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

Posted: 17 Mar 2021, 09:45
by Dillweed
@feiyue
I'm sorry, I'm not sure that I understand what you are saying, but I think I found a workaround by taking two captures and then doing work on those captures.

Really, I was hoping to find a way to capture an area of 100 x 12. Is that possible without capturing two areas?

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

Posted: 18 Mar 2021, 01:20
by feiyue
Expand the size of the selection box to adjust the width:35 and height:12 of the main interface and click apply.
adjust “ Height:12 ” to “ Height:50 ”, The actual height is 101 (2*50+1).

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

Posted: 18 Mar 2021, 18:18
by feiyue
Updated to 8.3 version - 2021/03/19 :dance: :beer:
.... 1. Add: Now You can set the capture mouse when capturing an image Use FindText.CaptureCursor(1) .
.... 2. Add: The FindText.ImageSearch() function is added, which is completely similar to
....... the built-in command ImageSearch, The coordinates are set by "CoordMode, Pixel" .
.... 3. Add: A new ScreenShot selection window has been added.
....... Now you can get multiple screenshots using hotkeys,
....... and then click the "CaptureS" button to select which screenshot to restore.

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

Posted: 18 Mar 2021, 22:46
by Hagork
I have the script loaded into my script and working. But I can not figure out how to replace the msgbox with a stop/go result.

With imagesearch (which wasn't detecting my image) I used.

Code: Select all

ImageSearch, Px, Py, 219,105, 288, 388, test.bmp
	If Errorlevel
		sleep, 200 ;pic not found, to continue my loop
	Else
		Pause ;pic found, to pause my loop to look at screen, then hotkey to resume the loop
Can FindText be setup for the same output?

Got it working

Code: Select all

 if (ok:=FindText(407, 184, 521, 660, 0, 0, Text))
 {
   CoordMode, Mouse
   X:=ok.1.x, Y:=ok.1.y, Comment:=ok.1.id
	   Click, %X% %Y% 0
 	   Pause
  }
   Else
  	 Sleep, 100

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

Posted: 19 Mar 2021, 03:08
by ivill
Hi, need help please, how do i manage to work with multiple monitors?
I've got a laptop and sometimes work with an external monitor, and it won't work with different monitors,
for this situation, do you have some advice to solve the problem? thanks very much!