FindText - Capture screen image into text and then find it

Post your working scripts, libraries and tools for AHK v1.1 and older
najeeb
Posts: 1
Joined: 04 Oct 2018, 01:36

Plz help this Script

Post by najeeb » 28 Aug 2022, 08:31

Code: Select all

; <COMPILER: v1.1.34.03>
#NoEnv
#SingleInstance, Force
SetBatchLines, -1
#NoTrayIcon 
SetWorkingDir %A_ScriptDir%  
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Gui -Caption +ToolWindow +Border +LastFound +AlwaysOnTop -Border +hWndhGUI
CustomColor = 884488
Gui, Color, %CustomColor%
Gui,Font,S16 Bold,Verdana ;Calibri
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Gui, Add, Button, hWndhButton2 x5 y5 w0 h0 gGuiMove, 
Gui, Add, text,x60 y10, SEARCH FILES
Gui, Add, Edit,x10 y40 w300 vdwgname
Gui, font, s12
Gui, Add, DropDownList, x10 y100 vExt,txt|exe|bat|ahk
Gui, Add, Button, x220 y100 gopendwg default, OPEN    ;  OPEN
Gui, Show, x0 y30 w350 h160 Center, NAJEEB SEARCH FILES
WinSet, Region, 0-0 W350 H160 R20-20,
WinMove, 0, 0
OnMessage( 0x200, "WM_MOUSEMOVE")
Return
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
GuiMove: 
 PostMessage, 0xA1, 2,,, NAJEEB SCRIPT BOOK 
Return
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
WM_MOUSEMOVE(wparam, lparam, msg, hwnd)
{
    if wparam = 1 ; LButton
        PostMessage, 0xA1, 2,,, A ; WM_NCLBUTTONDOWN
}
opendwg:
found:=""
Gui,Submit,Nohide
loop, %A_ScriptDir%\%dwgname%.%Ext%, 1, 1
{ if (A_LoopFileName=dwgname ".%Ext%" )
  { found := A_LoopFileFullPath
  } 
}
if found =
{ MsgBox, File not found
}
else
{ run %found%
}
Guicontrol,,dwgname,% Ext   ;vycistí hledací pole kódu
return 
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#R::Reload  ;<--  ~ Reload Script ~
#S::Suspend ;<--  ~ Suspend Script ~ 
#P::Pause   ;<--  ~ Pause Script ~
#M::WinMinimize, ;<--  ~ Minimize Script ~
ESC::ExitApp     ;<--  ~ Exit Script ~
[Mod edit: [code][/code] tags added.]

gregster
Posts: 8916
Joined: 30 Sep 2013, 06:48

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

Post by gregster » 28 Aug 2022, 09:04

Hi @najeeb, what is the connection between your posted script and the FindText() function (the actual topic of this thread)?

In general, you should explain what you need help with exactly.
We should move your post to its own topic, if it has nothing to do with the FindText() function.

c7aesa7r
Posts: 209
Joined: 02 Jun 2016, 21:09

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

Post by c7aesa7r » 28 Aug 2022, 22:58

@feiyue

I'm getting compile warnings regarding converting double to int.

In the c++ source the parameters err1 and err0 expects an int, but at the end what is being passed could be a double/floor
ahk script:

, e1:=(j[12] ? j[6] : Floor(j[4] * ini.err1))
, e0:=(j[12] ? j[7] : Floor(j[5] * ini.err0))

Code: Select all

     text:=j[1], w:=j[2], h:=j[3]
     , e1:=(j[12] ? j[6] : Floor(j[4] * ini.err1))
     , e0:=(j[12] ? j[7] : Floor(j[5] * ini.err0))
     , mode:=j[8], color:=j[9], n:=j[10]
     return (!ini.bits.Scan0) ? 0 : DllCall(&MyFunc
       , "int",mode, "uint",color, "uint",n, "int",dir
       , "Ptr",ini.bits.Scan0, "int",ini.bits.Stride
       , "int",ini.zw, "int",ini.zh
       , "int",sx, "int",sy, "int",sw, "int",sh
       , "Ptr",ini.ss, "Ptr",ini.s1, "Ptr",ini.s0
       , "AStr",text, "int",w, "int",h, "int",e1, "int",e0
       , "Ptr",&allpos, "int",ini.allpos_max
       , "int",w*ini.zoomW, "int",h*ini.zoomH)

I converted it as you did in the script:

Code: Select all

err1 = info[i].seterr ? info[i].e1 : floor(info[i].len1 * _err1_);
err0 = info[i].seterr ? info[i].e0 : floor(info[i].len0 * _err0_);

int FindText::PicFind(
    int mode, unsigned int c, unsigned int n, int dir
    , unsigned char* Bmp, int Stride, int zw, int zh
    , int sx, int sy, int sw, int sh
    , char* ss, unsigned int* s1, unsigned int* s0
    , char* text, int w, int h, int err1, int err0
    , unsigned int* allpos, int allpos_max
    , int new_w, int new_h)
warning C4244: 'argument': conversion from 'double' to 'int', possible loss of data

The function is working, but is this correct?

Yogi
Posts: 12
Joined: 06 Jul 2022, 23:03

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

Post by Yogi » 01 Sep 2022, 21:09

This is incredible. I can't imagine being able to code something like this in multiple lifetimes, well done!

cgx5871
Posts: 315
Joined: 26 Jul 2018, 14:02

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

Post by cgx5871 » 04 Sep 2022, 10:59

Code: Select all

vFindText(X,Y,offset:=50)(
Text_Yellow:="|<黄>[email protected]$42.0004000000A000000Q000000I000000A000000A00000040k000000E0000000008000000800000000000000000000000000E000000k00000DkA0003zM00000T4000003U"
Text_Red:="|<红>[email protected]$16.UU00U03s00s00s"
	t1:=FindText(, , X-50, Y-50, X+50, Y+50, 0, 0, Text_Red)
	t2:=FindText(, , X-offset, Y-offset, X+offset, Y+offset, 0, 0, Text_Red)
	return (t1 && t2)
}
发现两个问题,
1. 这个FindText(X, Y.....)) 好像不能缺省. 或者我自定义函数用了X,Y会有冲突
2. 如果缺省X,Y 用[1][1]调出X,Y再Click会无限点击.
if (Text1:=FindText(X, Y, X0-offset, Y0-offset, X0+offset, Y0+offset, 0, 0, Text))
{
tooltip % Text1[1][1]
; FindText().Click(Text1[1][1], Text1[2][2], "L")
}

