I'm having a bit of confusion regarding my post here. How to get combination key about 5-10 keys? I'm intended to capture "!qaz$esz" key without double quotes.
My application is a full screen application that prevent access to desktop before entering a right key to enable desktop access. I have kill explorer.exe and disable the Task Manager when the program start and enable it back after combination password is correct:-
private void Window_Loaded(object sender, RoutedEventArgs e)
{
/**
* 1. KILL EXPLORER
* 2. DISABLE KEY TO TERMINATE
* = Alt + F4
* = Win + Tab
* = Win + D
* = etc
* 3. ACCEPT SPECIFIC KEY ONLY TO UNLOCK TO MINIMIZE AND SET TOP = FALSE
*
*
* **/
RegistryKey regkey = SetKey(TaskManager.Disabled);
regkey.Close();
}
public static RegistryKey SetKey(TaskManager command)
{
RegistryKey mKey;
string subKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System";
mKey = Registry.CurrentUser.CreateSubKey(subKey);
switch (command)
{
case TaskManager.Enabled:
mKey.SetValue("DisableTaskMgr", 0);
break;
case TaskManager.Disabled:
mKey.SetValue("DisableTaskMgr", 1);
break;
}
return mKey;
}
But something must be lack on my code where I cannot detect the combination code that more to password.
Below code are what I'm testing to see if my entered key is captured.
public MainWindow()
{
InitializeComponent();
AddHandler(Keyboard.KeyDownEvent, (KeyEventHandler)HandleKeyDownEvent);
}
private void HandleKeyDownEvent(object sender, KeyEventArgs e)
{
if (e.Key == Key.Tab && (Keyboard.Modifiers & (ModifierKeys.Control | ModifierKeys.Shift)) == (ModifierKeys.Control | ModifierKeys.Shift))
{
MessageBox.Show("CTRL + SHIFT + TAB trapped"); // Working
}
if (e.Key == Key.Tab && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
{
MessageBox.Show("CTRL + TAB trapped"); // Working
}
if (e.Key == Key.F4 && Keyboard.Modifiers.HasFlag(ModifierKeys.Alt))
{
MessageBox.Show("ALT + F4 trapped"); // Not working
}
if (e.Key == Key.D && Keyboard.Modifiers.HasFlag(ModifierKeys.Windows))
{
MessageBox.Show("WIN + D trapped"); // Not working
}
if ((Keyboard.IsKeyDown(Key.LeftShift) && e.Key == Key.D1) && e.Key ==Key.Q && e.Key == Key.A && e.Key == Key.Z && e.Key == Key.D4 && e.Key == Key.E && e.Key == Key.S && e.Key == Key.Z)
{
MessageBox.Show("COMBOKEY"); // Not working
// RUN EXPLORER
// ENABLE TASK MANAGER
}
}
What is not settle is WINLOGO + D, ALT + TAB, ALT + F4 and LONG COMBINATION KEY.
I have try some of the code from here:-
I have see some discussion/posting/article on writing to LowLevelAPI. I'm not familiar accessing low level API and apply it on WPF application:-