QQ游戏对对碰外挂教程

玉树传说

玉树传说

2016-02-21 00:14

get新技能是需要付出行动的,即使看得再多也还是要动手试一试。今天图老师小编跟大家分享的是QQ游戏对对碰外挂教程,一起来学习了解下吧!

    这些日子,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

'自定义方块数据类型x,y位方块坐标,type为方块类型.
'在Easy对对碰1.5版中还加如了一些其他属性,例如是否带道具属性.
Public Type BOX
x As Integer
y As Integer
type As BOX_TYPE
End Type

'Api常量

'鼠标事件常量
Private Const MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4
Private Const MOUSEEVENTF_MOVE = &H1
Private Const MOUSEEVENTF_ABSOLUTE = &H8000

Public Const HWND_TOPMOST = -1
Public Const SWP_NOSIZE = &H1
Public Const SWP_NOMOVE = &H2
'自定义常量
'游戏区左上角坐标
Const GAME_LEFT As Integer = 176
Const GAME_TOP As Integer = 102
'每个方块的长宽
Const BOX_WIDTH As Integer = 48
Const BOX_HEIGHT As Integer = 48

'游戏窗口句柄
Public g_WindowHwnd As Long
'方块矩阵 (8*8)
Public boxs(7, 7) As BOX
**********过程名:DelayTime******************
'作者:Cyril
'书写日期:2004.10.23
'编辑日期:2002.10.23
'目的:获取当前场景 , 建立方块矩阵
'方法:killBox
'应用于:MainMod模块
'********************************************
Public Function getBoxs()
Dim i As Integer '矩阵行
Dim j As Integer '矩阵列
Dim color1 As Long '颜色 (22,22)处
Dim color2 As Long '颜色 (22,17)处

For i = 0 To 7
For j = 0 To 7
With boxs(i, j)
.x = GAME_LEFT + 22 + BOX_WIDTH * j
.y = GAME_TOP + 22 + BOX_HEIGHT * i
'取每个方块坐标(22,22)和(22,17)位置的颜色
color1 = getColor(.x, .y)
color2 = getColor(.x, .y - 5)
'用两点颜色确定一个方块类型.
If color1 = 16777215 And color2 = 16777215 Then .type = Panda
If color1 = 2097151 And color2 = 1353909 Then .type = Chicken
If color1 = 4473924 And color2 = 14209230 Then .type = Dog
If color1 = 13828048 And color2 = 3862322 Then .type = Frog
If color1 = 8623264 And color2 = 5805536 Then .type = Monkey
If color1 = 10921638 And color2 = 9408399 Then .type = Cat
If color1 = 15398649 And color2 = 1655140 Then .type = Ox
End With
Next j
Next i
End Function

为了方便理解,这里用了一种比较简单的算法 -- 穷举法.(这也是Easy对对碰最初版本的算法).
'其主要思想是列举16种消除方块的可能。一旦有匹配的情况出现,则马上执行鼠标点击动作.
'如果你要使你的外挂更强大,就必须采更优秀的算法.

'**********过程名:DelayTime******************
'作者:Cyril
'书写日期:2004.10.23
'编辑日期:2002.10.23
'目的:消去一个方块
'方法:killBox
'说明:无
'返回值:无
'应用于:MainMod模块
'********************************************
Public Function killBox()
Dim i As Integer
Dim j As Integer
getBoxs

' :
'   情况

For i = 0 To 4
For j = 0 To 7
If boxs(i, j).type = boxs(i + 2, j).type And boxs(i, j).type = boxs(i + 3, j).type Then
mouseClick boxs(i, j).x, boxs(i, j).y
mouseClick boxs(i + 1, j).x, boxs(i + 1, j).y
Exit Function
End If
Next j
Next i

'_
'   情况

For i = 0 To 5
For j = 0 To 6
If boxs(i, j).type = boxs(i + 2, j + 1).type And boxs(i, j).type = boxs(i + 1, j + 1).type Then
mouseClick boxs(i, j).x, boxs(i, j).y
mouseClick boxs(i, j + 1).x, boxs(i, j + 1).y
Exit Function
End If
Next j
Next i

