在好例子网,分享、交流、成长!
您当前所在位置:首页C# 开发实例C#游戏开发 → C# 枪战通用物理外挂 源码

C# 枪战通用物理外挂 源码

C#游戏开发

下载此实例
  • 开发语言:C#
  • 实例大小:0.07M
  • 下载次数:36
  • 浏览次数:971
  • 发布时间:2018-01-07
  • 实例类别:C#游戏开发
  • 发 布 人:猫九先森
  • 文件格式:.rar
  • 所需积分:5
 相关标签: 游戏 外挂 源码

实例介绍

【实例简介】


使用方法通读代码后就会使用了,自己摸索也可以!

【实例截图】

【核心代码】

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 枪战类通用物理外挂
{
    public partial class Form1 : Form
    {
        public Form1()
        {           
            InitializeComponent();
        }
        int bs=2;//倍数
        [DllImport("user32.dll")]//取设备场景
        private static extern IntPtr GetDC(IntPtr hwnd);//返回设备场景句柄
        [DllImport("gdi32.dll")]//取指定点颜色
        private static extern int GetPixel(IntPtr hdc, Point p);

        [DllImport("user32.dll", EntryPoint = "FindWindowA")]
        public static extern IntPtr FindWindowA(string lp1, string lp2);

        [DllImport("user32.dll", EntryPoint = "ShowWindow")]
        public static extern IntPtr ShowWindow(IntPtr hWnd, int _value);
        //重写API函数
        [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "ShowCursor")]
        public extern static bool ShowCursor(bool bShow);
        private void Form1_Load(object sender, EventArgs e)
        {
            TransparencyKey = BackColor;
        }
        int bj;
        private void timer1_Tick(object sender, EventArgs e)
        {
            Point p = new Point(MousePosition.X, MousePosition.Y);//取置顶点坐标        
            IntPtr hdc = GetDC(new IntPtr(0));//取到设备场景(0就是全屏的设备场景)
            int bj = GetPixel(hdc, p);//取指定点颜色
            int r = (bj & 0xFF);//转换R
            int g = (bj & 0xFF00) / 256;//转换G
            int b = (bj & 0xFF0000) / 65536;//转换B
            pictureBox2.BackColor = Color.FromArgb(r, g, b);//设置颜色框
        }

        private void button3_Click(object sender, EventArgs e)
        {
            timer1.Start();
            if (KG == true)
            {
                KG = false;
            }
            else { KG = true; }
        }

        private void button3_KeyDown(object sender, KeyEventArgs e)
        {
            if(e.KeyCode==Keys.T)
            {
                timer1.Stop();
            }
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            Point p = new Point(MousePosition.X, MousePosition.Y);//取置顶点坐标
            label1.Text = "当前鼠标坐标:"   "X:"   p.X   "Y:"   p.Y;//把坐标显示到窗口上
            my = p.Y;
            mx = p.X;
        }

        private void button4_Click(object sender, EventArgs e)
        {
            timer2.Start();
        }

        private void button4_KeyDown(object sender, KeyEventArgs e)
        {
            timer2.Stop();
        }
        //放大图片
        public Bitmap Magnifier(Bitmap srcbitmap, int multiple)
        {
            try
            {
                if (multiple <= 0) { multiple = 0; return srcbitmap; }
                Bitmap bitmap = new Bitmap(srcbitmap.Size.Width * multiple, srcbitmap.Size.Height * multiple);
                BitmapData srcbitmapdata = srcbitmap.LockBits(new Rectangle(new Point(0, 0), srcbitmap.Size), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
                BitmapData bitmapdata = bitmap.LockBits(new Rectangle(new Point(0, 0), bitmap.Size), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
                unsafe
                {
                    byte* srcbyte = (byte*)(srcbitmapdata.Scan0.ToPointer());
                    byte* sourcebyte = (byte*)(bitmapdata.Scan0.ToPointer());
                    for (int y = 0; y < bitmapdata.Height; y  )
                    {
                        for (int x = 0; x < bitmapdata.Width; x  )
                        {
                            long index = (x / multiple) * 4   (y / multiple) * srcbitmapdata.Stride;
                            sourcebyte[0] = srcbyte[index];
                            sourcebyte[1] = srcbyte[index   1];
                            sourcebyte[2] = srcbyte[index   2];
                            sourcebyte[3] = srcbyte[index   3];
                            sourcebyte  = 4;
                        }
                    }
                }
                srcbitmap.UnlockBits(srcbitmapdata);
                bitmap.UnlockBits(bitmapdata);
                return bitmap;
            }
            catch { this.Close(); return null; }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            timer3.Start();
           
        }
        int screenWidth;        //屏幕宽度
        int screenHeight;       //屏幕高度
        int mx;                 //鼠标x坐标
        int my;                 //鼠标y坐标
        const int imgWidth = 181;//放大后图片的宽度
        const int imgHeight = 181;//放大后图片的高度
        public double ColorSub(Color Color1, Color Color2)
        {
            double  temp = Math.Pow((Color1.R - Color2.R), 2)   Math.Pow((Color1.G - Color2.G), 2)   Math.Pow((Color1.B - Color2.B), 2);
            return  temp;
        }
        Graphics g;
        bool KG=false ;
        private void timer3_Tick(object sender, EventArgs e)
        {
            Bitmap image;
            Size size = new Size(imgWidth, imgHeight);
            image = new Bitmap(size.Width, size.Height);
            g = Graphics.FromImage(image);
            g.CopyFromScreen(new Point(mx - (imgWidth / 4), my - (imgHeight / 4)), new Point(0, 0), size);
            g.Dispose();
            pictureBox1.Image = Magnifier(image, bs);
            image.Dispose();
            Point p = new Point(mx, my);//取置顶点坐标        
            IntPtr hdc = GetDC(new IntPtr(0));//取到设备场景(0就是全屏的设备场景)
            int k = GetPixel(hdc, p);//取指定点颜色
            int r = (k & 0xFF);//转换R
            int g2 = (k & 0xFF00) / 256;//转换G
            int b = (k & 0xFF0000) / 65536;//转换B
            pictureBox3.BackColor = Color.FromArgb(r, g2, b);//设置颜色框
            double l = ColorSub(pictureBox2.BackColor, pictureBox3.BackColor);
            if (l < 1000 && KG==true)
            {
                Console.Beep(800, 300);
            }

            GC.Collect();
            GC.WaitForPendingFinalizers();

        }
        //获取任务栏
        IntPtr hTray = Form1.FindWindowA("Shell_TrayWnd", String.Empty);
        private void button2_Click(object sender, EventArgs e)
        {
            bs = 2;
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            if(TopMost==false)
            {
                TopMost = true;
                //隐藏任务栏
                Form1.ShowWindow(hTray, 0);
                //隐藏除图片框外所有空间
                button1.Visible = false;
                button2.Visible = false;
                button3.Visible = false;
                button4.Visible = false;
                button5.Visible = false;
                pictureBox2.Visible = false;
                pictureBox3.Visible = false;
                ShowCursor(false);//鼠标隐藏
                label1.Visible = false;
                FormBorderStyle = FormBorderStyle.None;
                
            }
            else
            {
                //显示任务栏
                Form1.ShowWindow(hTray, 5);
                //显示除图片框外所有空间
                button1.Visible = true;
                button2.Visible = true;
                button3.Visible = true;
                button4.Visible = true;
                button5.Visible = true;
                label1.Visible = false;
                ShowCursor(true);//鼠标显示
                pictureBox2.Visible = true;
                pictureBox3.Visible = true;
                TopMost = false;
                FormBorderStyle = FormBorderStyle.FixedToolWindow;
            }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            bs = 4;
        }

    
    }
}

标签: 游戏 外挂 源码

实例下载地址

C# 枪战通用物理外挂 源码

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警