Re: FindText - Capture screen image into text and then find it
Posted: 18 May 2018, 07:27
thats very impressive!
thank you so much
thank you so much
Let's help each other out
https://www.autohotkey.com/boards/
Please explain. I have attempted to set the err0 and err1 values to 1, 2, 3, 4, 5 and many others assuming it meant "percentage" and even just 1% makes my picture go crazy when 1% shouldn't be doing that.FindText(X,Y,W,H,err0,err1,Text)
err1 is the character "0" fault-tolerant in percentage (0-1) Default 0.
err0 is the character "_" fault-tolerant in percentage.(0-1) Default 0.
Ah, now that works better. Thanks lad.feiyue wrote:err1、err0 set 0.1 is 10%, 1 is 100%.
WinGetPos, x, y, w, h, Aguest26789 wrote:Is there a way to make it only search a certain window? (or coordinates in a window?)
feiyue wrote:@jt_kirk, I think this is a relatively easy solution:Code: Select all
;---------------------------- ; Load Pictures to GUI ;---------------------------- Gui, +AlwaysOnTop +ToolWindow Gui, Color, DDEEFF Gui, Font, cRed s28 Gui, Add, Text,, Drag Pictures here to Load . `n`nPress Enter or Space to Clear. Gui, Show,, Load Pictures OnMessage(0x201, "LButton_Down") return LButton_Down() { ListLines, Off if (A_Gui=1 or A_Gui=2) and (A_GuiControl="") SendMessage, 0xA1, 2 } GuiClose: ExitApp GuiDropFiles: Gui, +OwnDialogs Loop, parse, A_GuiEvent, `n { file:=A_LoopField Gosub, LoadPic } return LoadPic: Gui, 2:Default Gui, +LastFound +AlwaysOnTop +Owner1 -Caption Gui, Margin, 0, 0 Gui, Color, White Gui, Add, Button, w50 Default, OK Gui, Add, Picture, vPic, %file% GuiControlGet, p, Pos, Pic if pW>50 GuiControl, Move, Button1, w%pW% Gui, Show WinWaitClose return 2ButtonOK: 2GuiEscape: Gui, Destroy return ;----------- Script End ----------- ;
Code: Select all
/*
Use examples:
Loop {
pic1:=GetPicArr(100, 100, 20, 10)
Sleep, 1000
pic2:=GetPicArr(100, 100, 20, 10)
if ComparePicArr(pic1, pic2, n:=0.3)
{
MsgBox, The screen image changed !
Send z
}
}
*/
; Get the RGB value of all the points of the picture to the array
GetPicArr(x, y, w, h)
{
xywh2xywh(x,y,w,h, x,y,w,h)
if (w<1 or h<1)
return, 0
ListLines, % "Off" (lls:=A_ListLines=0?"Off":"On")/0
SetBatchLines, % "-1" (bch:=A_BatchLines)/0
GetBitsFromScreen(x,y,w,h,Scan0,Stride,bits)
arr:=[], i:=-4
Loop, % w*h
arr.Push(NumGet(bits,i+=4,"uint")&0xFFFFFF)
SetBatchLines, %bch%
ListLines, %lls%
return, arr
}
; Check whether all change points in the picture exceed the percentage
ComparePicArr(arr1, arr2, n:=0.3)
{
diff:=0, diffMax:=Round(arr1.MaxIndex()*n)
For k,v in arr1
diff+=(arr2[k]!=v)
if (diff>diffMax)
return, 1
return, 0
}