当前位置:  编程技术>php iis7站长之家

英雄联盟辅助lol挂机不被踢的方法(lol挂机脚本)

    来源: 互联网  发布时间:2014-10-26

    本文导语:  调用API设置鼠标位置并模拟鼠标右键让人物走动,全局钩子等 代码如下:using System;using System.Collections.Generic;using System.Linq;using System.Text; using System.Windows.Forms;using System.Runtime.InteropServices;using System.Threading; namespace LOLSetCursor{  ...

调用API设置鼠标位置并模拟鼠标右键让人物走动,全局钩子等

代码如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Threading;

namespace LOLSetCursor
{
    public class Hook
    {
        static bool IsStartThread = false;
        [StructLayout(LayoutKind.Sequential)]
        public class KeyBoardHookStruct
        {
            public int vkCode;
            public int scanCode;
            public int flags;
            public int time;
            public int dwExtraInfo;
        }
        public class SetPaint
        {
            public int X;
            public int Y;
            public int rows;
        }
        [Flags]  
        enum MouseEventFlag : uint 
        {  
            Move = 0x0001,  
            LeftDown = 0x0002,  
            LeftUp = 0x0004,  
            RightDown = 0x0008,  
            RightUp = 0x0010,  
            MiddleDown = 0x0020,  
            MiddleUp = 0x0040,  
            XDown = 0x0080,  
            XUp = 0x0100,  
            Wheel = 0x0800,  
            VirtualDesk = 0x4000,  
            Absolute = 0x8000  
        }

        //委托
        public delegate int HookProc(int nCode, int wParam, IntPtr lParam);
        static int hHook = 0;
        public const int WH_KEYBOARD_LL = 13;
        //释放按键的常量
        private const int KEYEVENTF_KEYUP = 2;
        //LowLevel键盘截获,如果是WH_KEYBOARD=2,并不能对系统键盘截取,Acrobat Reader会在你截取之前获得键盘。
        static HookProc KeyBoardHookProcedure;

        #region 调用API
        //设置钩子
        [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
        public static extern int SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr hInstance, int threadId);

        //抽调钩子
        [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
        public static extern bool UnhookWindowsHookEx(int idHook);

        //调用下一个钩子
        [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
        public static extern int CallNextHookEx(int idHook, int nCode, int wParam, IntPtr lParam);

        //获得模块句柄
        [DllImport("kernel32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
        public static extern IntPtr GetModuleHandle(string name);

        //寻找目标进程窗口
        [DllImport("user32.dll")]
        public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

        //查找子窗体
        [DllImport("user32.dll", EntryPoint = "FindWindowEX")]
        public static extern IntPtr FindWindowEx(IntPtr hwndParent,
            IntPtr hwndChildAfter, string lpszClass, string lpszWindow);


        //设置进程窗口到最前
        [DllImport("USER32.DLL")]
        public static extern bool SetForegroundWindow(IntPtr hWnd);

        //模拟键盘事件
        [DllImport("User32.dll")]
        public static extern void keybd_event(Byte bVk, Byte bScan, Int32 dwFlags, Int32 dwExtraInfo);

        //设置鼠标位置
        [DllImport("user32.dll")]
        static extern bool SetCursorPos(int X, int Y);

        //模拟鼠标按键
        [DllImport("user32.dll")]
        static extern void mouse_event(MouseEventFlag flsgs, int dx, int dy, uint data, UIntPtr extraInfo);
        #endregion
        ///
        /// 安装钩子
        ///
        public void Hook_Start()
        {
            //安装钩子
            if (hHook == 0)
            {
                KeyBoardHookProcedure = new HookProc(KeyBoatdHookProc);
                hHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyBoardHookProcedure,
                        IntPtr.Zero, 0);
                if (hHook == 0) Hook_Clear(); //hook设置失败
            }
        }

        ///
        /// 卸载Hook
        ///
        public static void Hook_Clear()
        {
            bool retKeyboard = true;
            if (hHook != 0)
            {
                retKeyboard = UnhookWindowsHookEx(hHook);
                hHook = 0;
            }
        }

        public static int KeyBoatdHookProc(int nCode, int wParam, IntPtr lParam)
        {
            Thread thread1 = new Thread(StartCursor);
            SetPaint sp = new SetPaint();
            sp.X = Screen.PrimaryScreen.Bounds.Width;
            sp.Y = Screen.PrimaryScreen.Bounds.Height;
            sp.rows = 0;
            //监控用户键盘输入
            KeyBoardHookStruct input = (KeyBoardHookStruct)Marshal.PtrToStructure(lParam, typeof(KeyBoardHookStruct));
            Keys k = (Keys)Enum.Parse(typeof(Keys), input.vkCode.ToString());

            if (input.vkCode == (int)Keys.Control || input.vkCode == (int)Keys.Shift || input.vkCode == (int)Keys.F1)
            {
                thread1.IsBackground = true;
                IsStartThread = true;
                thread1.Start(sp);
            }
            else if (input.vkCode == (int)Keys.Control || input.vkCode == (int)Keys.Shift || input.vkCode == (int)Keys.F2)
            {
                Hook_Clear();
                if (null != thread1)
                {
                    thread1.Abort();
                    IsStartThread = false;
                }
            }
            return CallNextHookEx(hHook, nCode, wParam, lParam);
        }

        static void StartCursor(object list)
        {
            SetPaint spaint = list as SetPaint;
            int sWhith = spaint.X;
            int sHeight = spaint.Y;
            int dx = 0;
            int dy = 0;

            while (IsStartThread)
            {               
                if (3 < spaint.rows) spaint.rows = 0;
                switch (spaint.rows)
                {
                    case 0:
                        dx = sWhith  / 3;
                        dy = sHeight / 3;
                        break;
                    case 1:
                        dy = dy * 2;
                        break;
                    case 2:
                        dx = dx * 2;
                        break;
                    case 3:
                        dy = dy / 2;
                        break;
                    default:
                        break;
                }
                spaint.rows++;
                //MessageBox.Show("width:"+sWhith+" height:"+sHeight+ " X:" + dx + " Y:" + dy+" rows:"+spaint.rows);
                SetCursorPos(dx, dy);
                mouse_event(MouseEventFlag.RightDown | MouseEventFlag.RightUp, 0, 0, 0, UIntPtr.Zero);
                Thread.Sleep(10000);
            }
        }
    }
}


    
 
 
 
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐
  • 英雄城市扩展工具 HeroStats
  • 魔法门英雄无敌引擎 OpenHoMM
  • 英雄,救命啦!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  • 我很菜,Ghost怎么用~???人道主义者,英雄主义者! 进来得分!!!!
  • 英雄救我
  • 高分赠英雄:如何改变JScrollPane的滚动条宽度?
  • 高分赠英雄!请问怎样才能获取主机名??
  • 我准备学习Java,如何配置Java环境?拜托各位英雄!!!
  • 欢迎个路英雄豪杰来参加讨论
  • 英雄在哪儿?请问如何让WEBLOGIC6.1自带的例子程序跑起来???
  • 英雄在哪儿?一个关于weblogic的小问题!60分!
  • 急求 unix 与linux在文件存储上 和数据存储上有哪些不同 希望各路英雄帮忙
  • 各位达人,英雄,小弟求 turbolinux 10教程一份,越全越好 100分相送,顶者有分
  • 广发英雄帖!!!!!!!!!如有能答者外300分!!!!!!!!(应该是很简单的噢!)
  • 想不到一个小问题也能憋倒英雄汉(就算我是吧,呵呵!)高手欢迎!
  • 一个提了多次但没解决的问题Unable to load class LanguageBean,哪位英雄能搞顶啊
  • 那位英雄有EJB的例子什么的!
  • JRUN和IIS4.0连接的问题。英雄救命!!
  • 请问路人甲大佬:创建weblogic连接池为什么出例外?------欢乐英雄
  • 超级菜鸟大发英雄贴,放分请较如何学习LINUX...............


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,,E-mail:www_#163.com(请将#改为@)

    浙ICP备11055608号-3