' _
'  情况

For i = 0 To 5
For j = 1 To 7
If boxs(i, j).type = boxs(i + 2, j - 1).type And boxs(i, j).type = boxs(i + 1, j - 1).type Then
mouseClick boxs(i, j).x, boxs(i, j).y
mouseClick boxs(i, j - 1).x, boxs(i, j - 1).y
Exit Function
End If
Next j
Next i

' 
': 情况
For i = 3 To 7
For j = 0 To 7
If boxs(i, j).type = boxs(i - 2, j).type And boxs(i, j).type = boxs(i - 3, j).type Then
mouseClick boxs(i, j).x, boxs(i, j).y
mouseClick boxs(i - 1, j).x, boxs(i - 1, j).y
Exit Function
End If
Next j
Next i

'_   情况
For i = 2 To 7
For j = 0 To 6
If boxs(i, j).type = boxs(i - 1, j + 1).type And boxs(i, j).type = boxs(i - 2, j + 1).type Then
mouseClick boxs(i, j).x, boxs(i, j).y
mouseClick boxs(i, j + 1).x, boxs(i, j + 1).y
Exit Function
End If
Next j
Next i

'  _ 情况
For i = 2 To 7
For j = 1 To 7
If boxs(i, j).type = boxs(i - 1, j - 1).type And boxs(i, j).type = boxs(i - 2, j - 1).type Then
mouseClick boxs(i, j).x, boxs(i, j).y
mouseClick boxs(i, j - 1).x, boxs(i, j - 1).y
Exit Function
End If
Next j
Next i

'_-- 情况
For i = 1 To 7
For j = 0 To 5

If boxs(i, j).type = boxs(i - 1, j + 2).type And boxs(i, j).type = boxs(i - 1, j + 1).type Then
mouseClick boxs(i, j).x, boxs(i, j).y
mouseClick boxs(i - 1, j).x, boxs(i - 1, j).y
Exit Function
End If
Next j
Next i

'-_ _ 情况
For i = 0 To 6
For j = 0 To 5

If boxs(i, j).type = boxs(i + 1, j + 2).type And boxs(i, j).type = boxs(i + 1, j + 1).type Then
mouseClick boxs(i, j).x, boxs(i, j).y
mouseClick boxs(i + 1, j).x, boxs(i + 1, j).y
Exit Function
End If
Next j
Next i

' -_- 情况
For i = 1 To 7
For j = 1 To 6

(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/diannaorumen/)

If boxs(i, j).type = boxs(i - 1, j - 1).type And boxs(i, j).type = boxs(i - 1, j + 1).type Then
mouseClick boxs(i, j).x, boxs(i, j).y
mouseClick boxs(i - 1, j).x, boxs(i - 1, j).y
Exit Function
End If
Next j
Next i
' _-_ 情况
For i = 0 To 6
For j = 1 To 6

If boxs(i, j).type = boxs(i + 1, j - 1).type And boxs(i, j).type = boxs(i + 1, j + 1).type Then
mouseClick boxs(i, j).x, boxs(i, j).y
mouseClick boxs(i + 1, j).x, boxs(i + 1, j).y
Exit Function
End If
Next j
Next i

'  情况

For i = 1 To 6
For j = 1 To 7

If boxs(i, j).type = boxs(i + 1, j - 1).type And boxs(i, j).type = boxs(i - 1, j - 1).type Then
mouseClick boxs(i, j).x, boxs(i, j).y
mouseClick boxs(i, j - 1).x, boxs(i, j - 1).y
Exit Function
End If
Next j

Next i
'  情况
For i = 1 To 6
For j = 0 To 6

If boxs(i, j).type = boxs(i + 1, j + 1).type And boxs(i, j).type = boxs(i - 1, j + 1).type Then
mouseClick boxs(i, j).x, boxs(i, j).y
mouseClick boxs(i, j + 1).x, boxs(i, j + 1).y
Exit Function
End If
Next j
Next i
'--_ 情况

For i = 1 To 7
For j = 2 To 7

If boxs(i, j).type = boxs(i - 1, j - 2).type And boxs(i, j).type = boxs(i - 1, j - 1).type Then
mouseClick boxs(i, j).x, boxs(i, j).y
mouseClick boxs(i - 1, j).x, boxs(i - 1, j).y
Exit Function
End If
Next j
Next i
'-- - 情况
For i = 0 To 7
For j = 3 To 7

If boxs(i, j).type = boxs(i, j - 2).type And boxs(i, j).type = boxs(i, j - 3).type Then
mouseClick boxs(i, j).x, boxs(i, j).y
mouseClick boxs(i, j - 1).x, boxs(i, j - 1).y
Exit Function
End If
Next j
Next i
'_ _- 情况
For i = 0 To 6
For j = 2 To 7

If boxs(i, j).type = boxs(i + 1, j - 2).type And boxs(i, j).type = boxs(i + 1, j - 1).type Then
mouseClick boxs(i, j).x, boxs(i, j).y
mouseClick boxs(i + 1, j).x, boxs(i + 1, j).y
Exit Function
End If
Next j
Next i

'- -- 情况
For i = 0 To 7
For j = 0 To 4

If boxs(i, j).type = boxs(i, j + 2).type And boxs(i, j).type = boxs(i, j + 3).type Then
mouseClick boxs(i, j).x, boxs(i, j).y
mouseClick boxs(i, j + 1).x, boxs(i, j + 1).y
Exit Function
End If
Next j
Next i

End Function

这里的鼠标模拟用了鼠标事件.你也可以用sendmessage来实现.

'**********过程名:DelayTime******************
'作者:Cyril
'书写日期:2004.10.23
'编辑日期:2002.10.23
'目的:模拟鼠标单击
'方法:mouseClick(ByVal x As Long, ByVal y As Long)
'说明:x -- 方块相对游戏窗口的X; y -- 方块相对游戏窗口的Y;
'返回值:无
'应用于:MainMod模块
'********************************************
Public Sub mouseClick(ByVal x As Long, ByVal y As Long)
Dim po As POINTAPI 'po点击前鼠标位置
Dim kX As Long '方块的绝对X坐标
Dim kY As Long '方块的绝对Y坐标
Dim winRECT As RECT '游戏窗口的RECT

'获得游戏窗口的RECT
GetWindowRect g_WindowHwnd, winRECT
'绝对坐标 = 游戏窗口左上角坐标 + 游戏中的相对坐标
kX = winRECT.Left + x
kY = winRECT.Top + y
'获得鼠标点击前位置
GetCursorPos po
'模拟鼠标移动
mouse_event MOUSEEVENTF_MOVE Or MOUSEEVENTF_ABSOLUTE, kX * 65535 / 1024, kY * 65535 / 768, 0&, 0&
'模拟鼠标按下弹起
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP Or MOUSEEVENTF_ABSOLUTE, 0, 0, 0&, 0&
'点击后返回原先位置
SetCursorPos po.x, po.y
End Sub

(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/diannaorumen/)
展开更多 50%)
分享

猜你喜欢

QQ游戏对对碰外挂教程

电脑入门
QQ游戏对对碰外挂教程

血型宝宝与血型妈妈对对碰

A型血 育儿知识 怀孕 孕妇
血型宝宝与血型妈妈对对碰

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

淘宝星座红包对对碰怎么玩?

手机软件 应用软件
淘宝星座红包对对碰怎么玩?

坐月子VS现代医学对对碰(上)

维生素 育儿知识 怀孕 孕妇
坐月子VS现代医学对对碰(上)

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

问答对对碰帮你解释网络灵异事件

电脑网络
问答对对碰帮你解释网络灵异事件

网络设置不求人 应用技巧问答对对碰

windows 操作系统
网络设置不求人 应用技巧问答对对碰

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

QQ邮箱新功能 阅读QQ好友空间

QQ邮箱新功能 阅读QQ好友空间

QQ上次登录信息可疑的处理办法

QQ上次登录信息可疑的处理办法
下拉加载更多内容 ↓