近来无事,写个连连看辅助,下面先说下思路吧(口才不行,见谅哈)

游戏辅助有三种方法,一种是读内存,这个不知道怎么分析,还有一种是获取封包,这个分析起来复杂,最后一种是图片识别再分析,这里采用最后一种 图片识别来做。

设计UI如下

连连看开始》启动辅助》得到游戏窗口信息(位置,大小)》将游戏窗口置顶(其实就是激活状态),并恢复默认状态》截取整个屏幕保存起来》得到游戏区域的坐标信息》分割游戏区域将每一块的大小,位置,并在其上面取9个点的颜色值,存入到List<List<T>>中(同时判断是不是背景色,背景判断是求9个点的颜色平均值,如果每个点和平均值相差5以内就认定是背景)》循环List<List<T>>开始识别

下面说下识别时候的思路

先给个图片

我们都知道连连看最多只可以拐2次

假设红色方块是开始位置,先向左一个方格,得到方格,如果是背景或者是已经消除了的,则检测上方,如果是没有消除的,则判定是不是一样的,

然后向下取一个方格,这时候已经拐了1次了,然后判断这个方格的左侧,然后右侧,然后下侧

按照图上的解释下

得到1是背景则向上,不是背景,判断和目标方块不一样,则向下得到3,是背景,则查看3的左侧,是背景,再左侧,是背景,再....查看到尽头是背景(这个地方为什么不看上下了呢?因为这个时候已经拐了2次了),然后看右侧,得到5,是背景,再右侧...到尽头是背景,然后还是继续向下得到6,是背景,然后看6的左右,依次类推,如果1的下方都没有找到 ,那么继续向左找,得到7,看7的上下,依次类推

本来我是打算使用大漠插件做的 ,但是遇到2个问题:1、采集图片信息太慢,每个方块9个点,采集19*11个方块竟然用了40多S(也可能是我没有找到合适的方法),2、识别后点击的时候快速移动并点击多次会报错

所以我准备自己调用user32.dll的方法来实现

另外,你需要开启连连看游戏,截屏一个图片,然后创建一个解决方案将这个图片放到窗体上,模拟一个游戏窗口,你总不能编写的时候 一会启动一下游戏吧,测试可以用你这个窗口来,等写好后最后测试再用QQ游戏测试下效果

新建一个winform方案,再这个方案想再添加一个专案,就是上面提到的那个测试窗体,就是拉一个picbox放图片,窗体样式设为none效果如下图,

这里你还要得到一个数据,就是窗口左上角到上图红点位置的xy坐标值

我使用根据进程获取句柄,后来发现连连看进程名字会改变,所以需要在config.txt里面配置下  或者修改根据窗口名字获得句柄

然后下面介绍下各个类的作用

Form1  主窗体

 using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
