英雄聯(lián)盟輔助lol掛機(jī)不被踢的方法(lol掛機(jī)腳本)
調(diào)用API設(shè)置鼠標(biāo)位置并模擬鼠標(biāo)右鍵讓人物走動(dòng),全局鉤子等
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,并不能對(duì)系統(tǒng)鍵盤截取,Acrobat Reader會(huì)在你截取之前獲得鍵盤。
static HookProc KeyBoardHookProcedure;
#region 調(diào)用API
//設(shè)置鉤子
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern int SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr hInstance, int threadId);
//抽調(diào)鉤子
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern bool UnhookWindowsHookEx(int idHook);
//調(diào)用下一個(gè)鉤子
[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);
//尋找目標(biāo)進(jìn)程窗口
[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);
//設(shè)置進(jìn)程窗口到最前
[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);
//設(shè)置鼠標(biāo)位置
[DllImport("user32.dll")]
static extern bool SetCursorPos(int X, int Y);
//模擬鼠標(biāo)按鍵
[DllImport("user32.dll")]
static extern void mouse_event(MouseEventFlag flsgs, int dx, int dy, uint data, UIntPtr extraInfo);
#endregion
/// <summary>
/// 安裝鉤子
/// </summary>
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設(shè)置失敗
}
}
/// <summary>
/// 卸載Hook
/// </summary>
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;
//監(jiān)控用戶鍵盤輸入
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);
}
}
}
}
相關(guān)文章
C#中數(shù)組、ArrayList和List三者的區(qū)別詳解及實(shí)例
這篇文章主要介紹了C#中數(shù)組、ArrayList和List三者的區(qū)別詳解及實(shí)例的相關(guān)資料,需要的朋友可以參考下2016-12-12DataGridView自動(dòng)設(shè)定列寬和行高
這篇文章介紹了DataGridView自動(dòng)設(shè)定列寬和行高的方法,對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2022-02-02c# 實(shí)現(xiàn)MD5,SHA1,SHA256,SHA512等常用加密算法源代碼
c# 如何實(shí)現(xiàn)MD5,SHA1,SHA256,SHA512等常用加密算法,需要的朋友可以參考下2012-12-12C# 實(shí)現(xiàn)dataGridView選中一行右鍵出現(xiàn)菜單的示例代碼
這篇文章主要介紹了C# 實(shí)現(xiàn)dataGridView選中一行右鍵出現(xiàn)菜單,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-09-09C#訪問(wèn)及調(diào)用類中私有成員與方法示例代碼
訪問(wèn)一個(gè)類的私有成員不是什么好做法,大家也都知道私有成員在外部是不能被訪問(wèn)的,這篇文章主要給大家介紹了關(guān)于C#訪問(wèn)及調(diào)用類中私有成員與方法的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),需要的朋友可以參考下2018-06-06C#面向?qū)ο笤O(shè)計(jì)原則之里氏替換原則
這篇文章介紹了C#面向?qū)ο笤O(shè)計(jì)原則之里氏替換原則,對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2022-03-03C#使用自定義的泛型節(jié)點(diǎn)類實(shí)現(xiàn)二叉樹(shù)類
這篇文章主要為大家詳細(xì)介紹了C#如何使用自定義的泛型節(jié)點(diǎn)類 Node<T>實(shí)現(xiàn)二叉樹(shù)類BinaryTree<T>及其方法,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2024-03-03C#實(shí)現(xiàn)更快讀寫超級(jí)大文件的方法詳解
這篇文章主要來(lái)和大家介紹一下C#實(shí)現(xiàn)更快讀寫超級(jí)大文件的方法,文中的示例代碼簡(jiǎn)潔易懂,對(duì)我們深入了解C#有一定的幫助,快跟隨小編一起學(xué)習(xí)起來(lái)吧2023-06-06