← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #677011]: VNCScreen.wait() does not catch image change

 

Question #677011 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/677011

    Status: Needs information => Open

Pavel gave more information on the question:
I tried a couple options, both have the same result.
option 1:
public Match waitForImage(VNCScreen vnc_old, String image, Region reg, double waitTimeout, float score) {
		System.out.println("Waiting for image: " + image + " in a specific region: " + reg.getX() + ", " + reg.getY() + " " + reg.getW() + "x" + reg.getH());
		
		vnc_old.setRect(reg.x, reg.y, reg.w, reg.h);
		
		Pattern pat = new Pattern(image);
		pat.similar(score);
		Match found = null;
		
		try {
			found = vnc_old.wait(image, waitTimeout);
			System.out.println("Match: " + found.getScore());
			System.out.println("Found image region: " + found.x + "," + found.y + " " + found.w + "x" + found.h);
		} catch (FindFailed e) {
			e.printStackTrace();
			screenShot(vnc_old, reg);
			throw new RuntimeException("Failed to find a match for image and click it. " + image);
		}
		
		vnc_old.hover();	// printing found region coordinates
		return found;
	}

option 2:
public Match waitForImage(String image, Region reg, double waitTimeout, float score) {
		int port = Integer.parseInt(5950);
		VNCScreen vnc = connectVNC(HOST, port, PASSWORD, 10, 5000);
		
		System.out.println("Waiting for image: " + image + " in a specific region: " + reg.getX() + ", " + reg.getY() + " " + reg.getW() + "x" + reg.getH());
		
		vnc.setRect(reg.x, reg.y, reg.w, reg.h);
		
		Pattern pat = new Pattern(image);
		pat.similar(score);
		Match found = null;
		
		try {
			found = vnc.wait(image, waitTimeout);
			System.out.println("Match: " + found.getScore());
			System.out.println("Found image region: " + found.x + "," + found.y + " " + found.w + "x" + found.h);
		} catch (FindFailed e) {
			e.printStackTrace();
			screenShot(vnc, reg);
			throw new RuntimeException("Failed to find a match for image and click it. " + image);
		}
		
		vnc.hover();	// printing found region coordinates
		return found;
	}

Commenting vnc.setRect(reg.x, reg.y, reg.w, reg.h); also does not bring
any changes to final result.

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.