using System.IO; namespace LianLianHelp
{
public partial class Form1 : Form
{
public static int SleepTime = ;
private bool isstop = true;
private bool isstart = false;
string gamename = "KYODAI~1";
public Form1()
{
InitializeComponent();
// dm.SetPath(Application.StartupPath + "\\aa");
}
Point gamePoint1 = new Point();
private void button1_Click(object sender, EventArgs e)
{ this.button1.Enabled = false;
// Start();
Thread th = new Thread(Start);
th.IsBackground = true;
th.Start();
} private void Start()
{
isstart = true;
isstop = false;
LianLianHelp.LianLelp.ClearList();
GetGamePanel();
GetNodes();
try
{
StarCheckNode();
}
catch
{ }
isstart = false;
isstop = true;
this.button1.BeginInvoke(new MethodInvoker(delegate()
{
button1.Enabled = true;
}));
} /// <summary>
/// 得到游戏信息
/// </summary>
private void GetGamePanel()
{
//YodaoDict LianLianDemo
// Process[] ps = Process.GetProcessesByName("KYODAI~1");
Process[] ps = Process.GetProcessesByName(gamename);
IntPtr lianlian_hwnd = ps[].MainWindowHandle;
// int lianlian_hwnd = dm.FindWindow("", "QQ游戏 - 连连看角色版"); Point mousepoint = LianLianHelp.GetMousePoint();
LianLianHelp.ShowWindow(lianlian_hwnd, );
LianLianHelp.SetForegroundWindow(lianlian_hwnd);
// dm.GetCursorPos(ref x, ref y);
//dm.SetWindowState(lianlian_hwnd, 1);
// dm.MoveTo(0, 0);
LianLianHelp.MoveMouse(, );
//LianLianHelp.SetWindowSize();
LianLianHelp.LianLelp.PrintScreen(Application.StartupPath + "\\screen.jpg");
// dm.CaptureJpg(0, 0, dm.GetScreenWidth(), dm.GetScreenHeight(), "screen.jpg", 100);
LianLianHelp.MoveMouse(mousepoint.X, mousepoint.Y);
// dm.MoveTo((int)x, (int)y);
//得到窗口大小
int x1 = , x2 = , y1 = , y2 = ;
LianLianHelp.GetWindowRects(lianlian_hwnd, ref x1, ref y1, ref x2, ref y2);
gamePoint1 = new Point((int)x1 + HelpSource.game_offset.X, (int)y1 + HelpSource.game_offset.Y);
} /// <summary>
/// 得到游戏图片方块
/// </summary>
private void GetNodes()
{
int x = gamePoint1.X;
int y = gamePoint1.Y; Bitmap bitmap = new Bitmap(Application.StartupPath + "\\screen.jpg");
for (int j = ; j < ; j++)
{
int _x = x + HelpSource.pieceSize.Width * j; List<LianLianClass> lclist = new List<LianLianClass>();
for (int i = ; i < ; i++)
{
int _y = y + HelpSource.pieceSize.Height * i;
LianLianClass lc = new LianLianClass(); int xindex = _x + ;
int[] _corlrs = new int[];
int cindex = ;
for (int m = ; m < ; m++)
{
int yindex = _y + ;
for (int n = ; n < ; n++)
{
Color color = bitmap.GetPixel(xindex, yindex); int r = Convert.ToInt32(color.R);
int g = Convert.ToInt32(color.G);
int b = Convert.ToInt32(color.B);
//string colorstr = dm.GetColor(xindex, yindex);
//int _colorcount = Getcolor(colorstr);
_corlrs[cindex] = r + g + b;
yindex += ;
cindex++;
}
xindex += ;
}
int colorcount = ;
lc.IsBackgrpund = CheckValue(_corlrs, ref colorcount);
lc.ThisPoint = new Point(_x + , _y + );
lc.ListPoint = new Point(j, i);
lc.ColorNumCount = _corlrs;
lclist.Add(lc);
}
LianLianHelp.LianLelp.LianList.Add(lclist);
}
bitmap.Dispose();
} private void StarCheckNode()
{
List<List<LianLianClass>> lianList = LianLianHelp.LianLelp.LianList;
while (true)
{
for (int x = ; x < ; x++)
{
for (int y = ; y < ; y++)
{
if (lianList[x][y].IsBackgrpund || lianList[x][y].Ismove)
continue;
thisllc = lianList[x][y]; // thisllc.ListPoint = new Point(x, y);
if (!CheckNode(thisllc, , NODETYPE.SOURCENODE, TODIRECTION.LEFT))
if (!CheckNode(thisllc, , NODETYPE.SOURCENODE, TODIRECTION.UP))
if (!CheckNode(thisllc, , NODETYPE.SOURCENODE, TODIRECTION.RIGHT))
CheckNode(thisllc, , NODETYPE.SOURCENODE, TODIRECTION.DOWN);
}
}
if (LianLianHelp.LianLelp.CheckISOK())
{
break;
}
}
}
LianLianClass thisllc = null;
LianLianClass checkllc = null;
/// <summary>
///
/// </summary>
/// <param name="lc">当前位置方块</param>
/// <param name="checkindex">第几个转弯,</param>
/// <param name="nodeType">lc类型</param>
/// <param name="toDirection">方向</param>
private bool CheckNode(LianLianClass lc, int checkindex, NODETYPE nodeType, TODIRECTION toDirection)
{
if (isstop)
{
throw new Exception();
}
if (checkindex > )
return false;
if (toDirection == TODIRECTION.LEFT)
{
#region left
LianLianClass _lc = LianLianHelp.LianLelp.GetNextLLC(lc.ListPoint.X, lc.ListPoint.Y, toDirection);
if (_lc == null)
return false;
if (_lc.ListPoint == thisllc.ListPoint)
return false;
if (_lc.IsBackgrpund || _lc.Ismove)
{
int _c = checkindex + ;
if (CheckNode(_lc, _c, NODETYPE.OTHERNODE, TODIRECTION.UP))
{
return true;
}
_c = checkindex + ;
if (CheckNode(_lc, _c, NODETYPE.OTHERNODE, TODIRECTION.DOWN))
{
return true;
}
else
{
_c = checkindex;
return CheckNode(_lc, _c, NODETYPE.OTHERNODE, TODIRECTION.LEFT);
}
}
else
{
if (LianLianHelp.LianLelp.Isalike(_lc, thisllc))
{
ClickNode(_lc, thisllc);
return true;
}
else
return false;
}
#endregion
}
else if (toDirection == TODIRECTION.RIGHT)
{
LianLianClass _lc = LianLianHelp.LianLelp.GetNextLLC(lc.ListPoint.X, lc.ListPoint.Y, toDirection);
if (_lc == null)
return false;
if (_lc.ListPoint == thisllc.ListPoint)
return false;
if (_lc.IsBackgrpund || _lc.Ismove)
{
int _c = checkindex + ;
if (CheckNode(_lc, _c, NODETYPE.OTHERNODE, TODIRECTION.UP))
{
return true;
}
_c = checkindex + ;
if (CheckNode(_lc, _c, NODETYPE.OTHERNODE, TODIRECTION.DOWN))
{
return true;
}
else
{
_c = checkindex;
return CheckNode(_lc, _c, NODETYPE.OTHERNODE, TODIRECTION.RIGHT);
}
}
else
{
if (LianLianHelp.LianLelp.Isalike(_lc, thisllc))
{
ClickNode(_lc, thisllc);
return true;
}
else
return false;
}
}
else if (toDirection == TODIRECTION.UP)
{
LianLianClass _lc = LianLianHelp.LianLelp.GetNextLLC(lc.ListPoint.X, lc.ListPoint.Y, toDirection);
if (_lc == null)
return false;
if (_lc.ListPoint == thisllc.ListPoint)
return false;
if (_lc.IsBackgrpund || _lc.Ismove)
{
int _c = checkindex + ;
if (CheckNode(_lc, _c, NODETYPE.OTHERNODE, TODIRECTION.LEFT))
{
return true;
}
_c = checkindex + ;
if (CheckNode(_lc, _c, NODETYPE.OTHERNODE, TODIRECTION.RIGHT))
{
return true;
}
else
{
_c = checkindex;
return CheckNode(_lc, _c, NODETYPE.OTHERNODE, TODIRECTION.UP);
}
}
else
{
if (LianLianHelp.LianLelp.Isalike(_lc, thisllc))
{
ClickNode(_lc, thisllc);
return true;
}
else
return false;
}
}
else
{
LianLianClass _lc = LianLianHelp.LianLelp.GetNextLLC(lc.ListPoint.X, lc.ListPoint.Y, toDirection);
if (_lc == null)
return false;
if (_lc.ListPoint == thisllc.ListPoint)
return false;
if (_lc.IsBackgrpund || _lc.Ismove)
{
int _c = checkindex + ;
if (CheckNode(_lc, _c, NODETYPE.OTHERNODE, TODIRECTION.LEFT))
{
return true;
}
_c = checkindex + ;
if (CheckNode(_lc, _c, NODETYPE.OTHERNODE, TODIRECTION.RIGHT))
{
return true;
}
else
{
_c = checkindex;
return CheckNode(_lc, _c, NODETYPE.OTHERNODE, TODIRECTION.DOWN);
}
}
else
{
if (LianLianHelp.LianLelp.Isalike(_lc, thisllc))
{
ClickNode(_lc, thisllc);
return true;
}
else
return false;
}
} } private bool CheckValue(int[] values, ref int count)
{
foreach (int i in values)
{
count += i;
}
int _index = count / values.Length;
foreach (int i in values)
{
if (Math.Abs(i - _index) >= )
{
return false;
}
}
return true;
} private void ClickNode(LianLianClass lc1, LianLianClass lc2)
{
lc1.Ismove = true;
lc2.Ismove = true;
LianLianHelp.MoveMouse(lc1.ThisPoint.X, lc1.ThisPoint.Y);
Thread.Sleep();
LianLianHelp.LeftClick(lc1.ThisPoint.X, lc1.ThisPoint.Y);
Thread.Sleep();
LianLianHelp.MoveMouse(lc2.ThisPoint.X, lc2.ThisPoint.Y);
Thread.Sleep();
LianLianHelp.LeftClick(lc2.ThisPoint.X, lc2.ThisPoint.Y);
Thread.Sleep(SleepTime);
Console.WriteLine("Click(" + lc1.ListPoint.X + "," + lc1.ListPoint.Y + ") and (" + lc2.ListPoint.X + "," + lc2.ListPoint.Y + ")");
} private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
} private void radioButton2_Click(object sender, EventArgs e)
{
RadioButton rdo = sender as RadioButton;
int index = int.Parse(rdo.Tag.ToString());
Random r = new Random();
switch (index)
{
case :
SleepTime = ;
break;
case : SleepTime = r.Next(, ); break;
case : SleepTime = r.Next(, ); break;
case : SleepTime = r.Next(, ); break;
}
button1.Enabled = true;
} private void Form1_Load(object sender, EventArgs e)
{
using (StreamReader reader = new StreamReader(Application.StartupPath + "\\config.txt"))
{
string _name = reader.ReadToEnd().Trim();
if (_name.Length > )
gamename = reader.ReadToEnd();
}
LianLianHelp.RegisterHotKey(this.Handle, , , Keys.F10);
LianLianHelp.RegisterHotKey(this.Handle, , , Keys.F11);
LianLianHelp.RegisterHotKey(this.Handle, , , Keys.F6);
LianLianHelp.RegisterHotKey(this.Handle, , , Keys.F7);
} protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case 0x0312: //这个是window消息定义的注册的热键消息
if (m.WParam.ToString().Equals(""))
{
if (!isstart)
{
isstart = true;
this.button1.Enabled = false;
// Start();
Thread th = new Thread(Start);
th.IsBackground = true;
th.Start();
}
}
else if (m.WParam.ToString().Equals(""))
{
isstop = true;
}
else if (m.WParam.ToString().Equals(""))
{
this.Hide();
}
else if (m.WParam.ToString().Equals(""))
{
this.Show();
} break;
}
base.WndProc(ref m);
} private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
LianLianHelp.UnregisterHotKey(this.Handle, );
LianLianHelp.UnregisterHotKey(this.Handle, );
LianLianHelp.UnregisterHotKey(this.Handle, );
LianLianHelp.UnregisterHotKey(this.Handle, );
}
} }
 namespace LianLianHelp
{
partial class Form1
{
/// <summary>
/// 設計工具所需的變數。
/// </summary>
private System.ComponentModel.IContainer components = null; /// <summary>
/// 清除任何使用中的資源。
/// </summary>
/// <param name="disposing">如果應該處置 Managed 資源則為 true,否則為 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
} #region Windows Form 設計工具產生的程式碼 /// <summary>
/// 此為設計工具支援所需的方法 - 請勿使用程式碼編輯器
/// 修改這個方法的內容。
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton3 = new System.Windows.Forms.RadioButton();
this.radioButton4 = new System.Windows.Forms.RadioButton();
this.button2 = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// button1
//
this.button1.Enabled = false;
this.button1.Location = new System.Drawing.Point(, );
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(, );
this.button1.TabIndex = ;
this.button1.Text = "开始";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.Location = new System.Drawing.Point(, );
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(, );
this.radioButton1.TabIndex = ;
this.radioButton1.Tag = "";
this.radioButton1.Text = "闪电";
this.radioButton1.UseVisualStyleBackColor = true;
this.radioButton1.Click += new System.EventHandler(this.radioButton2_Click);
//
// radioButton2
//
this.radioButton2.AutoSize = true;
this.radioButton2.Checked = true;
this.radioButton2.Location = new System.Drawing.Point(, );
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(, );
this.radioButton2.TabIndex = ;
this.radioButton2.TabStop = true;
this.radioButton2.Tag = "";
this.radioButton2.Text = "烈马";
this.radioButton2.UseVisualStyleBackColor = true;
this.radioButton2.Click += new System.EventHandler(this.radioButton2_Click);
//
// radioButton3
//
this.radioButton3.AutoSize = true;
this.radioButton3.Location = new System.Drawing.Point(, );
this.radioButton3.Name = "radioButton3";
this.radioButton3.Size = new System.Drawing.Size(, );
this.radioButton3.TabIndex = ;
this.radioButton3.Tag = "";
this.radioButton3.Text = "脱兔";
this.radioButton3.UseVisualStyleBackColor = true;
this.radioButton3.Click += new System.EventHandler(this.radioButton2_Click);
//
// radioButton4
//
this.radioButton4.AutoSize = true;
this.radioButton4.Location = new System.Drawing.Point(, );
this.radioButton4.Name = "radioButton4";
this.radioButton4.Size = new System.Drawing.Size(, );
this.radioButton4.TabIndex = ;
this.radioButton4.Tag = "";
this.radioButton4.Text = "蜗牛";
this.radioButton4.UseVisualStyleBackColor = true;
this.radioButton4.Click += new System.EventHandler(this.radioButton2_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(, );
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(, );
this.button2.TabIndex = ;
this.button2.Text = "退出";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.radioButton4);
this.groupBox1.Controls.Add(this.radioButton1);
this.groupBox1.Controls.Add(this.radioButton2);
this.groupBox1.Controls.Add(this.radioButton3);
this.groupBox1.Location = new System.Drawing.Point(, );
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(, );
this.groupBox1.TabIndex = ;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "速度";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.label4);
this.groupBox2.Controls.Add(this.label3);
this.groupBox2.Controls.Add(this.label2);
this.groupBox2.Controls.Add(this.label1);
this.groupBox2.Location = new System.Drawing.Point(, );
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(, );
this.groupBox2.TabIndex = ;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "热键";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(, );
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(, );
this.label4.TabIndex = ;
this.label4.Text = "停止:F11";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(, );
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(, );
this.label3.TabIndex = ;
this.label3.Text = "开始:F10";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(, );
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(, );
this.label2.TabIndex = ;
this.label2.Text = "呼出:F7";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(, );
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(, );
this.label1.TabIndex = ;
this.label1.Text = "隐藏:F6";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(, );
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Name = "Form1";
this.Text = "QQ连连看游戏辅助";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
this.Load += new System.EventHandler(this.Form1_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.ResumeLayout(false); } #endregion private System.Windows.Forms.Button button1;
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.RadioButton radioButton3;
private System.Windows.Forms.RadioButton radioButton4;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
}
}

