Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Keeping Macro Going during image find
#1
Hello! Great program so far, really easy to use!
My macros work, however it stops when it should be counting, not sure how to keep it going. also there is probably a better way to do this.

var w = wnd.find(0, "window name", "applicationname").Activate();
string primaryImage = @"image:"; //confirmation field y
string secondaryImage =  @"image:"; //popup button

int primaryImageCount = 0;

while (primaryImageCount < 6) {
    var primaryIm = uiimage.find(-1, w, primaryImage);

    if (primaryIm != null) {
        primaryImageCount++;
        keys.send("y"); // Primary image found, send "y".
    } else {
        // Primary image not found, let's look for the secondary image.
        var secondaryIm = uiimage.find(0, w, secondaryImage);

        if (secondaryIm != null) {
            // Secondary image found, you can close the popup or perform any other action.
            {secondaryIm.MouseClick();}
        }
    }
}

If I run the macro when the image is present it does the y button press, but will not automatically find it again when it pops up later.

What I am doing is a task that runs for about 1-2 minutes, once the task is completed, there is a button for the next step and you need to press y.
Sometimes there are popups during the task running, I just want to click that away so the task can continue and then look for the original image.
Each task has 6 steps to press y on, once those are completed it needs to wait for the file to save about 10 seconds and then start over again.

Thanks for any help you can provide!
#2
Try this.
 
Code:
Copy      Help
// script ""
var w = wnd.find(0, "window name", "applicationname").Activate();

IFImage[] image = {
    @"image:", //confirmation field y
    @"image:", //popup button
};
int primaryImageCount = 0;

while (primaryImageCount < 6) {
    var im = uiimage.wait(0, w, image);
    if (im.ListIndex == 0) {
        primaryImageCount++;
        keys.send("y"); // Primary image found, send "y".
    } else {
        // Secondary image found, you can close the popup or perform any other action.
        im.MouseClick();
    }

    
    //wait until the image disappears, else the scrit may find the same image instance again
    print.it("waitNot start"); //debug
    uiimage.waitNot(0, w, image[im.ListIndex]);
    print.it("waitNot end"); //debug
}
#3
for (int i = 0; i < 6; i++) {  
    wnd.find(1, "window", "application").Activate();
    string image = @"image:";
    var im = uiimage.find(-300, new(w1, (1322, 1103, 117, 112)), image, IFFlags.WindowDC, diff: 10);
    if (im != null) { keys.send("y"); print.it("agree"); } else { print.it("disagree"); }
    5.s();

Thank you so much for the reply.
I fixed it earlier with the above code, and figured it was a good time to fix the popups from happening so I wouldn't have to program something to close them.


Forum Jump:


Users browsing this thread: 1 Guest(s)