![Yay! Dance! Yay! :dance:](./images/smilies/dance.gif)
.... 1. Merge FindText() and FindText2() functions.
.... 2. The color difference mode is added to adjust the matching range accurately.
.... 3. Add a parameter "FindAll" that allows you to find only one result and return it immediately.
Wow
Code: Select all
for i,v in ok
if i<=12
MouseTip(v.1+v.3//2, v.2+v.4//2)
Code: Select all
findTextTool_demo_backwardsLoop_bottomTooTop(ok)
findTextTool_demo_backwardsLoop_bottomTooTop(ok){
i := ok.MaxIndex()
while(ok[i] && i){
X:=ok[i].1+ok[i].3//2, Y:=ok[i].2+ok[i].4//2, W:=ok.1.3, H:=ok.1.4, Comment:=ok.1.5, X+=W//2, Y+=H//2
MouseMove,% X+50 + mod(A_Index,2)*40,% Y ; MouseClick,left,% X+50,% Y
i--
}
Return
}
That's the problem i currently facing, but how to use PicX(), can you detail a bit more.feiyue wrote: ↑11 Apr 2019, 19:08Updated to 6.6 version - 2019/04/11
.... 1. FindText(), FindText2() share the same machine code, reduces the code size.
For a single text or image, the effects of these two functions are similar,
but for multiple text or images, FindText() loops through each text or image,
while FindText2() looks at them as a continuous combination of text for a one-time search.
Sometimes the text of a web page will be deformed and the spacing will be increased.
You can automatically cut a text into more than one text with PicX() and use FindText2() to find it.
FindText(..., Text ) ==> FindText2(..., PicX(Text) )
Hi. Instead of putting all coordinates in 1 variable, split them into 4. So you only need to update 4 variables instead of several lines in your script.snowiscold1 wrote: ↑01 Apr 2019, 08:14Hi feiyue,
I am new to autohotkey and I found out about your script a month ago. I have been working on my games in Bluestack, but I have 1 issue. I am unable to pass the parameter of EmulatorArea variable to the function. It gives me this error. I have tried with and without percentage sign. Please help me thank you.
test.png
Code: Select all
#SingleInstance Force EmulatorArea=145,645,244,751 t1:=A_TickCount Text:="|<>*122$41.zVzzzzzytzzzzzvvzzzzzrq3X4DzjgquTTzTPg5szyyrPvhzytanrPzyD3ki7zzyzzzzzzxzzzzzzvzzzzzzzzzzzzzzzzzzzzzzzzsTzzzzzrTzzzzzizzzzzzRX6vcsk7BqmLiZqvhJb1PhrOfayrPil7YxVrXrQQ/U" if (ok:=FindText(EmulatorArea, 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% } MsgBox, 4096,, % "Time:`t" (A_TickCount-t1) " ms`n`n" . "Pos:`t" X ", " Y "`n`n" . "Result:`t" (ok ? "Success !":"Failed !"), 3 MouseMove, X, Y (ok) && MouseTip()
There is no problem with the script. The problem is with windows and AHK and how the DPI scaling is implemented.SL5 wrote: ↑09 Apr 2019, 01:45ups. @feiyue, thanks for answering and again for all your great work on this script.(now inserted it as gif without audio now).feiyue wrote: ↑09 Apr 2019, 00:30I'm sorry, I'm from China, so I can't go to www.youtube.com or https youtu.be Broken Link for safety
in other words:
How would you do it if you wrote that yourself?
1. So first search for the window and save the area. how?
2. then use this area in FindText. how?
whey is facotr 1.88 nedet? (see examples below). do you use factor 1.88? is everybody using factor 1.88? only me? How would you do it if you did not use a factor?
Code: Select all
needle=Action List Appears Here ahk_class AutoHotkeyGUI ; mouseWindowTitle=0x100b50 ; WinGetPos, wX, wY, wW, wH, % needle xxx:=floor(wX/1.88) yyy:=floor(wY/1.88) if(ok:=FindText(xxx,yyy,xxx+wW,yyy+wH, 0, 0, Text)){ 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 MouseMove,% X+50,% Y msgbox,found }else{ Clipboard = found nothing in %wX%`, %wY%`, %wW%`, %wH% (19-04-09_01-29) msgbox, % Clipboard }
at least that sounds like I'm not wrong, not totally wrong. that helps me a lot already! thanks for the feedback.i will check that.
^---- I think it has nothing to do with my question but thanks anyway (i dont use a string)feiyue wrote: ↑09 Apr 2019, 00:30snowiscold1 , Here's a small wrapper function that calls FindText.Code: Select all
MyFindText(EmulatorArea, arg*) { a:=IsObject(EmulatorArea) ? EmulatorArea : StrSplit(EmulatorArea, ",") return, FindText(a[1]+0, a[2]+0, a[3]+0, a[4]+0, arg*) } EmulatoraArea:="x,y,w,h" ...
Code: Select all
; @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, Other parameters are the same as FindText()
@FindText(x1, y1, x2, y2, @*) {
return, FindText(x1, y1, x2-x1+1, y2-y1+1, @*)
}
Code: Select all
Text:="|<d>*165$7.1UkMAzXVksQD6zU"
Text.="|<a>*164$7.SFUHv56XSs"
Pic(Text, d)
Pic(Text, a)
if (ok:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, PicN("da"), 1, 1, JoinText:=1))
{
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%
}
Code: Select all
; You can put the text library at the beginning of the script,
; and Use Pic(Text,1) to add the text library to Pic()'s Lib,
; Use Pic("comment1|comment2|...") to get text images from Lib
Pic(comments, add_to_Lib=0)
{
static Lib:=[]
if (add_to_Lib)
{
re:="<([^>]*)>[^$]+\$\d+\.[\w+/]+"
Loop, Parse, comments, |
if RegExMatch(A_LoopField,re,r)
Lib[Trim(r1)]:=r
Lib[""]:=""
}
else
{
Text:=""
Loop, Parse, comments, |
Text.="|" . Lib[Trim(A_LoopField)]
return, Text
}
}
PicN(Number)
{
return, Pic( RegExReplace(Number, ".", "|$0") )
}
Code: Select all
CheckIfFarmersBusy:
ScreenShot()
okfb:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, farmerbusy, 0,0)
okfb1:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, farmerbusy1, 0,0)
okrss:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, searchRSS, 0,0)
okcl:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, cropland, 0,0)
okfl:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, foodlabel, 0,0)
oksrb:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, searchRSSButton, 0,0)
okf:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, farm, 0,0)
okf1:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, farm1, 0,0)
okf2:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, farm2, 0,0)
okf3:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, farm3, 0,0)
okf4:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, farm4, 0,0)
okf5:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, farm5, 0,0)
okgr:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, gatherRSS, 0,0)
okua:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, userAccount, 0,0)
okizl:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, izzy01label, 0,0)
okizzy01:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, izzy01, 0,0)
okshanewat:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, shanewat, 0,0)
okshanewatlabel:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, shanewatlabel, 0,0)
okuserSetting:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, userSetting, 0,0)
okcharacterManagement:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, characterManagement, 0,0)
okcharacterLogin:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, characterLogin, 0,0)
okuserAllAccount:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, userAllAccount, 0,0)
okchooseAnAccount:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, chooseAnAccount, 0,0)
okcandicecoldgmail:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, candicecoldgmail, 0,0)
okgoogleButton:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, googleButton, 0,0)
okswitchButton:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, switchButton, 0,0)
okfightfairlabel:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, fightfairlabel, 0,0)
oklionsloverlabel:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, lionsloverlabel, 0,0)
okfightfair:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, fightfair, 0,0)
oklionslover:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, lionslover, 0,0)
okcharismajoygmail:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, charismajoygmail, 0,0)
okdannypopolabel:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, dannypopolabel, 0,0)
okcharismajoylabel:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, charismajoylabel, 0,0)
okdannypopo:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, dannypopo, 0,0)
okcharismajoy:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, charismajoy, 0,0)
okmalikneevedgmail:=FindText(0, 0, A_ScreenWidth, A_ScreenHeight, 0, 0, malikneevedgmail, 0,0)
Code: Select all
clickText(o){
X:=o[1].1, Y:=o[1].2, W:=o[1].3, H:=o[1].4, X+=W//2, Y+=H//2
Click, %X%, %Y%
Sleep, 500
}
did you tried:
Code: Select all
SetTitleMatchMode, 2
WinGetPos, wX, wY, wW, wH, bluestacks_5
okfb:=FindText(wX, wY,wW,wH, tolerant1:=0, tolerant2:=0, farmerbusy)
Code: Select all
rectangleTip(wX,wY,wW,wH)
;/¯¯¯¯ rectangleTip ¯¯ 190424041852 ¯¯ 24.04.2019 04:18:52 ¯¯\
rectangleTip(x,y,w,h){
Gui, _rectangleTip_: +AlwaysOnTop -Caption +ToolWindow +Hwndmyid +E0x08000000
Gui, _rectangleTip_: Show, Hide w%w% h%h%
dhw:=A_DetectHiddenWindows
DetectHiddenWindows, On
d:=8, i:=w-d, j:=h-d
s=0-0 %w%-0 %w%-%h% 0-%h% 0-0
s=%s% %d%-%d% %i%-%d% %i%-%j% %d%-%j% %d%-%d%
WinSet, Region, %s%, ahk_id %myid%
DetectHiddenWindows, %dhw%
Gui, _rectangleTip_: Show, NA x%x% y%y%
Loop, 8 {
Gui, _rectangleTip_: Color, % A_Index & 1 ? "Red" : "Green"
Sleep, 500
}
}
;\____ rectangleTip __ 190424041908 __ 24.04.2019 04:19:08 __/
Return to “Scripts and Functions (v1)”
Users browsing this forum: No registered users and 183 guests