C# QQ连连看外挂(内存版)源代码
发一个C#QQ连连看外挂(内存版)源代码
现在游戏的基址已经改变了大家只要重新查找一下基址就直接可以用了
里面用了最经典的寻路算法(比递归算法快100倍+)
Main.cs
现在游戏的基址已经改变了大家只要重新查找一下基址就直接可以用了
里面用了最经典的寻路算法(比递归算法快100倍+)
Main.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace llk_wg {
class Main {
//游戏窗口标题
const string GAME_CAPTION = "QQ游戏 - 连连看角色版";
//棋盘基址
static IntPtr GAME_BASE = (IntPtr)0x0012A47C;
//声明一个棋盘数组
static byte[,] boxs = new byte[11, 19];
//游戏窗口句柄
static IntPtr hwnd;
//初始化棋盘数组
static void InitBox() {
//获取游戏句柄
hwnd = Win32.FindWindow(null, GAME_CAPTION);
//获取棋盘数组的内存基址
IntPtr lpBufferbase = Marshal.UnsafeAddrOfPinnedArrayElement(boxs, 0);
//获取pid
int ProcessId;
Win32.GetWindowThreadProcessId(hwnd, out ProcessId);
//打开游戏线程
IntPtr hObject = Win32.OpenProcess(Win32.STANDARD_RIGHTS_REQUIRED | Win32.SYNCHRONIZE | 4095, false, ProcessId);
//读取棋盘数据
Win32.ReadProcessMemory(hObject, GAME_BASE, lpBufferbase, boxs.Length, IntPtr.Zero);
//关闭线程
Win32.CloseHandle(hObject);
}
//发送鼠标消息(顺便把图片的高度宽度也算进去)
static void SendMouseclick(int x, int y) {
//获取游戏句柄
hwnd = Win32.FindWindow(null, GAME_CAPTION);
//lparam的高位就是y坐标低位就是x坐标y左移16就到高位去了
int lparam = (y << 16) + x;
Win32.PostMessage(hwnd, Win32.WM_LBUTTONDOWN, 0, lparam);
Win32.PostMessage(hwnd, Win32.WM_LBUTTONUP, 0, lparam);
}
//消除1对图片(模拟2次鼠标单击)
static void ClickTwo(int x1, int y1, int x2, int y2) {
SendMouseclick(22 + x1 * 31, 194 + y1 * 35);
SendMouseclick(22 + x2 * 31, 194 + y2 * 35);
}
//游戏开局
public static void Start(int type) {
int x = type == 1 ? 660 : 760;
SendMouseclick(x, 570);
}
//找相同的图片(本工具的核心)
static bool Select(int x1, int y1, int x2, int y2) {
if (x1 == x2 && y1 + 1 == y2) return true;
if (y1 == y2 && x1 + 1 == x2) return true;
List<int> list1 = new List<int>();
List<int> list2 = new List<int>();
List<int> list3 = new List<int>();
bool flag;
list1.Add(x1);
for (int i = x1 - 1; i >= 0; i--) if (boxs[i, y1] == 0) list1.Add(i); else break;
for (int i = x1 + 1; i < 11; i++) if (boxs[i, y1] == 0) list1.Add(i); else break;
list2.Add(x2);
for (int i = x2 - 1; i >= 0; i--) if (boxs[i, y2] == 0) list2.Add(i); else break;
for (int i = x2 + 1; i < 11; i++) if (boxs[i, y2] == 0) list2.Add(i); else break;
list3 = list1.Intersect(list2).ToList();
for (int i = 0; i < list3.Count(); i++) {
flag = true;
for (int j = Math.Min(y1, y2) + 1; j < Math.Max(y1, y2); j++) { if (boxs[list3[i], j] != 0) { flag = false; break; } }
if (flag) return true;
}
list1.Clear(); list2.Clear(); list3.Clear();
list1.Add(y1);
for (int i = y1 - 1; i >= 0; i--) if (boxs[x1, i] == 0) list1.Add(i); else break;
for (int i = y1 + 1; i < 19; i++) if (boxs[x1, i] == 0) list1.Add(i); else break;
list2.Add(y2);
for (int i = y2 - 1; i >= 0; i--) if (boxs[x2, i] == 0) list2.Add(i); else break;
for (int i = y2 + 1; i < 19; i++) if (boxs[x2, i] == 0) list2.Add(i); else break;
list3 = list1.Intersect(list2).ToList();
for (int i = 0; i < list3.Count(); i++) {
flag = true;
for (int j = Math.Min(x1, x2) + 1; j < Math.Max(x1, x2); j++) { if (boxs[j, list3[i]] != 0) { flag = false; break; } }
if (flag) return true;
}
return false;
}
//消除一对
public static void RemoveSingle() {
InitBox();
for (int x1 = 0; x1 < 11; x1++) {
for (int y1 = 0; y1 < 19; y1++) {
for (int x2 = 0; x2 < 11; x2++) {
for (int y2 = 0; y2 < 19; y2++) {
if (boxs[x1, y1] != 0 && boxs[x1, y1] == boxs[x2, y2] && !(x1 == x2 && y1 == y2)) {
if (Select(x1, y1, x2, y2)) {
ClickTwo(y1, x1, y2, x2);
return;
}
}
}
}
}
}
}
//消除所有
public static void RemoveAll() {
InitBox();
Target:
for (int x1 = 0; x1 < 11; x1++) {
for (int y1 = 0; y1 < 19; y1++) {
for (int x2 = 0; x2 < 11; x2++) {
for (int y2 = 0; y2 < 19; y2++) {
if (boxs[x1, y1] != 0 && boxs[x1, y1] == boxs[x2, y2] && !(x1 == x2 && y1 == y2)) {
if (Select(x1, y1, x2, y2)) {
ClickTwo(y1, x1, y2, x2);
boxs[x1, y1] = 0;
boxs[x2, y2] = 0;
goto Target;
}
}
}
}
}
}
}
//获取其他玩家最小box数量值
public static byte GetOtherUserMinNum() {
byte value = 0;
byte[] buffer = new byte[20];
int lpBase = 0x0012E04C;// 0x00115CDC;//0012E04C
//获取游戏句柄
hwnd = Win32.FindWindow(null, GAME_CAPTION);
//获取棋盘数组的内存基址
IntPtr lpBufferbase = Marshal.UnsafeAddrOfPinnedArrayElement(buffer, 0);
//获取pid
int ProcessId;
Win32.GetWindowThreadProcessId(hwnd, out ProcessId);
//打开游戏线程
IntPtr hObject = Win32.OpenProcess(Win32.STANDARD_RIGHTS_REQUIRED | Win32.SYNCHRONIZE | 4095, false, ProcessId);
//读取棋盘数据
Win32.ReadProcessMemory(hObject, (IntPtr)lpBase, lpBufferbase, buffer.Length, IntPtr.Zero);
//关闭线程
Win32.CloseHandle(hObject);
try { value = buffer.Where(o => o != 0).Min(); } catch { }
return value;
}
//获取自己的图片数量
public static byte GetShengyuNum() {
byte[] buffer = new byte[4];
//0012E048,00115CD8
int lpBase = 0x0012E048;// 0x00115CDC;//0012E04C
//获取游戏句柄
hwnd = Win32.FindWindow(null, GAME_CAPTION);
//获取棋盘数组的内存基址
IntPtr lpBufferbase = Marshal.UnsafeAddrOfPinnedArrayElement(buffer, 0);
//获取pid
int ProcessId;
Win32.GetWindowThreadProcessId(hwnd, out ProcessId);
//打开游戏线程
IntPtr hObject = Win32.OpenProcess(Win32.STANDARD_RIGHTS_REQUIRED | Win32.SYNCHRONIZE | 4095, false, ProcessId);
//读取棋盘数据
Win32.ReadProcessMemory(hObject, (IntPtr)lpBase, lpBufferbase, buffer.Length, IntPtr.Zero);
//关闭线程
Win32.CloseHandle(hObject);
return Marshal.ReadByte(lpBufferbase);
}
}
}
...全文
相关推荐
C#编写的QQ连连看源代码!
该项目使用C#开发,实现了针对QQ连连看游戏的辅助工具。核心功能包括识别游戏窗口、初始化游戏参数、分析图像块匹配关系,并通过路径搜索实现自动配对消除。代码结构清晰,包含图形界面控制与底层逻辑处理模块,
C#做的QQ程序源代码
在这个“C#做的QQ程序源代码”项目中,我们可以深入学习C#编程语言的应用,尤其是在构建类似即时通讯软件方面的能力。
c#仿QQ聊天IM界面实现(源代码)
【标题】:“C#仿QQ聊天IM界面实现(源代码)”是一个基于C#编程语言的项目,旨在模仿QQ即时通讯软件的用户界面,并且提供了完整的功能实现。
QQ连连看辅助
QQ连连看辅助是一款基于C#编程语言,利用Win32 API技术开发的工具软件,旨在帮助用户更轻松地玩转经典游戏——QQ连连看。
C#, QQ连连看, 模拟鼠标点击自动连牌器
本文介绍了一个名为Form1的类,它是qq连连看项目的一部分。该类包含开始游戏和退出程序的按钮,以及初始化组件、处理按钮点击事件和资源清理的方法。程序通过读取游戏内存数据,模拟鼠标点击自动完成连连看游


