次のコードがあります。
procedure TForm1.Button1Click(Sender: TObject);
var
XYCoord: integer;
window: hwnd;
c: TCanvas;
result : TColor;
color : string;
begin
c := TCanvas.Create;
window := FindWindow('Atlantica Online', NIL);
try
c.Handle := GetWindowDC(window);
Result := GetPixel(c.Handle, 50, 10);
finally
c.Free;
end;
color := GetColorASRGBString(result, true);
if color = '#FF0000' then
begin
SendMessage(window, WM_LBUTTONDOWN, MK_LBUTTON, makelong(50, 10));
SendMessage(window, WM_LBUTTONUP, MK_LBUTTON, makelong(50, 10));
end;
end;
function TForm1.GetColorASRGBString(
const ColorToConvert : TColor;
const IncludePrefixChar: Boolean): String;
var
r,g,b : Byte;
CurrentColor : TColor;
HexColorWithSpaces : String;
const
HexFormatStr : String = '%2x';
begin
CurrentColor := ColorToConvert;
CurrentColor := ColorToRGB(CurrentColor);
r := GetRValue(CurrentColor);
g := GetGValue(CurrentColor);
b := GetBValue(CurrentColor);
HexColorWithSpaces := IfThen(IncludePrefixChar, '#','')
+ Format(HexFormatStr, [r])
+ Format(HexFormatStr, [g])
+ Format(HexFormatStr, [b]);
Result := AnsiReplaceStr(HexColorWithSpaces, ' ', '0');
end;
特定のウィンドウの特定のピクセルが赤 (255,0,0) の場合、そこをクリックする必要があります...
すべての通常のアプリケーションで非常にうまく機能します...
ただし、アプリケーションが DirectX を使用している場合は失敗します (黒 (#000000) を返します)...
directx をフックする必要なく、これに対する解決策はありますか?
前もって感謝します