C
C#12mo ago
Luca

✅ I got a .net console c# project

How can I fix my erorrs?
No description
5 Replies
Luca
LucaOP12mo ago
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() { 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); } } } }
Buddy
Buddy12mo ago
What are you trying to make?
Denis
Denis12mo ago
The error is saying that you are trying to use Control which is a UI component, and those are not referenced by your project, which makes sense because this is a console application - no UI.
Angius
Angius12mo ago
Control is a class like any other
Mayor McCheese
Mayor McCheese12mo ago
aim-bot
Want results from more Discord servers?
Add your server