Core Function PixelChecksum

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "<pre> PixelChecksum ( <left>, <top>, <right>, <bottom>, <step> ) </pre> === Description === Generates a checksum for a region of pixels. === Parameters === ==== left ==== le...")
 
m (1 revision)
 
(6 intermediate revisions by one user not shown)
Line 1: Line 1:
 
<pre>
 
<pre>
PixelChecksum ( <left>, <top>, <right>, <bottom>, <step> )
+
PixelChecksum ( <left>, <top>, <right>, <bottom>, <step>, <hwnd> )
 
</pre>
 
</pre>
  
Line 30: Line 30:
  
 
Default is 1.
 
Default is 1.
 +
 +
==== hwnd ====
 +
 +
Optional; Window handle to be used.
  
 
=== Return Value ===
 
=== Return Value ===
  
 
Success: Returns the checksum value of the region.
 
Success: Returns the checksum value of the region.
Failure: Returns -1 if anything goes wrong.  
+
 
 +
Failure: Returns -1 if anything goes wrong.
  
 
=== Remarks ===
 
=== Remarks ===
Line 50: Line 55:
 
<syntaxhighlight lang="sputnik">
 
<syntaxhighlight lang="sputnik">
 
$coord = PixelChecksum( 200, 200, 220, 220 );
 
$coord = PixelChecksum( 200, 200, 220, 220 );
 +
println("Checksum is $coord");
 +
</syntaxhighlight>
 +
 +
 +
<syntaxhighlight lang="sputnik">
 +
$hWnd = WinGetHandle("Calc", "");
 +
$coord = PixelChecksum( 0, 0, 30, 30, $hWnd );
 
println("Checksum is $coord");
 
println("Checksum is $coord");
 
</syntaxhighlight>
 
</syntaxhighlight>

Latest revision as of 12:38, 14 June 2015

PixelChecksum ( <left>, <top>, <right>, <bottom>, <step>, <hwnd> )

Contents

Description

Generates a checksum for a region of pixels.

Parameters

left

left coordinate of rectangle.

top

top coordinate of rectangle.

right

right coordinate of rectangle.

bottom

bottom coordinate of rectangle.

step

Optional; Instead of searching each pixel use a value larger than 1 to skip pixels (for speed). E.g. A value of 2 will only check every other pixel.

Default is 1.

hwnd

Optional; Window handle to be used.

Return Value

Success: Returns the checksum value of the region.

Failure: Returns -1 if anything goes wrong.

Remarks

Performing a checksum of a region is very time consuming, so use the smallest region you are able to reduce CPU load. On some machines a checksum of the whole screen could take many seconds!

A checksum only allows you to see if "something" has changed in a region - it does not tell you exactly what has changed.

When using a step value greater than 1 you must bear in mind that the checksumming becomes less reliable for small changes as not every pixel is checked.

See "PixelCoordMode" in Opt

Example

$coord = PixelChecksum( 200, 200, 220, 220 );
println("Checksum is $coord");


$hWnd = WinGetHandle("Calc", "");
$coord = PixelChecksum( 0, 0, 30, 30, $hWnd );
println("Checksum is $coord");


// Wait until something changes in the region 0,0 to 50,50
 
// Get initial checksum
$checksum = PixelChecksum(0,0, 50,50);
 
// Wait for the region to change, the region is checked every 100ms to reduce CPU load
While ($checksum == PixelChecksum(0,0, 50, 50))
  Sleep(100);
 
MsgBox("Something in the region has changed!");
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox