QQ游戏对对碰外挂教程

2016-02-21 00:14 7 1 收藏

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

【 tulaoshi.com - QQ专区 】

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

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

  观察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种消除方块的可能。一旦有匹配的情况出现,则马上执行鼠标点击动作.
'如果你要使你的外挂更强大,就必须采更优秀的算法.

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

'**********过程名: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

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://www.tulaoshi.com/n/20160221/1650280.html

延伸阅读
在几年前我看到别人玩网络游戏用上了外挂,做为程序员的我心里实在是不爽,想搞清楚这到底是怎么回事。就拿了一些来研究,小有心得,拿出来与大家共享,外挂无非就是分几种罢了(依制作难度): 1、动作式,所谓动作式,就是指用API发命令给窗口或API控制鼠标、键盘等,使游戏里的人物进行流动或者攻击,最早以前的石器外挂就是这种方...
标签: 电脑入门
QQ农场和QQ牧场的场主使用外挂越来越频繁了,于是腾讯就不定期的打击QQ农场(牧场)使用外挂的用户,除在原有的警告和降级基础上增强制土地收回、清空仓库、取消QQ农场体验资格等处罚措施,甚至限制登录QQ农场,甚至永久封闭农场。但是对于那些想成为财主的用户来讲,富贵当然是险中求的了,为了当上QQ农场的财主大爷,不惜所铤而走险。 如果被...
标签: 电脑入门
在玩这个游戏不久的从前,平常不管任何时候,只要作物一成熟,消息栏就会显示一些人熟悉的名字。并且是以最快的速度成功收获。 第一次,我还很高兴。感觉有人在关注我。作为我的朋友,来摘取和分享我的劳动果实,我以为理所当然的事情,而且的确很开心,还傻乎乎的邀请他下次一定准时定的来摘收,尽管是我收益的最低限。 第二次...
图一 界面描述 一、制作思路 得到QQ连连看窗口指针,从而得到CDC; 对每幅图片取4个点进行编码; 实现连连看的算法; 模拟鼠标消去块; 二、部分代码 //定义的数据 bool flagx=true; int point1x,point1y,point2x,point2y;//保存需要单击点的位置 struct MYCOLOR { COLORREF c[4]; }; MYCOLOR tc[230];//颜色表230...
标签: 电脑入门
很多网友由于贪图方便省事,使用了腾讯三令五申的不准使用的qq农场外挂,导致农场被降级,重者被封号等严重后果,但是你们有没有想过,腾讯是怎么来判断你是否使用了外挂呢?在这里图老师小编就帮您分析一下。 一、想必大家一定都知道,登陆QQ的其他第三方软件的时候,都需要到腾讯的系统中转注册,不通过这个中转它不可能给你传输...

经验教程

469

收藏

63
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部