First, thank you feiyue for the really nice script. I'm very new to scripting and AHK, but I've been able to use your example below and it works great. Much faster than trying to do the same thing in imagesearch.
As I said, I'm new to all of this so looking for advice on how to modify your script to conduct a nested search within the initial loop. The flow would look something like this:
1. Search for images using your original multi-image search loop.
2. If Image 1 found, click ;; I have this working
3. If Image 2 found, click ;; I have this working
4. If Image 3 found, click And
4a. While Image 3a, 3b and 3c are on the screen, click each until all have been clicked. ;; When Image 3 is clicked, it brings up another screen with 3 images on it. When an image is clicked, it is removed from the screen. I want this nested loop to click each of these until none are remaining. There may be 1, 2 or 3 images present so it needs to click until all of them are gone.
Images in initial loop:
Image 1
Image 2
Image 3
Images in nested loop initiated when Image 3 is clicked:
Image 3a
Image 3b
Image 3c
Pseudocode:
If Image 1 is found, Click
If Image 2 is found, Click
If Image 3 is found, Click
While (Image 3a and/or 3b and/or 3c) are on screen, Click each until none remain
I'm not sure I've explained this very well so please let me know if I can clarify. Thanks for any assistance!
feiyue wrote:rupeshrulzz wrote: I want to put the details for all the required images in the beginning of the script and then call the desired image search wherever I need it in the script. How could I do it?
This problem is easy to solve, you can do it like this:
Code: Select all
; This function import text images through the comments in < >
Pic(comments, add_new=0) {
static Lib:=[]
if (add_new)
{
re:="<([^>]*)>[^$]+\$\d+\.[\w+/]{3,}"
Loop, Parse, comments, |
if RegExMatch(A_LoopField,re,r)
Lib[Trim(r1)]:=r
}
else
{
text:=""
Loop, Parse, comments, |
text.="|" . Lib[Trim(A_LoopField)]
return, text
}
}
; Usage For example:
; You can put the text library at the beginning of the script
CoordMode, Mouse, Screen
Text:="|<comment1>*138$24.10480U98zz9884Nz48O848u82Ec81U/z1U88CQ88k788U"
Text.="|<comment2>*138$24.10480U98zz9884Nz48O848u82Ec81U/z1U88CQ88k788U"
Text.="|<comment3>*138$24.10480U98zz9884Nz48O848u82Ec81U/z1U88CQ88k788U"
;-- Use Pic(Text,1) to add the text library to Pic()'s Lib
Pic(Text,1)
;.....................
;.....................
;.....................
;-- Find one picture at a time
if ok:=FindText(27,1061,150000,150000,0,0,Pic("comment1"))
{
X:=ok.1, Y:=ok.2, W:=ok.3, H:=ok.4, X+=W//2, Y+=H//2
;------------------------------
Click, X, Y
}
;-- Find more pictures at a time
if ok:=FindText(27,1061,150000,150000,0,0,Pic("comment1|comment2|comment3"))
{
Loop, % ok.MaxIndex()//5
{
i:=(A_Index-1)*5, X:=ok[i+1], Y:=ok[i+2]
W:=ok[i+3], H:=ok[i+4], Comment:=ok[i+5], X+=W//2, Y+=H//2
;------------------------------
if (Comment="comment1")
{
Click, X, Y
}
else if (Comment="comment2")
{
Click, X, Y
}
else if (Comment="comment3")
{
Click, X, Y
}
}
}