我有以下代码:
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?
提前致谢