Image/Pixel-Color Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Image/Pixel-Color Operations > ANA. - Imageworks > Pattern-Recognition >

Image/Pixel-Color Operations

ANA.FindPClick - Find a Pattern and Click

Previous Top Next


MiniRobotLanguage (MRL)

 

ANA.FindPClick

Get Locations of a specified Pattern-Object and Click one or multiple times

 

 

Intention

 

Welcome to the advanced FindPClick-Command.

It makes finding and clicking a Pattern a breeze.

Here's the magic it performs:

 

It captures the scene of the active window (Stored in IR 24)

Your chosen Pattern is loaded, keeping its original size (Secured in IR 23)

It seeks out the specified Pattern, once or multiple times

The locations of the Pattern are carefully noted on the TOS

Clicks are performed at the identified locations, once or multiple times

After the task is done, all the information you need is neatly arranged on the TOS

 

 

FindPCLick_TOS

 

The TOS will show: 0 - If NO Pattern were found, otherwise the number of found Patterns.

And below that the Coordinates of the found Patterns.

 

Imagine you're browsing a social network and want to click all the 'LIKE' buttons currently on display.
Just one call to this command, and it's done!

 

 

' Locate the Top-Window

STW.ct|Chrome_WidgetWin_1| - Brave

' Define the Location for the Pattern

$$FIA=?path\Like.bmp

' Call the Command

ANA.fpc|$$FIA|0|60|0|8|4,16|4|2

ENR.

 

 

Crucial Reminder: 

To fully understand how to use this command, please look into the ANA.FindPattern-Command.

  We've intentionally omitted details on 'Mouseover-Effects' and 'Admin-Rights' here, so do take the time to read about them there.

 

 

Syntax

 

ANA.FindPClick[|P1][|P2][|P3][|P4][|P5][|P6][|P7][|P8]

 

Parameter Explanation

 

P1 - Filepath and Filename of the Pattern-Image-File.

P2 - opt. Color Tolerance, if omitted 0 will be used.

P3 - opt. Pixel-Hit Tolerance, if omitted 33 will be used. This valuie depends on the Pattern that you feed into the Command.

        If your Pattern is 8x8 then the maximum number of Pixels that could match is 64. If its 24x8 the maximum Number is 192.
        So P4 is the minimum number of Matches to accept a result. Do not make P4 too low or else you may overrun the system with hundred-thousands of results.

P4 - opt. 0/1 - Debug-Flag

P5 - opt. Click-Type 1 - MLE. 2 - MLI. 4 - MLM.  8 - MLC.  16 - MRM.  32 - MDC.

           For P5 you can add the numbers to make multiple Clicks. For example 8+1=9 means you make an MLE. and an MLC. Click at each Location.

          Please take care that all Clicks here are multiplied with the number in P7

P6 - opt. Move Mouse relativ before Click, defaul is "0,0".

P7 - opt. Number of Clicks to do at each found place. (default is 1, maximum is 255)

P8 - opt. How many Findings should be clicked at (default is "0" means that all Findings will be clicked at)

         Assume, that you want only to click at the first element to be found, then you will just use a "1" here.  

 

The Command will leave a 0/1 on the TOS. As always, a 0 means Error, while a 1 means "all fine".

For example, if one of the IR's does not exist then you will get a result "0" on TOS.

The program will not generate an Error-Message.

 

Example

 

 

Click Pattern in Browser and Scroll

This will Click a specified Pattern in a Browser-Window and then Scroll forward.

 

'***********************************

' ANA.FindPClick-Sample

' This is a real-Life Example-Skript

' It can scroll through a Social-Network and click all

' Like-Buttons.

' You need to change the Top-Window STW. to your Browser

' and you need to record the "Like-Button" ($$PAC)

' or whatever you want to Click.

'***********************************

VAF.$$PAC=?path\Nma_16x8.bmp

ANA.Load|1|$$PAC

:Lb_Start

STW.ct|Chrome_WidgetWin_1|- Brave

HTV.$$HWN

ANA.Snap|0

IKS.{SHIFT}

  END.  

EIF.

ANA.rsl

$$FIA=?path\Like.bmp

ANA.fpc|$$FIA|0|60|0|8|41,16|1|2

:Do_ScrollB

GSB.ScrollX

GTO.Lb_Start

'-----------------------------------------------------------

:ScrollX

STW.ct|Chrome_WidgetWin_1|- Brave

' You may need to adjust these values, the ROBOT clicks at 

' that Point to get the Input Focus into this Window.

MPO.t|1120,998

' To use the Mouse-Wheel later

MLC.t|1120,998

MWR.-650

RET.

 

 

 

Remarks

Speed Guidelines:

 

1.The Command, being 'Multithreaded', loves to work with a Multicore CPUs.
It has a hearty appetite for CPU power and may even call upon the GPU's resources.

2.It prides itself on speed, even with large windows, given a modern CPU is in action.

3.Remember, larger Patterns mean a slower operation.

4.Current speed secrets?
Have the pattern touch the upper left corner. But stay flexible, this may not always be the case.

5.If a Pattern is being sluggish, recording a new Pattern and trying again might do the trick.

6.Patterns with nothing in them won't work. They need something to latch onto.

7.Steer clear of '.jpg' images or ones with artefact compression. Stick with '.bmp' or '.png' images for results you can count on.

 

Limitations:

Choosing wrong values for P2 and P3 may overrun the robot with too many "fitting results" and may keep the system busy for minutes.

We did not yet implement an "Maximum number of results" at this time.

 

The resolution of the Pattern-Images that can be used is limited to those resolutions that can be saved with the "Human Eye-Recorder"-Tool.

 

 

See also:

 

    ANA_FindPattern