KingPresLii
Posts: 13
Joined: 29 May 2022, 16:20

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

Post by KingPresLii » 16 Oct 2022, 23:50

@Mkonopko

What is the c parameter mean?

FindText(x,y,Text,c,w=150,h=150,ByRef rx="",ByRef ry="")

elbitjusticiero
Posts: 75
Joined: 06 May 2017, 11:07

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

Post by elbitjusticiero » 20 Oct 2022, 11:22

Hi! I'm having a particular problem using FindText() and for the life of me, I can't wrap my head around what's going on.

I'm using FindText to automate posting to a certain site with a modified WordPress backend. I use it to find the fields I need to fill, and some tabs and buttons to press.

There are two similar features in this system that I use, that should let me reuse some of my code. You can set a featured image for the post, or insert an inline image in the middle of it. Both of these functions are called through different buttons, but once you click them, you are presented with essentially the same thing: two tabs for browsing your computer or select an already uploaded image, and when you click the first tab, a button for uploading a file.

So, to automate this workflow, I wrote:

(1) a function that clicks the "Upload" tab, then the "Select file" button;
(2) a function to set the featured image, that clicks the "Set featured image" button, then calls function 1;
(3) a function to insert an inline image, that clicks the "Add object" button, then calls function 1.

The problem I'm having is that function 1 NEVER finds the "Select file" button when called from function 3. It ALWAYS works when called from function 2. And it should work every time -- the button it just the same. I know it's the same because I ran FindText on it, replaced the text I had before, and it's still working for function 1, but failing for function 2.

I don't know what's going on, so I thought I'd ask here.

I'm using this code:

(function 1)

Code: Select all

SubirArchivo( arch ) {
	
	SubirArchivosTab := "|<Subir archivos>*196$106.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000810000040U00000DU0U400000E200000120200000010000000A00800000040000000k48j4S1sySLWknkS01UEX6HU8n39W92Mm803V28N403AM4AYP38003Y8UYk1wl0EmN84s006EW2F0AH4138YkEs00/28N40VAM4AWn31U0VaMl4E2AkmEm66M603wCXsF0Dm1t38MD3k0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000U"

	if (ok:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, SubirArchivosTab))
	{
	  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%
	}
	Sleep 666

	SelArchButton := "|<Selecciona archivos>*159$133.00000000000000000000000000000000000000000000000800030000000010M0000w040001U00000000UA0001U020000000000000E00000U010000000000000800000M1sVsSDgS7sS0S/7Ztg8wD616F6MA6Mn6FUFa4H4m4l41lV9VM4289V0k0G412N6kq0AzYzc61g4lXs3t20VAmE9U2E2E430o2MGA34V0Ea984A1g1A30UN1A/412EU8H5663EW0W4kMAla5b0X8MY9VVW1jUwEwD7aD32R0TY3m4kkSDU0000000000000000000004"

	if (pk:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, SelArchButton))
	{
	  CoordMode, Mouse
	  X:=pk.1.1, Y:=pk.1.2, W:=pk.1.3, H:=pk.1.4, Comment:=pk.1.5, X+=W//2, Y+=H//2
      Click, %X%, %Y%
      WinWait, Open, , 2
      Sleep 1111
      Clip( arch )		; this sends the filename
      Send {Enter}
      
	}
	
}
(function 2)

Code: Select all

EstablecerImagenDestacada( foto ) {

	Send {Home}
	Sleep 333
	Send {PgDn}
	Sleep 333
	
	Text := "|<Establecer imagen destacada>*196$133." 
		. "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010800001U00000000A00000U400000000000000600400E200000000000000300200/X7Vlsw4ysS7ksy0TXlnnkq8aF1aE2Na9aMWNU8m9UU8m6G50V818F0G4l8E8N2kE6F29yUTY0a8Xt2Tq84AzC8T8VgUE820HAH4V82426E1YFYMWEA6109296NW1W1XA4G8nDV7XlwU4n4T7Ewl0TXnknsk000000000008000000000000000000000A000000000000000000001w000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004"

	if (ok:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 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%
	}
    
    Sleep 666
	SubirArchivo( foto )

}
(function 3)

Code: Select all

AñadirObjeto( objeto ) {
	
	AñadirObjetoButton := "|<Añadir objeto>*172$131.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000y000000000000000000003w00000000000000000000Tz00000000000000000000zy00000000000000000001sy00000000000000000003Utw043000a000k400000071vk0Q5U010001U00M0000T7rk0c00020003000k0000Tz1U1Mi7VwHkD7sXnls000zy304la94Na0nCNAn68001zw608W438H8128GEa8E00000A0za8yEWE66kYzAkU0000ks118GAV4U49V90MV00007Xk22MYNaN0AF6F0la0000TD0A6lDlom0D7sXsls0000wy00000000000100000001sw00000000000600000001Vk00000000000M000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004"

	if (ok:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, AñadirObjetoButton))
	{
	  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%
	  Sleep 333
	  SubirArchivo( objeto )
	}

}

HBinswanger
Posts: 17
Joined: 14 Feb 2016, 00:45

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

Post by HBinswanger » 05 Dec 2022, 15:13

I've spent a lot of time looking and Googling, but I can't seem to find where I can download the latest version of findtext.ahk
I very much need FindText(), so if you can help I'd be very grateful.

gregster
Posts: 8916
Joined: 30 Sep 2013, 06:48

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

Post by gregster » 05 Dec 2022, 15:28

HBinswanger wrote:
05 Dec 2022, 15:13
I've spent a lot of time looking and Googling, but I can't seem to find where I can download the latest version of findtext.ahk
I very much need FindText(), so if you can help I'd be very grateful.
See first post of this topic: viewtopic.php?f=6&t=17834#p86796