HelpSource 保存一些数据

 using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing; namespace LianLianHelp
{
class HelpSource
{
/// <summary>
/// 游戏区域相对于窗口偏移
/// </summary>
public static Point game_offset = new Point(, );
/// <summary>
/// 游戏区域大小
/// </summary>
public static Size gameSize = new Size(, );
/// <summary>
/// 每个方块大小
/// </summary>
public static Size pieceSize = new Size(, );
}
}

LianLianClass 游戏小方格类

 using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing; namespace LianLianHelp
{
class LianLianClass
{
private int[] colorNumCount=new int[];
/// <summary>
/// 颜色值
/// </summary>
public int[] ColorNumCount
{
get { return colorNumCount; }
set { colorNumCount = value; }
} private bool isBackgrpund = false;
/// <summary>
/// 是否是背景
/// </summary>
public bool IsBackgrpund
{
get { return isBackgrpund; }
set { isBackgrpund = value; }
} private Point thisPoint;
/// <summary>
/// 方块位置
/// </summary>
public Point ThisPoint
{
get { return thisPoint; }
set { thisPoint = value; }
} private Point listPoint;
/// <summary>
/// 数组中的位置
/// </summary>
public Point ListPoint
{
get { return listPoint; }
set { listPoint = value; }
}private bool ismove = false;
/// <summary>
/// 是否移除了
/// </summary>
public bool Ismove
{
get { return ismove; }
set { ismove = value; }
} private TODIRECTION toDirection = TODIRECTION.RIGHT; internal TODIRECTION ToDirection
{
get { return toDirection; }
set { toDirection = value; }
}
}
}

