добрый день - Форум Cheat-Master.ru
  • Страница 1 из 1
  • 1
Модератор форума: Sanoxxx, Alowir  
Форум » Программирование » C++/C Программирование » добрый день (насчеn warcraft 3 ( BATTLE.NET сервер))
добрый день
esen3ik Дата: Среда, 16.02.2022, 13:47 | Сообщение # 1
Новичок
Сообщений: 1
Статус: Offline
тут искал и столкнулся с горячими клавишами GlobalKeyBoardHook.cs
как все гроки знают у warcraft 3 есть хоткей именно через numpad 1 до Numpad 8
как можно через GlobalKeyBoardHook.cs передать варрафту??
тут форма
Код
gHook = new GlobalKeyboardHook();
            gHook.KeyDown += new KeyEventHandler(MyKeyDown);
            foreach (Keys key in Enum.GetValues(typeof(Keys)))
                gHook.HookedKeys.Add(key);

вот сам класс
Код
#region License_Do_Not_Remove
/*
*  Made by TheDarkJoker94.
*  Check http://thedarkjoker94.cer33.com/ for more C# Tutorials
*  and also SUBSCRIBE to my Youtube Channel http://www.youtube.com/user/TheDarkJoker094  
*  GlobalKeyboardHook is licensed under a Creative Commons Attribution 3.0 Unported License.(http://creativecommons.org/licenses/by/3.0/)
*  This means you can use this Code for whatever you want as long as you credit me! That means...
*  DO NOT REMOVE THE LINES ABOVE !!!
*/
#endregion
using System;
using System.Text;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Windows.Forms;

public class GlobalKeyboardHook
{
    [DllImport("user32.dll")]
    static extern int CallNextHookEx(IntPtr hhk, int code, int wParam, ref keyBoardHookStruct lParam);
    [DllImport("user32.dll")]
    static extern IntPtr SetWindowsHookEx(int idHook, LLKeyboardHook callback, IntPtr hInstance, uint theardID);
    [DllImport("user32.dll")]
    static extern bool UnhookWindowsHookEx(IntPtr hInstance);
    [DllImport("kernel32.dll")]
    static extern IntPtr LoadLibrary(string lpFileName);

    public delegate int LLKeyboardHook(int Code, int wParam, ref keyBoardHookStruct lParam);

    public struct keyBoardHookStruct
    {
        public int vkCode;
        public int scanCode;
        public int flags;
        public int time;
        public int dwExtraInfo;
    }

    const int WH_KEYBOARD_LL = 13;
    const int WM_KEYDOWN = 0x0100;
    const int WM_KEYUP = 0x0101;
    const int WM_SYSKEYDOWN = 0x0104;
    const int WM_SYSKEYUP = 0x0105;

    LLKeyboardHook llkh;
    public List<Keys> HookedKeys = new List<Keys>();

    IntPtr Hook = IntPtr.Zero;

    public event KeyEventHandler KeyDown;
    public event KeyEventHandler KeyUp;

    public GlobalKeyboardHook()
    {
        llkh = new LLKeyboardHook(HookProc);

    }
    ~GlobalKeyboardHook()
    { unhook(); }

    public void hook()
    {
        IntPtr hInstance = LoadLibrary("User32");
        Hook = SetWindowsHookEx(WH_KEYBOARD_LL, llkh, hInstance, 0);
    }

    public void unhook()
    {
        UnhookWindowsHookEx(Hook);
    }

    public int HookProc(int Code, int wParam, ref keyBoardHookStruct lParam)
    {
        if (Code >= 0)
        {
            Keys key = (Keys)lParam.vkCode;
            if (HookedKeys.Contains(key))
            {
                KeyEventArgs kArg = new KeyEventArgs(key);
                if ((wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN) && (KeyDown != null))
                    KeyDown(this, kArg);
                 if ((wParam == WM_KEYUP || wParam == WM_SYSKEYUP) && (KeyUp != null))
                    KeyUp(this, kArg);
                if (kArg.Handled)
                    return 1;
            }
        }
        return CallNextHookEx(Hook, Code, wParam, ref lParam);
    }

}



esen3ik
Форум » Программирование » C++/C Программирование » добрый день (насчеn warcraft 3 ( BATTLE.NET сервер))
  • Страница 1 из 1
  • 1
Поиск:
Статистика Форума
Лучшие пользователи
АК_47 [37939]

GеNius [7210]

[CM]Russel [5557]

romka619 [5008]

[CM]AGRESSOR [4638]

Snake_Firm [4452]

Сэс [4416]

Artem_Buero [4224]

[CM]Durman [3204]

[CM]Рафаэль [3079]

iMaddy [2855]

sky_Woker [2854]

-Masson- [2776]

Новые пользователи
fneeget [03:01]

maxitobrawl1234 [02:45]

DzxetAtomo [02:23]

dadadasi [01:49]

Hazratkulovabos877 [01:37]

stravenge [01:21]

sokol323223 [01:13]

Lox228_985 [00:13]

Antonaaalekhin [23:59]

efremovdanil6688 [23:37]

tanyginoleg64 [23:30]

semenevs2009 [23:28]

grisv6961 [23:23]