电脑技术学习

制作QQ游戏对对碰外挂教程详解

dn001

  这些日子,QQ游戏外挂是风光了一阵.俄罗斯方块,连连看,对对碰这些游戏的外挂层出不穷。其实这一类外挂的原理大体都是一样的。下面我就以QQ游戏对对碰外挂作为例子阐述一下QQ外挂的制作原理。

  观察QQ游戏对对碰的游戏界面及游戏规则,发现玩家是在固定的一个游戏区内寻找复合要求的方块然后点击两次鼠标消去方块从而达到得分的目的。因此,我们可以通过模拟人的观察,和鼠标点击来实现外挂自动消除方块,完成全局。

  取得可消方块(模拟人观察):要判断哪个方块可以消,我们可以通过获取方块某点的颜色来判断方块的类型,然后建立方块矩阵,然后在矩阵中选择出适合消去的方块。关于取颜色,我们用到几个API函数 GetPixel、GetDC、ReleaseDC。(详细的介绍请参考MSDN或各种API相关资料)

  模拟鼠标击:在此我们使用 mouse_event 来模拟鼠标的移动,点击,弹起。个人认为用postmessage是更好的,在此使用mouse_event只是为了阐述简单。

下面是VB实现代码(带详细注释):
'模块中
'*************模块:modMain******************
'作者:Cyril
'Email:terry6394@126.com
'Web: http://www.sguca.com/other
'书写日期:2004.10.23
'编辑日期:2002.10.23
'转载请保留此信息
'版权所有(a)Cyril 405 工作室 
'********************************************
Option Explicit

'API声明
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y 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 GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
'API类型定义
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

'方块类型定义
Public Enum BOX_TYPE
Ox = 0
Dog = 1
Panda = 2
Chicken = 3
Cat = 4
Frog = 5
Monkey = 6
End Enum

;