public VirtualKeys PromptKey() { var last_key = (VirtualKeys)0; var found_key = false; var thread = new Thread(GetKey); thread.SetApartmentState(ApartmentState.STA); thread.Start(); while (!found_key) { } return(last_key); void GetKey() { var keys = (VirtualKeys[])Enum.GetValues(typeof(VirtualKeys)); while (true) { foreach (var key in keys) { try { if (WinApi.isKeyDown(key)) { found_key = true; last_key = key; return; } } catch { } } } } }
public static void Init2() { var mSize = 0; var mAddr = IntPtr.Zero; foreach (ProcessModule m in Process.GetCurrentProcess().Modules) { if (m.ModuleName == "vstdlib.dll") { mSize = m.ModuleMemorySize; mAddr = m.BaseAddress; } } var addr = WinApi.GetProcAddress(mAddr, "KeyValuesSystem"); Console.WriteLine(addr); var ctr = Marshal.GetDelegateForFunctionPointer <New>(addr); var key = ctr(addr); var key2 = ctr(addr); Console.WriteLine(key); Console.WriteLine(key2); }