bbdude101
Posts: 1
Joined: 09 Dec 2022, 23:41

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

Post by bbdude101 » 09 Dec 2022, 23:46

Am I missing something here?

I downloaded the code from the first post and when I do to run it, I get an error on line 1884 "This line does not contain a recognizable action - Send CMD"

User avatar
boiler
Posts: 16767
Joined: 21 Dec 2014, 02:44

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

Post by boiler » 09 Dec 2022, 23:59

bbdude101 wrote: Am I missing something here?

I downloaded the code from the first post and when I do to run it, I get an error on line 1884 "This line does not contain a recognizable action - Send CMD"
You apparently didn’t report the error message correctly. It must say “Switch cmd”, not “Send CMD”. Update your AHK version to the latest. You are using an old version before the Switch command was added. The header of the script says: “Usage: (required AHK v1.1.31+)”

whitefree
Posts: 1
Joined: 09 Dec 2022, 22:28

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

Post by whitefree » 10 Dec 2022, 01:11

@feiyue

May I know what exactly these parts are used for?
can you explain please?
what binary is this?

thanks.

Code: Select all

    x32:=""
    . "5557565383EC6C83BC2480000000058BBC24C00000000F84E60800008BAC24C4"
    . "00000085ED0F8ECE0D0000C744240400000000C74424140000000031EDC74424"
    . "0800000000C7442418000000008D76008B8424BC0000008B4C241831F631DB01"
    . "C885FF894424107F3DE99100000066900FAF8424A800000089C189F099F7FF01"
    . "C18B442410803C1831744D8B8424B800000083C30103B424D8000000890CA883"
    . "C50139DF74558B44240499F7BC24C400000083BC24800000000375B40FAF8424"
    . "9400000089C189F099F7FF8D0C818B442410803C183175B38B4424088B9424B4"
    . "00000083C30103B424D8000000890C8283C00139DF8944240875AB017C241883"
    . "442414018B9C24DC0000008B442414015C2404398424C40000000F8530FFFFFF"
    . "896C241031C08B74240839B424C80000008B5C24100F4DF0399C24CC00000089"
    . "7424080F4CC339C6894424100F4DC683BC248000000003894424040F846C0800"
    . "008BAC24940000008B8424A00000000FAFAC24A40000008BB42494000000C1E0"
    . "028944243801C58B8424A8000000896C2434F7D88D0486894424248B84248000"
    . "000085C00F858A0300008B842484000000C744242000000000C7442428000000"
    . "00C1E8100FB6E88B8424840000000FB6C4894424140FB6842484000000894424"
    . "188B8424A8000000C1E002894424308B8424AC00000085C00F8EC60000008B7C"
    . "240C8B442434896C241C8BAC24A800000085ED0F8E8D0000008BB42490000000"
    . "8B6C242803AC24B000000001C6034424308944242C038424900000008944240C"
    . "0FB67E028B4C241C0FB6160FB646012B5424182B44241489FB01CF29CB8D8F00"
    . "0400000FAFC00FAFCBC1E00B0FAFCBBBFE05000029FB0FAFDA01C10FAFD301CA"
    . "399424880000000F93450083C60483C5013B74240C75A98B9C24A8000000015C"
    . "24288B44242C8344242001034424248B74242039B424AC0000000F854AFFFFFF"
    . "897C240C8B8424A80000002B8424D8000000C644244F00C644244E00C7442454"
    . "00000000C744246000000000894424588B8424AC0000002B8424DC0000008944"
    . "243C8B84248C00000083E80183F8070F87D005000083F803894424440F8ECB05"
    . "00008B4424608B74245489442454897424608B742458397424540F8FCE0A0000"
    . "8B4424588B742408C7442430000000008944245C8B8424B40000008D04B08B74"
    . "24448944245089F083E0018944244889F08BB4249000000083E003894424648B"
    . "4424608B7C243C39F80F8F7F010000837C2464018B5C24540F4F5C245C897C24"
    . "2C89442420895C24408DB426000000008B7C24488B44242C85FF0F4444242083"
    . "7C244403894424240F8FD5020000807C244E008B442440894424288B4424280F"
    . "85DD020000807C244F000F85800300000FAF8424A80000008B5424048B5C2424"
    . "85D28D2C180F8E840000008BBC24CC0000008B9424B000000031C08B9C24C800"
    . "0000896C24348B4C24088974241C01EA897C24188B6C24048B7C2410895C2414"
    . "39C17E1C8B9C24B40000008B348301D6803E00750B836C2414010F8860040000"
    . "39C77E1C8B9C24B80000008B348301D6803E00740B836C2418010F8840040000"
    . "83C00139E875B98B6C24348B74241C8B44240885C074278BBC24B00000008B84"
    . "24B40000008B5C24508D0C2F8D7426008B1083C00401CA39D8C6020075F28B44"
    . "2424038424A00000008B5C24308BBC24D00000008904DF8B442428038424A400"
    . "00008944DF0483C3013B9C24D4000000895C24307D308344242001836C242C01"
    . "8B4424203944243C0F8DA2FEFFFF8344245401836C245C018B44245439442458"
    . "0F8D59FEFFFF8B44243083C46C5B5E5F5DC2600083BC2480000000010F84E007"
    . "000083BC2480000000020F843B0500008B8424840000000FB6BC2484000000C7"
    . "44242C00000000C744243000000000C1E8100FB6D08B84248400000089D50FB6"
    . "DC8B842488000000C1E8100FB6C88B84248800000029CD01D1896C243C89DD89"
    . "4C24140FB6F40FB684248800000029F501DE896C241889FD8974241C29C501F8"
    . "894424288B8424A8000000896C2420C1E002894424388B8424AC00000085C00F"
    . "8EDFFCFFFF8B4C24348B6C243C8B8424A800000085C00F8E880000008B842490"
    . "0000008B542430039424B000000001C8034C243889CF894C243403BC24900000"
    . "00EB34395C24147C3D394C24187F37394C241C7C3189F30FB6F3397424200F9E"
    . "C3397424280F9DC183C00483C20121D9884AFF39C7741E0FB658020FB648010F"
    . "B63039DD7EBD31C983C00483C201884AFF39C775E28BB424A800000001742430"
    . "8B4C24348344242C01034C24248B44242C398424AC0000000F854FFFFFFFE921"
    . "FCFFFF8B442424807C244E00894424288B442440894424248B4424280F8423FD"
    . "FFFF0FAF8424940000008B5C24248D2C988B5C240485DB0F8EE1FDFFFF8BBC24"
    . "C800000031C9896C24148DB6000000008B8424B40000008B5C2414031C888B84"
    . "24B80000008B2C880FB6441E0289EAC1EA100FB6D229D00FB6541E010FB61C1E"
    . "0FAFC03B44240C7F2789E80FB6C429C20FAFD23B54240C7F1789E80FB6C029C3"
    . "0FAFDB3B5C240C7E108DB4260000000083EF010F887701000083C1013B4C2404"
    . "758E89AC2484000000E950FDFFFF66900FAF8424940000008B7C24248B4C2404"
    . "8D04B8894424140384248400000085C90FB65C06010FB67C06020FB60406895C"
    . "24188944241C0F8E12FDFFFF8B8424CC00000031DB894424388B8424C8000000"
    . "894424348B44240C897C240C8D742600395C24087E658B8424B40000008B4C24"
    . "148B7C240C030C980FB6440E020FB6540E010FB60C0E2B5424182B4C241C89C5"
    . "01F829FD8DB8000400000FAFD20FAFFDC1E20B0FAFFDBDFE05000029C50FAFE9"
    . "01FA0FAFCD01D1398C2488000000730B836C2434010F88A1000000395C24107E"
    . "618B8424B80000008B4C24148B7C240C030C980FB6440E020FB6540E010FB60C"
    . "0E2B5424182B4C241C89C501F829FD8DB8000400000FAFD20FAFFDC1E20B0FAF"
    . "FDBDFE05000029C50FAFE901FA0FAFCD01D1398C24880000007207836C243801"
    . "783A83C3013B5C24040F8521FFFFFF8944240CE906FCFFFF908DB42600000000"
    . "8B74241CE92DFCFFFF8DB4260000000089AC2484000000E91AFCFFFF8944240C"
    . "E911FCFFFFC7442444000000008B44243C8B742458894424588974243CE930FA"
    . "FFFF8B8424880000008BB424BC00000031C931DB31ED89BC24C0000000894424"
    . "048B8424840000000FAFC08944240CEB1AB80A0000006BDB0AF7E189F901DA89"
    . "FBC1FB1F01C111D383C6010FBE0685C00F84B80000008D78D083FF0976D383F8"
    . "2F75E58D04AD000000008944241489C80FACD8100FB7C00FAF8424DC00000099"
    . "F7BC24C40000000FAF84249400000089C70FB7C131C90FAF8424D800000099F7"
    . "BC24C00000008B9424B40000008D04878B7C24148904AA89D88B9C24B8000000"
    . "83C50189043B31DBE97BFFFFFF8B842484000000C1E8100FAF8424DC00000099"
    . "F7BC24C40000000FAF84249400000089C10FB78424840000000FAF8424D80000"
    . "0099F7FF8D04818984248400000083BC2480000000058B8424A80000000F9444"
    . "244E83BC2480000000030F9444244F038424A00000002B8424D8000000894424"
    . "588B8424A4000000038424AC0000002B8424DC0000008944243C8B8424A40000"
    . "00C78424A400000000000000894424548B8424A0000000C78424A00000000000"
    . "000089442460E977F8FFFF8B8424A8000000038424A00000008BAC24A8000000"
    . "8BB424A40000000FAFAC24AC000000894424208B8424A400000083EE01038424"
    . "AC00000003AC24B00000008974241439F0896C241C0F8C0E0100008BB424A000"
    . "000083C001C7442428000000008944242C8B8424800000002B8424A000000083"
    . "EE01897424308B7424140FAFB4249400000089C7897424248B74242001F78D6E"
    . "01897C24348B442430394424200F8C980000008B7C24148B5C24248B74242803"
    . "5C24382BB424A0000000039C2490000000C1EF1F0374241C897C2418EB4D6690"
    . "398424980000007E4B807C24180075448B7C241439BC249C0000007E370FB64B"
    . "FE0FB653FD83C3040FB67BF86BD24B6BC92601D189FAC1E20429FA01CAC1FA07"
    . "8854060183C00139E8741889C2C1EA1F84D274ACC64406010083C00183C30439"
    . "E875E88B7424340174242883442414018BBC24940000008B442414017C242439"
    . "44242C0F853CFFFFFF8B8424A80000008B8C24AC00000083C00285C989442420"
    . "0F8EBEF6FFFF8B8424AC0000008B6C241C036C2420C744241C01000000C74424"
    . "240000000083C001894424288B8424A8000000896C241883C0048944242C8B84"
    . "24880000008B9424A800000085D20F8EA70000008B4424188B5C24248B74242C"
    . "039C24B000000089C12B8C24A800000089C201C6894C2414908DB42600000000"
    . "0FB642010FB62ABF010000000384248400000039E8723D0FB66A0239E872358B"
    . "4C24140FB669FF39E872290FB66EFF39E872210FB669FE39E872190FB62939E8"
    . "72120FB66EFE39E8720A0FB63E39F80F92C189CF89F9834424140183C201880B"
    . "83C60183C3018B7C2414397C241875908BBC24A8000000017C24248344241C01"
    . "8B5C24208B74241C015C2418397424280F852FFFFFFF89842488000000E9A2F5"
    . "FFFF8B8424840000008BB424AC000000C744241400000000C744241800000000"
    . "83C001C1E007898424840000008B8424A8000000C1E00285F68944241C0F8E61"
    . "F5FFFF8B4424348BAC24840000008B9C24A800000085DB7E618B8C2490000000"
    . "8B5C2418039C24B000000001C10344241C894424200384249000000089C76690"
    . "0FB651020FB641010FB6316BC04B6BD22601C289F0C1E00429F001D039C50F97"
    . "0383C10483C30139F975D58BBC24A8000000017C24188B442420834424140103"
    . "4424248B74241439B424AC0000000F857AFFFFFFE9CBF4FFFFC7442410000000"
    . "00C744240800000000E916F3FFFFC744243000000000E90BF7FFFF9090909090"
    x64:=""
    . "4157415641554154555756534881EC88000000488BBC24F0000000488BB42430"
    . "01000083F905898C24D000000089542468448944240444898C24E80000004C8B"
    . "AC2438010000488B9C2440010000448B942450010000448B9C24580100000F84"
    . "5909000031ED4531E44585DB0F8E1901000044897424104C89AC243801000031"
    . "C0448BBC2420010000448BAC24D000000031ED448BB424800100004889B42430"
    . "0100004531E4C744240800000000C74424380000000089C64889BC24F0000000"
    . "48637C24384531C94531C04803BC24480100004585D27F33EB7B660F1F440000"
    . "410FAFC789C14489C89941F7FA01C142803C0731743C4983C0014863C54501F1"
    . "83C5014539C2890C837E4589F09941F7FB4183FD0375C90FAF8424F800000089"
    . "C14489C89941F7FA42803C07318D0C8175C4488B9424380100004983C0014963"
    . "C44501F14183C4014539C2890C827FBB4401542438834424080103B424880100"
    . "008B4424084139C30F8552FFFFFF448B742410488BBC24F0000000488BB42430"
    . "0100004C8BAC243801000031C04439A42460010000440F4DE039AC2468010000"
    . "0F4DE84139EC4189EF450F4DFC83BC24D0000000030F849A0800008B8424F800"
    . "00008B8C24100100000FAF8424180100008D04888B8C24F8000000894424208B"
    . "842420010000F7D88D0481894424088B8424D000000085C00F859E0300008B4C"
    . "24684889C84189CB0FB6C441C1EB1089C20FB6C1450FB6DB4189C28B84242801"
    . "000085C00F8E300100008B842420010000448964242831C94889B42430010000"
    . "4C89AC2438010000448B6424048BB42420010000448B6C2420C1E00244897C24"
    . "18896C24304889BC24F00000004489D5C744243800000000894424104189CF89"
    . "D748899C244001000085F60F8E84000000488B9C24F00000004963C54531D24C"
    . "8D4C030248635C243848039C2430010000450FB631410FB651FE410FB641FF29"
    . "EA4489F14501DE4189D0418D96000400004429D929F80FAFD10FAFC00FAFD1C1"
    . "E00B8D0402BAFE0500004429F2410FAFD0410FAFD001D04139C4420F93041349"
    . "83C2014983C1044439D67FA544036C2410017424384183C70144036C24084439"
    . "BC24280100000F855DFFFFFF448B7C2418448B6424288B6C2430488BBC24F000"
    . "0000488BB424300100004C8BAC2438010000488B9C24400100008B8424200100"
    . "002B842480010000C644245700C644245600C744246C00000000C74424780000"
    . "0000894424708B8424280100002B842488010000894424448B8424E800000083"
    . "E80183F8070F87F505000083F8038944244C0F8EF00500008B4424788B4C246C"
    . "8944246C894C24788B4C2470394C246C0F8F600B00008B4424708B4C244C4889"
    . "9C24400100004889F34C89EEC74424300000000089442474418D4424FF498D44"
    . "85044589E54C8BA42440010000488944246089C883E0018944245089C883E003"
    . "8944247C8B4424788B4C244439C80F8F38010000837C247C018B54246C0F4F54"
    . "2474894C2428894424088954244866908B44245085C08B4424280F4444240883"
    . "7C244C03894424380F8FD2020000807C2456008B442448894424100F85DA0200"
    . "00807C2457000F85740300008B4C24100FAF8C2420010000034C24384585FF7E"
    . "50448B942468010000448B8C246001000031C04139C589C27E184189C8440304"
    . "8642803C0300750A4183E9010F888200000039D57E1289CA41031484803C1300"
    . "74064183EA01786C4883C0014139C77FC24585ED741B4C8B4424604889F06690"
    . "89CA03104883C0044C39C0C604130075EF8B4C24308B54243803942410010000"
    . "4C8B94247001000089C801C04898418914828B54241003942418010000418954"
    . "820489C883C0013B842478010000894424307D308344240801836C2428018B44"
    . "2408394424440F8DE4FEFFFF8344246C01836C2474018B44246C394424700F8D"
    . "A0FEFFFF8B4424304881C4880000005B5E5F5D415C415D415E415FC383BC24D0"
    . "000000010F84AC08000083BC24D0000000020F84520500008B542468448B5424"
    . "04C744241000000000C74424180000000089D0440FB6C2C1E810440FB6C84889"
    . "D00FB6CC4489D04589CBC1E810894C24380FB6D04C89D00FB6C44129D34401CA"
    . "89C18B44243829C8034C243889442430410FB6C24589C24129C24401C0448B84"
    . "2428010000894424388B842420010000C1E0024585C0894424280F8E1AFDFFFF"
    . "448974243C896C24484C89AC2438010000448B7424208BAC2420010000448B6C"
    . "243044897C244044896424444189CF48899C24400100004189D44489D385ED7E"
    . "724C635424184963C631D2488D4407024901F2EB314539C47C3E4139CD7F3941"
    . "39CF7C344439CB410F9EC044394C24380F9DC14883C0044421C141880C124883"
    . "C20139D57E24440FB6000FB648FF440FB648FE4539C37EBD31C94883C0044188"
    . "0C124883C20139D57FDC4403742428016C2418834424100144037424088B4424"
    . "10398424280100000F856FFFFFFF448B74243C448B7C2440448B6424448B6C24"
    . "484C8BAC2438010000488B9C2440010000E924FCFFFF662E0F1F840000000000"
    . "8B442438807C245600894424108B442448894424380F8426FDFFFF8B4424108B"
    . "4C24380FAF8424F80000004585FF448D14880F8E99FDFFFF448B8C2460010000"
    . "4531C04989DB662E0F1F840000000000428B1486438B1C844401D289D98D4202"
    . "C1E9100FB6C948980FB6040729C88D4A014863D20FAFC00FB614174863C90FB6"
    . "0C0F4439F07F1A0FB6C729C10FAFC94439F17F0D0FB6C329C20FAFD24439F27E"
    . "0A4183E9010F88950100004983C0014539C77F9C895C24684C89DBE911FDFFFF"
    . "8B4424108B4C24380FAF8424F80000008D048889C1034424684585FF8D500248"
    . "63D2440FB614178D500148980FB604074863D20FB614170F8ED4FCFFFF448B9C"
    . "246801000048895C24584531C948897424184C8964242089CB89C64189D44489"
    . "5C2440448B9C246001000044895C243C4539CD4589C87E6E488B442418428B14"
    . "8801DA8D42024898440FB634078D42014863D20FB6141748980FB604074589F3"
    . "4501D6418D8E000400004529D329F2410FAFCB4429E00FAFC0410FAFCB41BBFE"
    . "050000C1E00B4529F3440FAFDA01C8410FAFD301C239542404730B836C243C01"
    . "0F88A60000004439C57E6A488B442420428B148801DA8D42024898440FB63407"
    . "8D42014863D20FB6141748980FB604074589F04501D6418D8E000400004529D0"
    . "29F2410FAFC84429E00FAFC0410FAFC841B8FE050000C1E00B4529F0440FAFC2"
    . "01C8410FAFD001C2395424047207836C24400178374983C1014539CF0F8F0EFF"
    . "FFFF488B5C2458488B7424184C8B642420E99BFBFFFF662E0F1F840000000000"
    . "895C24684C89DBE9C8FBFFFF488B5C2458488B7424184C8B642420E9B4FBFFFF"
    . "C744244C000000008B4424448B4C247089442470894C2444E90BFAFFFF8B4424"
    . "68448B7C24044531C04C8B8C244801000031C94189C6440FAFF0EB0F4B8D0480"
    . "4863D24C8D04424983C101410FBE0185C00F84960000008D50D083FA0976DD83"
    . "F82F75E34C89C048C1E8100FB7C00FAF8424880100009941F7FB0FAF8424F800"
    . "000089442408410FB7C049C1E8200FAF8424800100009941F7FA8B5424088D04"
    . "824863D183C1014189449500448904934531C0EB92448B4C24684489C8C1E810"
    . "0FAF8424880100009941F7FB0FAF8424F800000089C1410FB7C10FAF84248001"
    . "00009941F7FA8D04818944246883BC24D0000000058B8424200100000F944424"
    . "5683BC24D0000000030F94442457038424100100002B84248001000089442470"
    . "8B842418010000038424280100002B842488010000894424448B842418010000"
    . "C7842418010000000000008944246C8B842410010000C7842410010000000000"
    . "0089442478E98EF8FFFF8B8424200100008B8C24180100000FAF842428010000"
    . "83E90189CA48984801F048894424088B84242001000003842410010000894424"
    . "388B8424180100000384242801000039C80F8C750100008B8C241001000083C0"
    . "0148899C244001000089442420C74424180000000089D3448974244444897C24"
    . "4883E901448964244C4889B424300100004189CA894C243C8B8C24F800000042"
    . "8D0495000000000FAFCA89442430489848894424288B8424D00000002B842410"
    . "010000894C24108B4C24384189C3448D51014101CB44895C2440448B9C240001"
    . "00008B44243C394424380F8CA50000008B4C24108B5424304189DE488B742428"
    . "4C6344241841C1EE1F4C0344240801CA4C63F94863D24C8D0C174829D6EB5190"
    . "4139C37E544584F6754F399C24080100007E46410FB64902410FB6510183C001"
    . "4983C0016BD24B6BC92601D14A8D140E4983C104460FB6243A4489E2C1E20444"
    . "29E201D1C1F907418848FF4139C2741D89C2C1EA1F84D274A783C00141C60000"
    . "4983C1044983C0014139C275E38B7424400174241883C3018BB424F800000001"
    . "742410395C24200F8535FFFFFF448B742444448B7C2448448B64244C488BB424"
    . "30010000488B9C24400100008B842420010000448B94242801000083C0024585"
    . "D20F8E73F6FFFF488B4C2408489844897C24404889442410448B7C246848899C"
    . "2440010000C744240801000000488D440101C744243800000000448974243C48"
    . "89C18B8424280100004889CB83C001894424184863842420010000488D500348"
    . "F7D048894424288B84242001000048895424208B54240483E8014883C0014889"
    . "442430448B8C24200100004585C90F8EAF000000488B44242048634C24384C8D"
    . "0C18488B4424284801F14C8D0418488B4424304C8D34184889D8660F1F440000"
    . "0FB610440FB650FF41BB010000004401FA4439D2724A440FB650014439D27240"
    . "450FB650FF4439D27236450FB651FF4439D2722C450FB650FE4439D27222450F"
    . "B6104439D27219450FB651FE4439D2720F450FB6114439D2410F92C30F1F4000"
    . "4883C0014488194983C1014883C1014983C0014C39F075888B8C242001000001"
    . "4C2438834424080148035C24108B442408394424180F8528FFFFFF448B74243C"
    . "448B7C244089542404488B9C2440010000E904F5FFFF8B4424684531DBC74424"
    . "380000000083C001C1E007894424688B842420010000C1E002894424108B8424"
    . "2801000085C00F8ECEF4FFFF44897C242848899C2440010000448B7C2468448B"
    . "9424200100008B5C242044897424184585D27E594C637424384863C34531C048"
    . "8D4C07024901F6660F1F8400000000000FB6110FB641FF440FB649FE6BC04B6B"
    . "D22601C24489C8C1E0044429C801D04139C7430F9704064983C0014883C10445"
    . "39C27FCC035C241044015424384183C301035C240844399C2428010000759044"
    . "8B742418448B7C2428488B9C2440010000E924F4FFFFC744243000000000E941"
    . "F6FFFF90909090909090909090909090"

