public KeybindHandler()
        {
            handler = this;
            Console.WriteLine("Starting key thread");
            Thread keyThread = new Thread(() =>
            {
                while (true)
                {
                    for (char c = (char)0; c < 0xFF; c++)
                    {
                        noKey[c] = true;
                        if (GetAsyncKeyState(c))
                        {
                            noKey[c] = false;
                            if (keyBuffs[c] > 0)
                            {
                                continue;
                            }
                            keyBuffs[c]++;
                            TabUI.ui.Invalidate();
                            clientKeyEvent.Invoke(this, new ClientKeyEvent(c));
                        }
                        if (noKey[c])
                        {
                            keyBuffs[c] = 0;
                        }
                    }
                    Thread.Sleep(10);
                }
            });

            keyThread.Start();
            Console.WriteLine("key thread started");
        }
        public KeybindHandler()
        {
            handler = this;
            Console.WriteLine("Starting key thread");
            for (char c = (char)0; c < 0xFF; c++)
            {
                downBuffs.Add(c, 0);
                noKey.Add(c, true);
            }
            for (char c = (char)0; c < 0xFF; c++)
            {
                releaseBuffs.Add(c, 0);
                yesKey.Add(c, true);
            }
            Program.mainLoop += (object sen, EventArgs e) =>
            {
                for (char c = (char)0; c < 0xFF; c++)
                {
                    noKey[c]  = true;
                    yesKey[c] = false;
                    if (SDK.instance.GetKeyState(c) || (c < 0x7 && SDK.instance.GetMouseState(c)))
                    {
                        if (clientKeyHeldEvent != null)
                        {
                            clientKeyHeldEvent.Invoke(this, new clientKeyEvent(c));
                        }
                        noKey[c] = false;
                        if (downBuffs[c] > 0)
                        {
                            continue;
                        }
                        downBuffs[c]++;
                        OverlayHost.ui.Invalidate();
                        try
                        {
                            if (clientKeyDownEvent != null)
                            {
                                clientKeyDownEvent.Invoke(this, new clientKeyEvent(c));
                            }
                        }
                        catch (Exception) { }
                    }
                    else
                    {
                        yesKey[c] = true;
                        if (releaseBuffs[c] > 0)
                        {
                            continue;
                        }
                        releaseBuffs[c]++;
                        OverlayHost.ui.Invalidate();
                        if (clientKeyUpEvent != null)
                        {
                            try
                            {
                                clientKeyUpEvent.Invoke(this, new clientKeyEvent(c));
                            }
                            catch (Exception) { }
                        }
                    }
                    if (noKey[c])
                    {
                        downBuffs[c] = 0;
                    }
                    if (!yesKey[c])
                    {
                        releaseBuffs[c] = 0;
                    }
                }
            };

            clientKeyDownEvent += dispatchKeybinds;
            Console.WriteLine("key shit started");
        }
Beispiel #3
0
        public KeybindHandler()
        {
            handler = this;
            Console.WriteLine("Starting key thread");
            for (char c = (char)0; c < 0xFF; c++)
            {
                downBuffs.Add(c, 0);
                noKey.Add(c, true);
            }
            for (char c = (char)0; c < 0xFF; c++)
            {
                releaseBuffs.Add(c, 0);
                yesKey.Add(c, true);
            }
            Program.mainLoop += (object sen, EventArgs e) =>
            {
                if (MCM.isMinecraftFocused())
                {
                    for (char c = (char)0; c < 0xFF; c++)
                    {
                        noKey[c]  = true;
                        yesKey[c] = false;
                        if (MCM.GetAsyncKeyState(c))
                        {
                            if (clientKeyHeldEvent != null)
                            {
                                clientKeyHeldEvent.Invoke(this, new clientKeyEvent(c));
                            }
                            noKey[c] = false;
                            if (downBuffs[c] > 0)
                            {
                                continue;
                            }
                            downBuffs[c]++;
                            OverlayHost.ui.Invalidate();
                            try
                            {
                                if (clientKeyDownEvent != null)
                                {
                                    clientKeyDownEvent.Invoke(this, new clientKeyEvent(c));
                                    //DBG.Debug("Dispatched key down [" + c.ToString() + "]");
                                }
                            }
                            catch (Exception) { }
                        }
                        else
                        {
                            yesKey[c] = true;
                            if (releaseBuffs[c] > 0)
                            {
                                continue;
                            }
                            releaseBuffs[c]++;
                            OverlayHost.ui.Invalidate();
                            if (clientKeyUpEvent != null)
                            {
                                try
                                {
                                    clientKeyUpEvent.Invoke(this, new clientKeyEvent(c));
                                    //DBG.Debug("Dispatched key up [" + c.ToString() + "]");
                                }
                                catch (Exception) { }
                            }
                        }
                        if (noKey[c])
                        {
                            downBuffs[c] = 0;
                        }
                        if (!yesKey[c])
                        {
                            releaseBuffs[c] = 0;
                        }
                    }
                }
            };

            clientKeyDownEvent += dispatchKeybinds;
            Console.WriteLine("key shit started");
        }