Sikuli has a great feature that allows you to manipulate an image once inserted in the code. As you know, Sikuli works by clicking on your screen from the images you provide to it in the code.
The feature is the ‘Target Offset’. The target offset feature allows you to click to an offset of where the image is located on your screen. Target offset is very handy when you need to click somewhere on the screen that does not always have a fixed image. For example, let us say you want to click on a video. The video does not have a constant image. This means every time you run the process, there will be a different image. Sikuli would not recognize the image you provided if it cannot find it on your computer screen. The solution is taking a screenshot of something on your screen that is fixed or does not change. Target offset then allows you to have a location clicked that is to the right, left, up, or down from the fixed image.
Here is an example. I am on the Digital Finance Learning twitter page. Check our twitter page out. We post daily tweets on the latest Digital Finance news and how to’s for automation and visual tools.
The goal is to always click the link that is showing at the bottom. What if that link changes every month? Target offset would be very handy for this. We need to find a fixed image that never changes. “Digital Finance Learning” is a good fixed image to use. I am 99% sure we are not going to change our name.
Now if we click the image we inserted into the Sikuli Gui, a window should pop up like this. Select the Target Offset tab.
The target offset tab should give you a live preview of the image being recognized on your screen. There should be a crosshair in the middle which controls exactly where the mouse is going to click. Now, we just need to click on the link, which will move the crosshair down. This tells Sikuli that whenever you recognize the image, click on the offset (X,Y) location from (0,0) which is set at the center of the image you provided.
After changing the crosshair location, just hit Apply and OK. Sikuli will save the settings and whenever it runs that line of code, it will read the target offset that is set within that image.
In relation to Digital Finance, this can be utilized for ERP’s, online or application, company portals, excel sheets, and other areas. This one of the most useful features with Sikuli. It allows flexibility in screen automation when a location on your screen cannot be easily clicked on.