Descolada
Posts: 1098
Joined: 23 Dec 2021, 02:30

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

Post by Descolada » 10 Dec 2022, 10:59

@whitefree, I'm not feiyue, but I think I can answer the question. It is machine code (compiled C code) for speedier image search, x32 for 32-bit AHK and x64 for 64-bit. The source code for that is provided a bit further down in FindText.ahk:

Code: Select all

	  /***** C source code of machine code *****
  
	  int __attribute__((__stdcall__)) PicFind(
		int mode, unsigned int c, unsigned int n, int dir
		, unsigned char * Bmp, int Stride, int zw, int zh
		, int sx, int sy, int sw, int sh
		, char * ss, unsigned int * s1, unsigned int * s0
		, char * text, int w, int h, int err1, int err0
		, unsigned int * allpos, int allpos_max
		, int new_w, int new_h )
	  {
		int ok=0, o, i, j, k, v, r, g, b, rr, gg, bb;
		int x, y, x1, y1, x2, y2, len1, len0, e1, e0, max;
		int r_min, r_max, g_min, g_max, b_min, b_max, x3, y3;
		unsigned char * gs;
		unsigned long long sum;
		//----------------------
		// MultiColor or PixelSearch or ImageSearch Mode
		if (mode==5)
		{
		  max=n; v=c*c;
		  for (i=0, sum=0, o=0; (j=text[o++])!='\0';)
		  {
			if (j>='0' && j<='9')
			  sum = sum*10 + (j-'0');
			else if (j=='/')
			{
			  y=(sum>>16)&0xFFFF; x=sum&0xFFFF;
			  s1[i]=(y*new_h/h)*Stride+(x*new_w/w)*4;
			  s0[i++]=sum>>32; sum=0;
			}
		  }
		  goto StartLookUp;
		}
		//----------------------
		// Generate Lookup Table
		o=0; len1=0; len0=0;
		for (y=0; y<h; y++)
		{
		  for (x=0; x<w; x++)
		  {
			if (mode==3)
			  i=(y*new_h/h)*Stride+(x*new_w/w)*4;
			else
			  i=(y*new_h/h)*sw+(x*new_w/w);
			if (text[o++]=='1')
			  s1[len1++]=i;
			else
			  s0[len0++]=i;
		  }
		}
		if (err1>=len1) len1=0;
		if (err0>=len0) len0=0;
		max=(len1>len0) ? len1 : len0;
		//----------------------
		// Color Position Mode
		// only used to recognize multicolored Verification Code
		if (mode==3)
		{
		  y=c>>16; x=c&0xFFFF;
		  c=(y*new_h/h)*Stride+(x*new_w/w)*4;
		  goto StartLookUp;
		}
		//----------------------
		// Generate Two Value Image
		o=sy*Stride+sx*4; j=Stride-sw*4; 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; v=r+rr+rr;
			  ss[i]=((1024+v)*r*r+2048*g*g+(1534-v)*b*b<=n) ? 1:0;
			}
		}
		else if (mode==1)  // Gray Threshold Mode
		{
		  c=(c+1)<<7;
		  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
		{
		  gs=(unsigned char *)(ss+sw*sh);
		  x2=sx+sw; y2=sy+sh;
		  for (y=sy-1; y<=y2; y++)
		  {
			for (x=sx-1; x<=x2; x++, i++)
			  if (x<0 || x>=zw || y<0 || y>=zh)
				gs[i]=0;
			  else
			  {
				o=y*Stride+x*4;
				gs[i]=(Bmp[2+o]*38+Bmp[1+o]*75+Bmp[o]*15)>>7;
			  }
		  }
		  k=sw+2; i=0;
		  for (y=1; y<=sh; y++)
			for (x=1; x<=sw; x++, i++)
			{
			  o=y*k+x; n=gs[o]+c;
			  ss[i]=(gs[o-1]>n || gs[o+1]>n
				|| gs[o-k]>n   || gs[o+k]>n
				|| gs[o-k-1]>n || gs[o-k+1]>n
				|| gs[o+k-1]>n || gs[o+k+1]>n) ? 1:0;
			}
		}
		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;
			}
		}
		//----------------------
		StartLookUp:
		w=new_w; h=new_h;
		if (mode==5 || mode==3)
		  { x1=sx; y1=sy; x2=sx+sw-w; y2=sy+sh-h; sx=0; sy=0; }
		else
		  { x1=0; y1=0; x2=sw-w; y2=sh-h; }
		if (dir<1 || dir>8) dir=1;
		// 1 ==> ( Left to Right ) Top to Bottom
		// 2 ==> ( Right to Left ) Top to Bottom
		// 3 ==> ( Left to Right ) Bottom to Top
		// 4 ==> ( Right to Left ) Bottom to Top
		// 5 ==> ( Top to Bottom ) Left to Right
		// 6 ==> ( Bottom to Top ) Left to Right
		// 7 ==> ( Top to Bottom ) Right to Left
		// 8 ==> ( Bottom to Top ) Right to Left
		if (--dir>3) { i=y1; y1=x1; x1=i; i=y2; y2=x2; x2=i; }
		for (y3=y1; y3<=y2; y3++)
		{
		  for (x3=x1; x3<=x2; x3++)
		  {
			y=((dir&3)>1) ? y1+y2-y3 : y3;
			x=(dir&1) ? x1+x2-x3 : x3;
			if (dir>3) { i=y; y=x; x=i; }
			//----------------------
			e1=err1; e0=err0;
			if (mode==5)
			{
			  o=y*Stride+x*4;
			  for (i=0; i<max; i++)
			  {
				j=o+s1[i]; c=s0[i]; r=Bmp[2+j]-((c>>16)&0xFF);
				g=Bmp[1+j]-((c>>8)&0xFF); b=Bmp[j]-(c&0xFF);
				if ((r*r>v || g*g>v || b*b>v) && (--e1)<0)
				  goto NoMatch;
			  }
			}
			else if (mode==3)
			{
			  o=y*Stride+x*4;
			  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; v=r+rr+rr;
				  if ((1024+v)*r*r+2048*g*g+(1534-v)*b*b>n && (--e1)<0)
					goto NoMatch;
				}
				if (i<len0)
				{
				  j=o+s0[i]; r=Bmp[2+j]-rr; g=Bmp[1+j]-gg; b=Bmp[j]-bb; v=r+rr+rr;
				  if ((1024+v)*r*r+2048*g*g+(1534-v)*b*b<=n && (--e0)<0)
					goto NoMatch;
				}
			  }
			}
			else
			{
			  o=y*sw+x;
			  for (i=0; i<max; i++)
			  {
				if (i<len1 && ss[o+s1[i]]==0 && (--e1)<0) goto NoMatch;
				if (i<len0 && ss[o+s0[i]]!=0 && (--e0)<0) goto NoMatch;
			  }
			  // Clear the image that has been found
			  for (i=0; i<len1; i++)
				ss[o+s1[i]]=0;
			}
			allpos[ok*2]=sx+x; allpos[ok*2+1]=sy+y;
			if (++ok>=allpos_max) goto Return1;
			NoMatch:;
		  }
		}
		//----------------------
		Return1:
		return ok;
	  }
  
	  */

