FindText - Capture screen image into text and then find it
Re: FindText - Capture screen image into text and then find it
Updated to 6.8 version - 2019/10/25
.... 1. Fixed case insensitive key names in internal array of Pic() function.
.... 2. In order to facilitate this script to be included in other scripts as a library (#Include <FindText.ahk>),
.... no custom global variables are used, and the label of subprogram is greatly reduced.
At present, there is no good idea, so there is no improvement.
.... 1. Fixed case insensitive key names in internal array of Pic() function.
.... 2. In order to facilitate this script to be included in other scripts as a library (#Include <FindText.ahk>),
.... no custom global variables are used, and the label of subprogram is greatly reduced.
At present, there is no good idea, so there is no improvement.
Last edited by feiyue on 26 Oct 2019, 22:23, edited 1 time in total.
Re: FindText - Capture screen image into text and then find it
Is it possible to have a larger selection area
Re: FindText - Capture screen image into text and then find it
@Jinpachi If the capture range is not large, you can adjust the following values:
; The capture range can be changed by adjusting the numbers
;----------------------------
ww:=35, hh:=12
;----------------------------
In addition, you can make your own packaging function for convenient use. For example:
; The capture range can be changed by adjusting the numbers
;----------------------------
ww:=35, hh:=12
;----------------------------
@uwscia OK, I'll talk about the current status in the second post.
In addition, you can make your own packaging function for convenient use. For example:
Code: Select all
; My_FindText() ---- << Copy this function into your script >> ----
; (x1, y1) is the upper-left coordinate of the search range,
; (x2, y2) is the lower-right coordinate of the search range,
; other parameters are passed to FindText() function as is.
My_FindText(x1, y1, x2, y2, @*)
{
ok2:=[]
For i,v in ok:=FindText(x1, y1, x2-x1, y2-y1, @*)
ok2[i]:={ "ID" : v.5, "x" : v.1+v.3//2, "y" : v.2+v.4//2 }
return, ok2.MaxIndex() ? ok2:0
}
Re: FindText - Capture screen image into text and then find it
Code: Select all
; ====================== Functions =========================
ControlClick2(X, Y, WinTitle="", WinText="", ExcludeTitle="", ExcludeText="")
{
hwnd:=ControlFromPoint(X, Y, WinTitle, WinText, cX, cY
, ExcludeTitle, ExcludeText)
PostMessage, 0x201, 0, cX&0xFFFF | cY<<16,, ahk_id %hwnd% ; WM_LBUTTONDOWN
PostMessage, 0x202, 0, cX&0xFFFF | cY<<16,, ahk_id %hwnd% ; WM_LBUTTONUP
PostMessage, 0x203, 0, cX&0xFFFF | cY<<16,, ahk_id %hwnd% ; WM_LBUTTONDBLCLCK
PostMessage, 0x202, 0, cX&0xFFFF | cY<<16,, ahk_id %hwnd% ; WM_LBUTTONUP
}
; Retrieves the control at the specified point.
; X [in] X-coordinate relative to the top-left of the window.
; Y [in] Y-coordinate relative to the top-left of the window.
; WinTitle [in] Title of the window whose controls will be searched.
; WinText [in]
; cX [out] X-coordinate relative to the top-left of the control.
; cY [out] Y-coordinate relative to the top-left of the control.
; ExcludeTitle [in]
; ExcludeText [in]
; Return Value: The hwnd of the control if found, otherwise the hwnd of the window.
ControlFromPoint(X, Y, WinTitle="", WinText="", ByRef cX="", ByRef cY="", ExcludeTitle="", ExcludeText="")
{
static EnumChildFindPointProc=0
if !EnumChildFindPointProc
EnumChildFindPointProc := RegisterCallback("EnumChildFindPoint","Fast")
if !(target_window := WinExist(WinTitle, WinText, ExcludeTitle, ExcludeText))
return false
VarSetCapacity(rect, 16)
DllCall("GetWindowRect","uint",target_window,"uint",&rect)
VarSetCapacity(pah, 36, 0)
NumPut(X + NumGet(rect,0,"int"), pah,0,"int")
NumPut(Y + NumGet(rect,4,"int"), pah,4,"int")
DllCall("EnumChildWindows","uint",target_window,"uint",EnumChildFindPointProc,"uint",&pah)
control_window := NumGet(pah,24) ? NumGet(pah,24) : target_window
DllCall("ScreenToClient","uint",control_window,"uint",&pah)
cX:=NumGet(pah,0,"int"), cY:=NumGet(pah,4,"int")
return control_window
}
; Ported from AutoHotkey::script2.cpp::EnumChildFindPoint()
EnumChildFindPoint(aWnd, lParam)
{
if !DllCall("IsWindowVisible","uint",aWnd)
return true
VarSetCapacity(rect, 16)
if !DllCall("GetWindowRect","uint",aWnd,"uint",&rect)
return true
pt_x:=NumGet(lParam+0,0,"int"), pt_y:=NumGet(lParam+0,4,"int")
rect_left:=NumGet(rect,0,"int"), rect_right:=NumGet(rect,8,"int")
rect_top:=NumGet(rect,4,"int"), rect_bottom:=NumGet(rect,12,"int")
if (pt_x >= rect_left && pt_x <= rect_right && pt_y >= rect_top && pt_y <= rect_bottom)
{
center_x := rect_left + (rect_right - rect_left) / 2
center_y := rect_top + (rect_bottom - rect_top) / 2
distance := Sqrt((pt_x-center_x)**2 + (pt_y-center_y)**2)
update_it := !NumGet(lParam+24)
if (!update_it)
{
rect_found_left:=NumGet(lParam+8,0,"int"), rect_found_right:=NumGet(lParam+8,8,"int")
rect_found_top:=NumGet(lParam+8,4,"int"), rect_found_bottom:=NumGet(lParam+8,12,"int")
if (rect_left >= rect_found_left && rect_right <= rect_found_right
&& rect_top >= rect_found_top && rect_bottom <= rect_found_bottom)
update_it := true
else if (distance < NumGet(lParam+28,0,"double")
&& (rect_found_left < rect_left || rect_found_right > rect_right
|| rect_found_top < rect_top || rect_found_bottom > rect_bottom))
update_it := true
}
if (update_it)
{
NumPut(aWnd, lParam+24)
DllCall("RtlMoveMemory","uint",lParam+8,"uint",&rect,"uint",16)
NumPut(distance, lParam+28, 0, "double")
}
}
return true
}
; ===============================================
~WheelUp::
#IfWinActive ahk_class QWidget
; Easy
Text:="|<Pic2>[email protected]$71.000000000000000000000000000000000000000000000000000000000000000000000000000000000000U000000000010000000000020000000000040000000000080000280000000000004000000000000000100000000000200008000000400000000000800000080000E0E000000000U00000000001000000000000000000000000000000E000000000000000000000000001"
if (ok:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, Text, , 0))
{
WinRestore, ahk_exe AkelPad.exe
Click
Sleep 250
ControlClick2(960, 324, "^.*Engvidshortcut.*$")
;MouseGetPos, xpos, ypos
;MouseClick, left, 914, 317, 2, 0 ; [WhichButton , X, Y, ClickCount, Speed, D|U, R]
Sleep 500
ControlSend, , ^c, ^.*Engvidshortcut.*$
Sleep 250
ControlClick, x60 y150, ahk_class QWidget,, Left, 1, NA ; клик по строке ввода текста
;MouseMove, xpos, ypos, 0
}
; Again
Text:="|<Pic3>[email protected]$71.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E0000000000000000000000000804004000100E00000004000U0000000000100U0000000020100000100040200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"
if (ok:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, Text, , 0))
{
Click
sleep 5000
ControlClick2(960, 324, "^.*Engvidshortcut.*$")
Sleep 500
ControlSend, , ^c, ^.*Engvidshortcut.*$
Sleep 250
ControlClick, x60 y150, ahk_class QWidget,, Left, 1, NA ;
;MouseMove, xpos, ypos, 0
}
Re: FindText - Capture screen image into text and then find it
Your window title uses regular expressions: "^.*Engvidshortcut.*$"
I think you need to add this at the beginning of the script: SetTitleMatchMode, RegEx
I think you need to add this at the beginning of the script: SetTitleMatchMode, RegEx
Re: FindText - Capture screen image into text and then find it
Updated to 6.9 version - 2019/10/30
.... 1. The ScreenShot_GetColor() function is added.
.... Before using it, you usually need to update the last screenshot with the ScreenShot() function.
.... FindText() function can also update the last screenshot, So you can use FindText() instead of ScreenShot().
.... 1. The ScreenShot_GetColor() function is added.
.... Before using it, you usually need to update the last screenshot with the ScreenShot() function.
.... FindText() function can also update the last screenshot, So you can use FindText() instead of ScreenShot().
Re: FindText - Capture screen image into text and then find it
First of all I would like to thank Feiyue for the awesome work he does. Second, for someone who is curious of MCODE, I would like to add that I have verified MCODE for both x32; and x64 versions of 10.30.2019 FindText() release and have found that my generated MCODE is identical to the one that is posted on 10.30.2019 release. I have used C function that is provided by Fyiyue,
For this I have used MCode4GCC Generator Revision 2015.02.03 with the following switches C:\TDM-GCC-64\bin\gcc.exe -m32 -O2 and C:\TDM-GCC-64\bin\gcc.exe -m64 -O2 using Laszlo style.
Also, I have tested one of previous versions (where find_pic1 and find_pic2) existed, and found that x64 bit code had minor difference at the end of code, where my code had extra code:"909090909090909090909090" , which I believe there is a documentation and explanation for this code.
Once again, Thank you Feiyue
Code: Select all
int __attribute__((__stdcall__)) PicFind(
int mode, unsigned int c, unsigned int n
, int offsetX, int offsetY, unsigned char * Bmp
, int Stride, int sx, int sy, int sw, int sh
, unsigned char * gs, char * ss, char * text
, int * s1, int * s0, int * input, int num
, unsigned int * allpos, int allpos_max)
{
int o, i, j, x, y, r, g, b, rr, gg, bb, max, e1, e0, ok;
int o1, x1, y1, w1, h1, sx1, sy1, len1, len0, err1, err0;
int o2, x2, y2, w2, h2, sx2, sy2, len21, len20, err21, err20;
int r_min, r_max, g_min, g_max, b_min, b_max;
//----------------------
ok=0; w1=input[1]; h1=input[2];
len1=input[3]; len0=input[4];
err1=input[5]; err0=input[6];
max=len1>len0 ? len1 : len0;
//----------------------
// Generate Lookup Table
for (j=0; j<num; j+=7)
{
o=o1=o2=input[j]; w2=input[j+1]; h2=input[j+2];
for (y=0; y<h2; y++)
{
for (x=0; x<w2; x++)
{
i=(mode==3) ? y*Stride+x*4 : y*sw+x;
if (text[o++]=='1')
s1[o1++]=i;
else
s0[o2++]=i;
}
}
}
// Color Position Mode
// This mode is not support combination lookup
// only used to recognize multicolored Verification Code
if (mode==3)
{
sx1=sx+sw-w1; sy1=sy+sh-h1;
for (y=sy; y<=sy1; y++)
{
for (x=sx; x<=sx1; x++)
{
o=y*Stride+x*4; e1=err1; e0=err0;
j=o+c; rr=Bmp[2+j]; gg=Bmp[1+j]; bb=Bmp[j];
for (i=0; i<max; i++)
{
if (i<len1)
{
j=o+s1[i]; r=Bmp[2+j]-rr; g=Bmp[1+j]-gg; b=Bmp[j]-bb;
if (3*r*r+4*g*g+2*b*b>n && (--e1)<0)
goto NoMatch3;
}
if (i<len0)
{
j=o+s0[i]; r=Bmp[2+j]-rr; g=Bmp[1+j]-gg; b=Bmp[j]-bb;
if (3*r*r+4*g*g+2*b*b<=n && (--e0)<0)
goto NoMatch3;
}
}
allpos[ok++]=y<<16|x;
if (ok>=allpos_max)
goto Return1;
NoMatch3:
continue;
}
}
goto Return1;
}
// Generate Two Value Image
o=sy*Stride+sx*4; j=Stride-4*sw; i=0;
if (mode==0) // Color Mode
{
rr=(c>>16)&0xFF; gg=(c>>8)&0xFF; bb=c&0xFF;
for (y=0; y<sh; y++, o+=j)
for (x=0; x<sw; x++, o+=4, i++)
{
r=Bmp[2+o]-rr; g=Bmp[1+o]-gg; b=Bmp[o]-bb;
ss[i]=(3*r*r+4*g*g+2*b*b<=n) ? 1:0;
}
}
else if (mode==1) // Gray Threshold Mode
{
c=(c+1)*128;
for (y=0; y<sh; y++, o+=j)
for (x=0; x<sw; x++, o+=4, i++)
ss[i]=(Bmp[2+o]*38+Bmp[1+o]*75+Bmp[o]*15<c) ? 1:0;
}
else if (mode==2) // Gray Difference Mode
{
for (y=0; y<sh; y++, o+=j)
{
for (x=0; x<sw; x++, o+=4, i++)
{
gs[i]=(Bmp[2+o]*38+Bmp[1+o]*75+Bmp[o]*15)>>7;
ss[i]=0;
}
}
sx1=sw-2; sy1=sh-2;
for (y=1; y<=sy1; y++)
for (x=1; x<=sx1; x++)
{
i=y*sw+x; j=gs[i]+c;
if ( gs[i-1]>j || gs[i+1]>j
|| gs[i-sw]>j || gs[i+sw]>j
|| gs[i-sw-1]>j || gs[i-sw+1]>j
|| gs[i+sw-1]>j || gs[i+sw+1]>j )
ss[i]=1;
}
}
else // (mode==4) Color Difference Mode
{
r=(c>>16)&0xFF; g=(c>>8)&0xFF; b=c&0xFF;
rr=(n>>16)&0xFF; gg=(n>>8)&0xFF; bb=n&0xFF;
r_min=r-rr; g_min=g-gg; b_min=b-bb;
r_max=r+rr; g_max=g+gg; b_max=b+bb;
for (y=0; y<sh; y++, o+=j)
for (x=0; x<sw; x++, o+=4, i++)
{
r=Bmp[2+o]; g=Bmp[1+o]; b=Bmp[o];
ss[i]=(r>=r_min && r<=r_max
&& g>=g_min && g<=g_max
&& b>=b_min && b<=b_max) ? 1:0;
}
}
// Start Lookup
sx1=sw-w1; sy1=sh-h1;
for (y=0; y<=sy1; y++)
{
for (x=0; x<=sx1; x++)
{
o=y*sw+x; e1=err1; e0=err0;
if (e0==len0)
{
for (i=0; i<len1; i++)
if (ss[o+s1[i]]!=1 && (--e1)<0)
goto NoMatch1;
}
else
{
for (i=0; i<max; i++)
{
if (i<len1 && ss[o+s1[i]]!=1 && (--e1)<0)
goto NoMatch1;
if (i<len0 && ss[o+s0[i]]!=0 && (--e0)<0)
goto NoMatch1;
}
}
//------------------
if (num>7)
{
x1=x+w1-1; y1=y-offsetY; if (y1<0) y1=0;
for (j=7; j<num; j+=7)
{
o2=input[j]; w2=input[j+1]; h2=input[j+2];
len21=input[j+3]; len20=input[j+4];
err21=input[j+5]; err20=input[j+6];
sx2=sw-w2; i=x1+offsetX; if (i<sx2) sx2=i;
sy2=sh-h2; i=y+offsetY; if (i<sy2) sy2=i;
for (x2=x1; x2<=sx2; x2++)
{
for (y2=y1; y2<=sy2; y2++)
{
o1=y2*sw+x2; e1=err21; e0=err20;
for (i=0; i<len21; i++)
{
if (ss[o1+s1[o2+i]]!=1 && (--e1)<0)
goto NoMatch2;
}
if (e0!=len20)
{
for (i=0; i<len20; i++)
if (ss[o1+s0[o2+i]]!=0 && (--e0)<0)
goto NoMatch2;
}
goto MatchOK;
NoMatch2:
continue;
}
}
goto NoMatch1;
MatchOK:
x1=x2+w2-1;
}
}
//------------------
allpos[ok++]=(sy+y)<<16|(sx+x);
if (ok>=allpos_max)
goto Return1;
// Clear the image that has been found
for (i=0; i<len1; i++)
ss[o+s1[i]]=0;
NoMatch1:
continue;
}
}
Return1:
return ok;
}
Also, I have tested one of previous versions (where find_pic1 and find_pic2) existed, and found that x64 bit code had minor difference at the end of code, where my code had extra code:"909090909090909090909090" , which I believe there is a documentation and explanation for this code.
Once again, Thank you Feiyue
Re: FindText - Capture screen image into text and then find it
Updated to 7.0 version - 2019/11/24
.... 1. Modify: the first four parameters of FinText() used to specify the search range
....... are changed from the previous (X, Y, W, H) to (X1, Y1, X2, Y2), Similar to the
....... built-in command imagesearch, because many novices want to use the simple way.
....... Note: this will cause incompatibility with previous scripts.
.... 2. Modify: the return array of FindText() is slightly modified,
....... The object of each result is changed from a simple array [X,Y,W,H,Comment]
....... to an associative array {1:X, 2:Y, 3:W, 4:H, x:X+W//2, y:Y+H//2, id:Comment}
....... Note: this causes slight incompatibility with previous scripts, because object.5 is renamed object.id
.... 3. Modify: FindTextOCR() is renamed as OcrOK()
....... because it directly uses the return value of FinText() as a parameter.
.... 4. Add: now you can use a hotkey to take a screenshot,
....... So you can quickly capture some fleeting screen images,
....... And then capture some images in the last screenshot.
.... 5. Add: Undo is added to crop image edges.
It took me a long time to decide to modify the first four parameters of the function,
Because novices want to use the simplest two points to determine a range.
However, this will cause some incompatibilities.
Users' previous scripts need to modify or use a wrapped function.
So I waited until a big version number to make some big changes.
.... 1. Modify: the first four parameters of FinText() used to specify the search range
....... are changed from the previous (X, Y, W, H) to (X1, Y1, X2, Y2), Similar to the
....... built-in command imagesearch, because many novices want to use the simple way.
....... Note: this will cause incompatibility with previous scripts.
.... 2. Modify: the return array of FindText() is slightly modified,
....... The object of each result is changed from a simple array [X,Y,W,H,Comment]
....... to an associative array {1:X, 2:Y, 3:W, 4:H, x:X+W//2, y:Y+H//2, id:Comment}
....... Note: this causes slight incompatibility with previous scripts, because object.5 is renamed object.id
.... 3. Modify: FindTextOCR() is renamed as OcrOK()
....... because it directly uses the return value of FinText() as a parameter.
.... 4. Add: now you can use a hotkey to take a screenshot,
....... So you can quickly capture some fleeting screen images,
....... And then capture some images in the last screenshot.
.... 5. Add: Undo is added to crop image edges.
It took me a long time to decide to modify the first four parameters of the function,
Because novices want to use the simplest two points to determine a range.
However, this will cause some incompatibilities.
Users' previous scripts need to modify or use a wrapped function.
So I waited until a big version number to make some big changes.
-
- Posts: 45
- Joined: 02 Jul 2019, 11:34
Re: FindText - Capture screen image into text and then find it
Hi, I wanted to thank you again for this awesome library. I made some useful adjustments you may want to consider.
First is adding a method of adjusting the width and height of the capture area.
The second suggestion is allowing output from Copy to only contain the string itself.
The third suggestion is a way to import strings to test with the gui.
First is adding a method of adjusting the width and height of the capture area.
Adjustable Capture Area
The second suggestion is allowing output from Copy to only contain the string itself.
Export only the String
The third suggestion is a way to import strings to test with the gui.
Import Previously Captured Strings
GUI preview
Last edited by thebbandit on 30 Nov 2019, 14:18, edited 1 time in total.
Re: FindText - Capture screen image into text and then find it
@thebbandit
Thank you for your suggestion. I updated it to realize some of your ideas.
The version number was not updated because it was not a major change.
Thank you for your suggestion. I updated it to realize some of your ideas.
The version number was not updated because it was not a major change.
Re: FindText - Capture screen image into text and then find it
Hi, can you select the inscription above the green line in the same search area? Above the red line is the same inscription and yet another. By there are two same words the script does not work.
Can you somehow distinguish them?
Can you somehow distinguish them?
Re: FindText - Capture screen image into text and then find it
You can sort it with SortOK(). For example:
ok:=SortOK( FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, Text) )
ok:=SortOK( FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, Text) )
Re: FindText - Capture screen image into text and then find it
Thanks for the answer, but it's too hard for me.
How can SortOK be added to this code to sort?
This script selects subtitles in a specific language for a YouTube video.
I will add that Findtext only searches in the area where the list of subtitles appears.
How can SortOK be added to this code to sort?
This script selects subtitles in a specific language for a YouTube video.
I will add that Findtext only searches in the area where the list of subtitles appears.
Code: Select all
Text:="|<>**50$53.0003kD0wS0006UG18o00090Y2F/zzzzzDwzyCXVb6QNYvAaPBYqGNzPhqHdjVnUrPYUHX3bRirNDbmHCnRanRBYqQ6vVb6MNYjzzvzzzzz005a0000000AQ0000000Tk00004"
if (ok:=FindText(632, 252, 890, 584, 0, 0, Text))
{
CoordMode, Mouse
X:=ok.1.x, Y:=ok.1.y, Comment:=ok.1.id
ControlClick, x%X% y%Y%, %title%,,,, NA
Sleep 1000
goto english_to_polish_translator_2
}else{
MsgBox No English
}
-
- Posts: 45
- Joined: 02 Jul 2019, 11:34
Re: FindText - Capture screen image into text and then find it
I am finding an error that occurs when using the CaptureS button. I have two monitors set up in a dual display, 1080p for both side to side. (if that is relevant) When I press the CaptureS button it will place the overlayed image on the screen, but it will be offset +y by 20 or more pixels. When I continue to grab a capture, the screen capture will be offset in other direction, as if it was capturing from the non-offset area.
Demonstration
Re: FindText - Capture screen image into text and then find it
@thebbandit Thank you for your feedback.
Would you please test the latest version to see if the problem is solved?
Would you please test the latest version to see if the problem is solved?
-
- Posts: 45
- Joined: 02 Jul 2019, 11:34
Re: FindText - Capture screen image into text and then find it
It is working wonderfully, and the new scrolling edit menu is just sublime!
Much better clarity when selecting pixels the way you have designed it.
Much better clarity when selecting pixels the way you have designed it.
Allow TestClipboard to accept only string
Re: FindText - Capture screen image into text and then find it
@thebbandit Thank you very much for your many good suggestions !
You think very carefully ! I fixed it and achieved this effect.
You think very carefully ! I fixed it and achieved this effect.
-
- Posts: 45
- Joined: 02 Jul 2019, 11:34
Re: FindText - Capture screen image into text and then find it
I found another issue with the Screenshot Hotkey, if placed inside of a script that uses conditional hotkeys, if they are not reset this may possibly break functionality of your binding. This is easily fixed with this before the bindings in cmd="Apply":
Once I figured that issue out, then I discovered another related to using this as a library. With the Screenshot Hotkey, if the script is using the screenshot function within a timer, the screenshot from the hotkey will be overwritten with any new screenshots from timers.
Is it possible to save the screenshot from the hotkey into a seperate set of variables? I am trying to understand how the process of this is occuring, but I dont see how exactly the screenshot is being saved and loaded from.
Resolved this by running the library file as a standalone script instead of launching the gui command, its better for it to have its own thread anyways. it was also having issues even when I had the timers off, so idk what global setting it didn't like.
I just wanted to add, this Screenshot_GetColor function is amazing, I have implimented it in place of a pixelsearch loop and had a reduction of MS time of around 75% its dropped from 450ms or more to 100-150ms, which is an astounding reduction! I will be developing some more functions using this method soon.
Code: Select all
hotkey, IfWinActive
Is it possible to save the screenshot from the hotkey into a seperate set of variables? I am trying to understand how the process of this is occuring, but I dont see how exactly the screenshot is being saved and loaded from.
Resolved this by running the library file as a standalone script instead of launching the gui command, its better for it to have its own thread anyways. it was also having issues even when I had the timers off, so idk what global setting it didn't like.
I just wanted to add, this Screenshot_GetColor function is amazing, I have implimented it in place of a pixelsearch loop and had a reduction of MS time of around 75% its dropped from 450ms or more to 100-150ms, which is an astounding reduction! I will be developing some more functions using this method soon.
Re: FindText - Capture screen image into text and then find it
Hi!
I'm very interested in this script it looks great. I'm not a programmer, mind telling me how to search a area around mousepointer?
I read the intro nothing said there really makes it clear to me how to do it, I might have missed it not sure.
I got the part of choosing and making the image to the text.
What I want is for it to only search a rectangle around mousepointer, then move mouse to the exact pixel of image found inside rectangle.
I got the start of the code like so
It finds the images when I do the "test", but they are not at the place I want it to search. Another problem for me is that it clicks the middle of the image, although I would like it to click the end of a line (edge of the image found) - so it clicks middle of the line once it find the line but not the edge of it. And the size of these lines might differ so setting it to move a certain distance won't work probably. So wondering if you could make it select which pixel of the image found it should click, like a horizontal color difference on one side of the line (for example black colored line meets white background should work if run in grey mode)?
Thanks!
I'm very interested in this script it looks great. I'm not a programmer, mind telling me how to search a area around mousepointer?
I read the intro nothing said there really makes it clear to me how to do it, I might have missed it not sure.
I got the part of choosing and making the image to the text.
What I want is for it to only search a rectangle around mousepointer, then move mouse to the exact pixel of image found inside rectangle.
I got the start of the code like so
Code: Select all
; #Include <FindText>
t1:=A_TickCount
Text:="|<>#[email protected]$42.0000000000000003zzzs000000000000000U"
if (ok:=FindText(409-150000, 1904-150000, 150000, 150000, 0, 0, Text))
{
CoordMode, Mouse
X:=ok.1.x, Y:=ok.1.y, Comment:=ok.1.id
; Click, %X%, %Y%
}
MsgBox, 4096, Tip, % "Found :`t" Round(ok.MaxIndex()) "`n`n"
. "Time :`t" (A_TickCount-t1) " ms`n`n"
. "Pos :`t" X ", " Y "`n`n"
. "Result:`t" (ok ? "Success ! " Comment : "Failed !")
for i,v in ok
if (i<=2)
MouseTip(ok[i].x, ok[i].y)
;===== Copy The Following Functions To Your Own Code Just once =====
Thanks!
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: NinjoOnline, NPerovic and 182 guests