- 注册时间
- 2011-3-10
- 最后登录
- 1970-1-1
该用户从未签到
|
游戏双开的解决主要是对窗口句柄的获取。现在的窗口句柄获取,一般采用窗口名称获取句柄。这样就会出现一个问题,只要有多个同名窗口,就无法对单一的窗口进行操作。
而采用鼠标获取窗口句柄,就能完美解决这个问题。以下为鼠标获取窗口句柄的代码。
Dim pt As POINTAPI
Dim hwd As Long '存放窗体句柄
Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
SetCapture Form1.hwnd '使鼠标在窗口外部移动时仍能得到鼠标事件
Form1.MousePointer = 2 '鼠标在窗口外部移动时的鼠标指针
End Sub
Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim str As String
str = Space$(256)
If Button <> 1 Then Exit Sub '判断鼠标左键是否处于按下状态
Call GetCursorPos(pt) '得到光标的当前位置
hwd = WindowFromPoint(pt.x, pt.y) '得到光标所在点的窗口句柄
End Sub
以上为源码文件,对于API的声明就很简单了,在这里就不写了,如果需要请回帖我会补发的。 |
|