User avatar
SteveMylo
Posts: 233
Joined: 22 Jun 2021, 00:50
Location: Australia
Contact:

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

Post by SteveMylo » 25 Dec 2022, 16:57

How can I ask if both searches have the same coordinates?
Merry Christmas , what better time to relax and check out the forum :lol: :xmas:
To keep my example simple, these two FindText() If statements find the same Red dot cause there is only one.
The 1st search is from Bottom Left and 2nd search is from Top Right, obviously both find the same red dot.

Code: Select all

Text:="|<>[email protected]$5.zzzzzz"
If (ok1:=FindText(bX, bY, X2, Y3, X4-(X2-X1), Y4, 0, 0, Text,,,,,,6))
Sleep, 111
If (ok2:=FindText(cX, cY, X2, Y3, X4-(X2-X1), Y4, 0, 0, Text,,,,,,7))
So How can I ask if both searches have the same coordinates?
This codes below do not work, I don't even know if it's the right way of going about it :?:

Code: Select all

If (ok1[1].x = ok2[1].x)   ; does not work
{
    soundbeep
    return
}
return

;=====================================
If bX = cX   ; does not work
{
    soundbeep
    return
}
return

feiyue
Posts: 349
Joined: 08 Aug 2014, 04:08

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

Post by feiyue » 25 Dec 2022, 20:52