LianLianHelp  游戏辅助类

 using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics; namespace LianLianHelp
{
enum TODIRECTION
{
LEFT,
RIGHT,
UP,
DOWN
} enum NODETYPE
{
SOURCENODE,
OTHERNODE
} class LianLianHelp
{
private static LianLianHelp lianLelp; public static LianLianHelp LianLelp
{
get
{
if (lianLelp == null)
{
lianLelp = new LianLianHelp();
}
return LianLianHelp.lianLelp;
}
} private LianLianHelp()
{ } public void ClearList()
{
LianList.Clear();
} List<List<LianLianClass>> lianList = new List<List<LianLianClass>>();
/// <summary>
/// 方块列表
/// </summary>
public List<List<LianLianClass>> LianList
{
get { return lianList; }
set { lianList = value; }
} public bool Isalike(LianLianClass c1, LianLianClass c2)
{ for (int i = ; i < ; i++)
{
if (Math.Abs(c1.ColorNumCount[i] - c2.ColorNumCount[i]) > )
return false;
}
return true;
} public LianLianClass GetLLC(int thisx, int thisy, TODIRECTION toDirection)
{
LianLianClass lc = GetNextLLC(thisx, thisy, toDirection);
if (lc.Ismove == true || lc.IsBackgrpund == true)
lc = GetLLC(lc.ListPoint.X, lc.ListPoint.Y, toDirection);
return lc;
} public LianLianClass GetNextLLC(int thisx, int thisy, TODIRECTION toDirection)
{
LianLianClass lc = null;
switch (toDirection)
{
case TODIRECTION.LEFT:
if (thisx == )
return null;
else
{
lc = LianList[thisx - ][thisy];
}
break;
case TODIRECTION.RIGHT:
if (thisx == )
return null;
else
{
lc = LianList[thisx + ][thisy];
}
break;
case TODIRECTION.UP:
if (thisy == )
return null;
else
{
lc = LianList[thisx][thisy - ]; }
break;
case TODIRECTION.DOWN:
if (thisy == )
return null;
else
{
lc = LianList[thisx][thisy + ];
}
break;
}
return lc;
} public bool CheckISOK()
{
for (int x = ; x < ; x++)
{
for (int y = ; y < ; y++)
{
LianLianClass llc = LianList[x][y];
if (llc.IsBackgrpund)
{
continue;
}
if (!llc.Ismove)
{
return false;
}
}
}
return true;
} public void PrintScreen(string file)
{
Bitmap bit = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics g = Graphics.FromImage(bit);
g.CopyFromScreen(new Point(, ), new Point(, ), bit.Size);
bit.Save(file);
g.Dispose();
bit.Dispose();
} #region 鼠标
const int MOUSEEVENTF_MOVE = 0x0001; // 移动鼠标
const int MOUSEEVENTF_LEFTDOWN = 0x0002; //模拟鼠标左键按下
const int MOUSEEVENTF_LEFTUP = 0x0004; //模拟鼠标左键抬起
const int MOUSEEVENTF_RIGHTDOWN = 0x0008; //模拟鼠标右键按下
const int MOUSEEVENTF_RIGHTUP = 0x0010; //模拟鼠标右键抬起
const int MOUSEEVENTF_MIDDLEDOWN = 0x0020;// 模拟鼠标中键按下
const int MOUSEEVENTF_MIDDLEUP = 0x0040; //模拟鼠标中键抬起
const int MOUSEEVENTF_ABSOLUTE = 0x8000; //标示是否采用绝对坐标 [DllImport("user32.dll", EntryPoint = "GetCursorPos")]//获取鼠标坐标
private static extern int GetCursorPos(
ref POINTAPI lpPoint
); [System.Runtime.InteropServices.DllImport("user32")]
private static extern int mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo); public static void LeftClick(int x, int y)
{
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE, x * / Screen.PrimaryScreen.Bounds.Width, y * / Screen.PrimaryScreen.Bounds.Height, , );//点击
mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE, x * / Screen.PrimaryScreen.Bounds.Width, y * / Screen.PrimaryScreen.Bounds.Height, , );//抬起
} public static void MoveMouse(int x, int y)
{
mouse_event(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE, x * / Screen.PrimaryScreen.Bounds.Width, y * / Screen.PrimaryScreen.Bounds.Height, , );
} [StructLayout(LayoutKind.Sequential)]//定义与API相兼容结构体,实际上是一种内存转换
private struct POINTAPI
{
public int X;
public int Y;
} public static Point GetMousePoint()
{
LianLianHelp.POINTAPI pointapi = new LianLianHelp.POINTAPI();
LianLianHelp.GetCursorPos(ref pointapi);
return new Point(pointapi.X, pointapi.Y);
}
#endregion #region 窗体
public const int SW_HIDE = ;
public const int SW_SHOWNORMAL = ;
public const int SW_SHOWMINIMIZED = ;
public const int SW_SHOWMAXIMIZED = ;
public const int SW_MAXIMIZE = ;
public const int SW_SHOWNOACTIVATE = ;
public const int SW_SHOW = ;
public const int SW_MINIMIZE = ;
public const int SW_SHOWMINNOACTIVE = ;
public const int SW_SHOWNA = ;
public const int SW_RESTORE = ; [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern int ShowWindow(IntPtr hwnd, int nCmdShow);
[System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SetForegroundWindow")]
public static extern bool SetForegroundWindow(IntPtr hWnd);//设置此窗体为活动窗体
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool GetWindowRect(IntPtr hWnd, ref RECT lpRect); [StructLayout(LayoutKind.Sequential)]
private struct RECT
{
public int Left; //最左坐标
public int Top; //最上坐标
public int Right; //最右坐标
public int Bottom; //最下坐标
} [DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int MoveWindow(IntPtr hWnd, int x, int y, int nWidth, int nHeight, bool BRePaint); public static int SetWindowSize(IntPtr hWnd, int x, int y, int width, int height)
{
return MoveWindow(hWnd, x, y, width, height, false);
} public static int GetWindowHandle(string name)
{
Process[] ps = Process.GetProcessesByName(name);
return ps[].MainWindowHandle.ToInt32();
} public static void GetWindowRects(IntPtr hWnd, ref int x1, ref int y1, ref int x2, ref int y2)
{
RECT rect = new RECT();
GetWindowRect(hWnd, ref rect);
x1 = rect.Left;
y1 = rect.Top;
x2 = rect.Right;
y2 = rect.Bottom;
} #endregion #region 热键
//注册热键的api
[DllImport("user32.dll")]
public static extern bool RegisterHotKey(IntPtr hWnd, int id, uint control, Keys vk);
[DllImport("user32.dll")]
public static extern bool UnregisterHotKey(IntPtr hWnd, int id); #endregion
}
}

游戏效果:如果ClickNode不添加时间间隔,瞬间全消

c#QQ连连看辅助的更多相关文章

  1. 【好玩的应用】QQ连连看辅助工具

    自己学了这么久的C语言,但没有写出过什么可以用的东西来,总觉得心里不爽.这几天实在是不想干正事,在网上瞎逛逛,结果发现有人写了连连看的外挂.顿时觉得这很有意思啊.于是把代码下载下来,捣鼓了捣鼓.发现还 ...

  2. QQ连连看-外挂

    QQ连连看-外挂 2014-11-06 参考 [1] [视频教程] c语言实践课程之qq连连看辅助开发 [2] CE工具下载 [3] [原创]qq连连看外挂制作详解

  3. 用Python玩连连看是什么效果?

    1.前言 Python实现的qq连连看辅助, 仅用于学习, 请在练习模式下使用, 请不要拿去伤害玩家们... 很多人学习python,不知道从何学起.很多人学习python,掌握了基本语法过后,不知道 ...

  4. C#_自动测试2_连连看外挂

    GUI自动化测试和做外挂的原理很相似,都是模拟用户的鼠标和键盘操作, 给自己的程序写自动化就是做测试,给别人的程序写自动化就是外挂了. 本文使用的技术也同样适用制作“对对碰”,"找茬&quo ...

  5. Django商城项目笔记No.11用户部分-QQ登录1获取QQ登录网址

    Django商城项目笔记No.11用户部分-QQ登录 QQ登录,亦即我们所说的第三方登录,是指用户可以不在本项目中输入密码,而直接通过第三方的验证,成功登录本项目. 若想实现QQ登录,需要成为QQ互联 ...

  6. 游戏辅助外gua篇:如何Dump内存获得游戏的辅助

    转载请标明出处: https://dujinyang.blog.csdn.net/article/category/9267855 本文出自:[奥特曼超人的博客] 本篇邀请了 "阿七&quo ...

  7. visual_c++外挂教程(详细)

    课程分四个大章节 初级篇,中级篇,进阶篇,高级篇 初级篇内容:编写一个完整的,简单的外挂 C++的数据类型:Byte,Word,DWORD,int,float API函数的调mouse_event,G ...

  8. C#本地修改器

    C#本地修改器 C# 制作外挂常用的API C#做外挂的常用API,本人用了很久,基本没发现问题 using System; using System.Collections.Generic; usi ...

  9. C#外挂QQ找茬辅助源码,早期开发

    这是一款几年前开发的工具,当年作为一民IT纯屌,为了当年自己心目中的一位女神熬夜开发完成.女神使用后找茬等级瞬间从眼明手快升级为三只眼...每次看到这个就会想起那段屌丝与女神的回忆.今天特地把代码更新 ...

随机推荐

  1. Tips & Tricks:Apache log4j简明教程(一)

    Apache log4j的官方介绍是“log4j is a reliable, fast and flexible logging framework (APIs) written in Java, ...

  2. Python的print中国输出对齐问题

    问题叙述性说明: 在使用Python内置函数print当输出英语,应用格输出类型可以对齐很好: s1 = 'I am a long sentence.' s2 = 'I\'m short.' prin ...

  3. I Love This Game 2115(结构体)

    Problem Description Do you like playing basketball ? If you are , you may know the NBA Skills Challe ...

  4. 判断sqlserver对象是否存在

    --查看对象是否已经存在  --数据库是否存在     --if exists (select * from sys.databases where name = ’数据库名’)    --  dro ...

  5. C# 中的常用正则表达式总结

    这是我发了不少时间整理的C# 的正则表达式 ,新手朋友注意一定要手册一下哦,这样可以节省很多写代码的时间,中国自学编程网为新手朋友整理发布. 只能输入数字:"^[0-9]*$". ...

  6. 【Head First Javascript】学习笔记0——自己制作chm参考手册素材

    变量声明:var 常量声明:const 数据格式转换: 1.转换函数 parseInt(A):把字符串A转换成整数:其中A为只包含数字的字符串 parseFloat(A):把字符串A转换成浮点数:其中 ...

  7. 如何使用linq操作datatable进行分组

    使用微软.net的孩子们应该都知道linq吧,要知道linq可是其他高级语言没有的技术,比如php,java等等,但是起初我对linq的认识只是停留在对 list<> 的泛型集合进行操作, ...

  8. 我的MYSQL学习心得(九)

    原文:我的MYSQL学习心得(九) 我的MYSQL学习心得(九) 我的MYSQL学习心得(一) 我的MYSQL学习心得(二) 我的MYSQL学习心得(三) 我的MYSQL学习心得(四) 我的MYSQL ...

  9. ASP.NET 5 :读写数据库连接字符串

    ASP.NET 5 :读写数据库连接字符串 1.概述 ASP.NET 5模板项目配置文件采用了JSON格式,你依然可以采用以前的xml格式.C#对web.config或app.config读写及加密有 ...

  10. 吞吐量(Throughput)、QPS、并发数、响应时间(RT)对系统性能的影响

    首先对吞吐量().QPS.并发数.响应时间(RT)几个概念一直比较模糊,也不知道哪些指标可以较好的衡量系统的性能.今天特意查了些资料做一些记录:首先看一些概念(来自百度百科) 1. 响应时间(RT) ...