如何获取指定游戏的一个点的像素(50)

S

sury8

Unregistered / Unconfirmed
GUEST, unregistred user!
如题,比如qq游戏的一个点的像素,我不要用getdc(0) 这个是相对于整个桌面的,我要取游戏的窗口,这样就可以不依赖分辨率了。getwindowsdc也失败了,有过这方面经验的朋友指点下,获取句柄的代码就省了,直接假设句柄已经取到了
 
procedure TForm1.Timer1Timer(Sender: TObject);varPos: TPoint;Handle: HWND;ScreenDC: HDC;Buf: array[0..1024] of Char;ScreenColor: COLORREF;beginGetCursorPos(Pos); // 得到当前光标位置Handle := WindowFromPoint(Pos); // 返回当前位置的句柄HandleText.text := IntToStr(Handle);GetClassName(Handle, Buf, 1024); // 得到类名ClassNameText.Caption := Buf;SendMessage(Handle, WM_GETTEXT, 33, Integer(@Buf)); // 得到标题TitleText.Caption := Buf;{ 得到光标处点的颜色 }ScreenDC := GetDC(0);ScreenColor := GetPixel(ScreenDC, Pos.X, Pos.Y);Shape.Brush.Color := TColor(ScreenColor);RGBColorText.Caption := '红: ' + IntToStr(GetRValue(ScreenColor)) +' 绿: ' + IntToStr(GetGValue(ScreenColor)) + ' 蓝: ' +IntToStr(GetBValue(ScreenColor));ReleaseDC(0, ScreenDC);DelphiColorText.Caption := Format('Delphi中颜色值:$00%2.2x%2.2x%2.2x', [GetBValue(ScreenColor),GetGValue(ScreenColor), GetRValue(ScreenColor)]);HTMLColorText.Caption := Format('HTML颜色值:#%2.2x%2.2x%2.2x', [GetRValue(ScreenColor),GetGValue(ScreenColor), GetBValue(ScreenColor)]);end;
 
接受答案了.
 
白痴一个 鉴定完毕
 

Similar threads

S
回复
0
查看
959
SUNSTONE的Delphi笔记
S
S
回复
0
查看
779
SUNSTONE的Delphi笔记
S
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
顶部 底部