FindText().ObjView(ok1)
FindText().ObjView(ok2)

anothermartz
Posts: 3
Joined: 10 Jan 2023, 16:13

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

Post by anothermartz » 10 Jan 2023, 16:33

@feiyue

Hi and thank you for this incredible script!

I believe there's a bug with X:="wait" and setting the scale.

Normal search finds my target with scale set to 2:

Code: Select all

ok:=FindText(X,Y,,,,,0.2,0.2,Text,,,,,,,2,2)
target is found
But if I do it with a wait, it is unable to find it:

Code: Select all

ok:=FindText(X:="wait",Y:=3,,,,,0.2,0.2,Text,,,,,,,2,2)
target is not found
Even if I do it with wait0 it works:

Code: Select all

ok:=FindText(X:="wait0",Y:=3,,,,,0.2,0.2,Text,,,,,,,2,2)
target is found

anothermartz
Posts: 3
Joined: 10 Jan 2023, 16:13

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

Post by anothermartz » 11 Jan 2023, 09:04

I thought I fixed it by changing line 111 in FindText.ahk from

Code: Select all

, zoomW:=1, zoomH:=1)
to

Code: Select all

, zoomW:="", zoomH:="")
But I was mistaken :(

It seems that rather than just not finding it when scale isn't set to 1, FindText actually crashes! If the timer is set to 1, it won't return after 1 second, it will just freeze. Whereas is scale is set to 1/default, the search will return as not found if not found within the time limit.

I suppose I will make my own timer loop in the meantime:

Code: Select all

time:=3
timeout:=A_TickCount+Round(time*1000)
loop
{
ok:=FindText(X,Y,,,,,0.2,0.2,Text,,,,,,,2,2)
      if (time>=0 and A_TickCount>=timeout)

      Break
}until ok!=0

feiyue
Posts: 349
Joined: 08 Aug 2014, 04:08

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

Post by feiyue » 12 Jan 2023, 04:30

Usually I use FindText for office automation, so I need to search for static images.
For reliability, it is better to ensure that the image remains unchanged for 0.5 seconds after finding the image.
The image location found when the page is just displayed and expanded may be different from the final display location.
This does enhance the reliability, but you can't find the changing image (if it can't be stable for 0.5 seconds),
so you need to write your own circular search.

