This is a class that makes using GDI to accelerate pixel detection nice and easy.
It works by introducing the concept of a "Snapshot". A Snapshot is a copy of the portion of the screen stored in memory that you can query using a command that works like AHK's
One advantage of this technique is that you are taking a copy of a portion of the screen at a single point in time, so you do not have to worry about the screen changing part way through making multiple pixel checks.
ie, it makes it easy to perform multiple checks on one "frame" of the stream of images.
Also, when you check a pixel color from the snapshot, the result is cached, meaning faster results if you check that pixel's color in the future - so no need to worry about storing local copies of pixel colors to speed up processing.
What are the features / How do I use it?
Using the class is a Snap (ahem).
Define the Snapshot area as a 200x200 block of the screen at coordinates 300,300:
snap := new CGdipSnapshot(300,300,200,200) ; x, y, width, height
Some time later.... We can still inspect this snapshot, even if the screen has changed.
Pixel values can be read as Hex or r/g/b values.
You can use coordinates relative to the Screen or the Snapshot.
r_value := snap.SnapshotGetColor(0,0).r
Handy cached pixel arrays! Re-query pixels without subsequent DLL calls!
myval := snap.PixelScreen[300,300].rgb
myval := snap.PixelScreen[300,300].rgb ; no DLL call!
myval := snap.PixelSnap[0,0].rgb ; Same value, still no DLL call!
Pixels array elements are objects! Chain commands!
bool := snap.PixelScreen[300,300].Compare(snap.PixelScreen[0,0]) ; this will always be true, and only ever require one DLL call!
Use multiple snapshots at one time! Easily compare!
snap1 := new CGdipSnapshot(300,300,200,200)
snap2 := new CGdipSnapshot(300,300,200,200)
msgbox % "Pixel 0,0 did not change for 5 seconds"
msgbox % "Snapshot 1 and 2 are similar"
Just create a Text box with attribute
0xEand store the HWND, then call the function:
Gui, Add, Text, 0xE x5 y5 w%w% h%h% hwndSnapshotPreview
Where can I get it?
Requires the gdip_all library from here
GitHub Page (Download from here)
Wiki - Full Documentation
Full example script