VB 怎样后台获取游戏窗口内某点颜色?有会的麻烦给我码源

在说下问题,是要让程序获取后台游戏窗口内某点的颜色,不是前台游戏窗口的颜色,那位好心的哥哥姐姐帮忙下... 在说下问题,是要让程序获取后台游戏窗口内某点的颜色,不是前台游戏窗口的颜色,那位好心的哥哥姐姐帮忙下 展开
 我来答
WWEERR
2011-06-16 · TA获得超过841个赞
知道小有建树答主
回答量:536
采纳率:0%
帮助的人:530万
展开全部
加入一个Timer,interval设置为100或者50

Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long

Private Sub Timer1_Timer()
Static lX As Long, lY As Long
On Local Error Resume Next
Dim P As POINTAPI, h As Long, hD As Long, r As Long
GetCursorPos P
If P.x = lX And P.y = lY Then Exit Sub
lX = P.x: lY = P.y
'Label2(0).Caption = lX & "," & lY
h = WindowFromPoint(lX, lY)
'Label2(1).Caption = h
hD = GetDC(h)
'Label2(2).Caption = hD
ScreenToClient h, P
'Label2(3).Caption = P.x & "," & P.y
r = GetPixel(hD, P.x, P.y)
If r = -1 Then
BitBlt Picture1.hdc, 0, 0, 1, 1, hD, P.x, P.y, vbSrcCopy
r = Picture1.Point(0, 0)
Else
Picture1.PSet (0, 0), r
End If
'Label2(4).Caption = Hex$(r)
Picture1.BackColor = r
End Sub
更多追问追答
追问
你给的代码只能得到前台的嘛
追答
我还以为程序要在后台获取游戏的某一点,等下啊
rengzang11
2011-06-16 · TA获得超过164个赞
知道答主
回答量:309
采纳率:0%
帮助的人:0
展开全部
这里有一种方法后台获取指定点颜色,但这方法如果指定的窗口被其它窗口盖住就
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
百度网友c084b03
2011-06-16 · 超过13用户采纳过TA的回答
知道答主
回答量:54
采纳率:0%
帮助的人:42.1万
展开全部
用图片img的属性中有个显示坐标的功能,会把所点击坐标发给后台,然后你在后台判断坐标范围,switch语句就行,让后对应获取颜色。
追问
麻烦你说具体点好吗
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式