Luca
Luca
CC#
Created by Luca on 12/13/2023 in #help
✅ I got a .net console c# project
Console.Clear(); Console.WriteLine("==== Button Functionality ===="); Console.WriteLine("Press 'E' and then click or hold left mouse button."); Console.WriteLine("Press 'B' to go back to the main menu."); while (true) { if (Console.KeyAvailable) { ConsoleKeyInfo keyInfo = Console.ReadKey(true); if (keyInfo.Key == ConsoleKey.E) { Console.WriteLine("E key pressed. Now click or hold left mouse button."); WaitForMouseRelease(); Console.WriteLine("Mouse button released. Simulating 'E' key press."); keybd_event(VK_E, 0, 0, UIntPtr.Zero); keybd_event(VK_E, 0, KEYEVENTF_KEYUP, UIntPtr.Zero); break; } else if (keyInfo.Key == ConsoleKey.B) { break; } } } } static void WaitForMouseRelease() { while ((Control.MouseButtons & MouseButtons.Left) != 0) { Thread.Sleep(10); } } } }
7 replies
CC#
Created by Luca on 12/13/2023 in #help
✅ I got a .net console c# project
using System; using System.Runtime.InteropServices; using System.Threading; using System.Windows.Forms; namespace ConsoleAppWithModernUI { class Program { [DllImport("user32.dll", SetLastError = true)] static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo); private const byte VK_E = 0x45; // Virtual key code for the 'E' key private const uint KEYEVENTF_KEYUP = 0x0002; // Key up flag static void Main(string[] args) { Console.Title = "Modern UI Console App"; while (true) { Console.Clear(); Console.WriteLine("======== Modern UI Console App ========"); Console.WriteLine("1. Press E after clicking the button"); Console.WriteLine("2. Exit"); Console.Write("Select an option: "); string userInput = Console.ReadLine(); switch (userInput) { case "1": RunEButtonFunctionality(); break; case "2": Environment.Exit(0); break; default: Console.WriteLine("Invalid option. Please try again."); break; } } } static void RunEButtonFunctionality() {
7 replies