anothermartz
Posts: 3
Joined: 10 Jan 2023, 16:13

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

Post by anothermartz » 15 Jan 2023, 17:10

feiyue wrote:
12 Jan 2023, 04:30
Usually I use FindText for office automation, so I need to search for static images.
For reliability, it is better to ensure that the image remains unchanged for 0.5 seconds after finding the image.
The image location found when the page is just displayed and expanded may be different from the final display location.
This does enhance the reliability, but you can't find the changing image (if it can't be stable for 0.5 seconds),
so you need to write your own circular search.
I am testing this with static images.

With no wait, image is found at different scales (image and search scale are equal).

With wait0, image is found (sees it until it is not there, as expected) at different scales

With wait1/wait - image is found if they are at scale 1, but if the scale is set to anything else, it is not that it can't find it, actually the whole script freezes!

Please test yourself to see if you can get your script to find an image with wait1 at scale 2, it will freeze.

feiyue
Posts: 349
Joined: 08 Aug 2014, 04:08

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

Post by feiyue » 16 Jan 2023, 02:55

@anothermartz Thank you for your feedback. This is really caused by a bug. :thumbup: :beer:
When adding the last two parameters, I didn't think well and debugging was too little.
Now I have fixed this bug, because there are no more updates, so the version number has not changed.

Post Reply

Return to “Scripts and Functions (v1)”