public void OnLoad(object sender, EventArgs e) { Thread posThread = new Thread(() => { int lx = 0; int ly = 0; while (true) { fixSizeDel del = new fixSizeDel(() => { MCM.RECT mcRect = MCM.getMinecraftRect(); x = mcRect.Left + 16; y = mcRect.Top + 30; width = mcRect.Right; height = mcRect.Bottom; if (x != lx || y != ly) { lx = x; ly = y; ui.Refresh(); } ui.TopMost = MCM.isMinecraftFocused(); }); ui.Invoke(del); } }); posThread.Start(); Console.WriteLine("Tab GUI overlay loop started!"); }
public OverlayHost() { this.AutoScaleMode = AutoScaleMode.None; ui = this; this.TopMost = true; Console.WriteLine("Starting TabGUI."); this.FormBorderStyle = FormBorderStyle.None; this.TransparencyKey = Color.FromArgb(77, 77, 77); this.BackColor = this.TransparencyKey; this.Location = new Point(0, 0); this.DoubleBuffered = true; this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); hWnd = this.Handle; overDel = new WinEventDelegate(adjustOverlay); mouseMove = new LowLevelMouseProc(OnMouseMove); SetWinEventHook((uint)SWEH_Events.EVENT_OBJECT_LOCATIONCHANGE, (uint)SWEH_Events.EVENT_OBJECT_LOCATIONCHANGE, IntPtr.Zero, overDel, (uint)MCM.mcWinProcId, GetWindowThreadProcessId(MCM.mcWinHandle, IntPtr.Zero), (uint)SWEH_dwFlags.WINEVENT_OUTOFCONTEXT | (uint)SWEH_dwFlags.WINEVENT_SKIPOWNPROCESS | (uint)SWEH_dwFlags.WINEVENT_SKIPOWNTHREAD); SetWinEventHook((uint)SWEH_Events.EVENT_SYSTEM_FOREGROUND, (uint)SWEH_Events.EVENT_SYSTEM_FOREGROUND, IntPtr.Zero, overDel, 0, 0, (uint)SWEH_dwFlags.WINEVENT_OUTOFCONTEXT | (uint)SWEH_dwFlags.WINEVENT_SKIPOWNPROCESS | (uint)SWEH_dwFlags.WINEVENT_SKIPOWNTHREAD); //mouseHookID= SetWindowsHookEx(14, mouseMove, GetModuleHandle("user32"), 0); UInt64 initialStyle = GetWindowLong(this.Handle, -20); SetWindowLong(this.Handle, -20, initialStyle | 0x80000 | 0x20); Timer rainbowTimer = new Timer(); float rainbowTick = 0f; rainbowTimer.Tick += (object segfsjn, EventArgs gfdd) => { if (MCM.isMinecraftFocused()) { rainbowTick += 0.005f; rainbow = new SolidBrush(Rainbow(rainbowTick)); this.Invalidate(); } }; rainbowTimer.Interval = 10; rainbowTimer.Stop(); if (postOverlayLoad != null) { postOverlayLoad.Invoke(this, new EventArgs()); } Paint += OverlayHost_Paint; }
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"); }