VB 怎样后台获取游戏窗口内某点颜色?有会的麻烦给我码源
在说下问题,是要让程序获取后台游戏窗口内某点的颜色,不是前台游戏窗口的颜色,那位好心的哥哥姐姐帮忙下...
在说下问题,是要让程序获取后台游戏窗口内某点的颜色,不是前台游戏窗口的颜色,那位好心的哥哥姐姐帮忙下
展开
3个回答
展开全部
加入一个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
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
更多追问追答
追问
你给的代码只能得到前台的嘛
追答
我还以为程序要在后台获取游戏的某一点,等下啊
展开全部
这里有一种方法后台获取指定点颜色,但这方法如果指定的窗口被其它窗口盖住就
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用图片img的属性中有个显示坐标的功能,会把所点击坐标发给后台,然后你在后台判断坐标范围,switch语句就行,让后对应获取颜色。
追问
麻烦你说具体点好吗
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询