PixelGetColor

Retrieves the color of the pixel at the specified X and Y coordinates.

Color := PixelGetColor(X, Y , Mode)

パラメータ

X, Y

型:整数

画素の X 座標と Y 座標を指定します。Coordinates are relative to the active window's client area unless CoordMode was used to change that.

Mode

型:文字列

If blank or omitted, the pixel is retrieved using the normal method. Otherwise, specify one or more of the following words. 複数の単語がある場合は、それぞれをスペースで区切ってください(例:"Alt Slow")。

Alt: Uses an alternate method to retrieve the color, which should be used when the normal method produces invalid or inaccurate colors for a particular type of window. This method is about 10 % slower than the normal method.

Slow: Uses a more elaborate method to retrieve the color, which may work in certain full-screen applications when the other methods fail. この方法は、通常の方法と比較して約3倍の速度がかかります。注:SlowAltより優先されるので、この場合はAltを指定する必要はありません。

戻り値

型:文字列

画素のRGB(赤緑青)色を16進数で表す文字列を返す関数です。例えば、紫は青と赤の強度が0x80(128)、緑の強度が0x00(0)であるため、0x800080と定義されています。

エラー処理

失敗したときはOSErrorをスローします。

備考

つまり、他のウィンドウの後ろに隠れたウィンドウのピクセルカラーを取得することはできません。一方、マウスカーソルの下にある画素は、通常、検出することができます。The exception to this is game cursors, which in most cases will obstruct any pixels beneath them.

Use Window Spy (available in tray icon menu) or the example at the bottom of this page to determine the colors currently on the screen.

既知の制限事項:

PixelSearch, ImageSearch, CoordMode, MouseGetPos

ホットキーを押すと、マウスカーソルの現在位置にある画素の色が表示されます。

^!z::  ; Control+Alt+Z hotkey.
{
    MouseGetPos &MouseX, &MouseY
    MsgBox "The color at the current cursor position is " PixelGetColor(MouseX, MouseY)
}