How to disable key combination in windows by registry

8
"https://i.stack.imgur.com/zc21b.png"> , and ESC by Windows 7 and 8 registry? >

I can disable the Esc key but not the rest, here is an example of the key Esc :

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,5b,e0,38,00,00,00,00,00
    
asked by anonymous 15.05.2014 / 22:42

2 answers

6

In response to another pergunta .

One way to achieve this by programming in Delphi is to use Hooks (#

Consider the following example ( tested in Delphi XE4 , Visual application ):

{ Anula o funcionamento da tecla Esc }
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, 
  System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs;

  type
  tagKBDLLHOOKSTRUCT = record
  vkCode: DWord;
  scanCode: DWord;
  flags: DWord;
  time: DWord;
  dwExtraInfo: PDWord;
  end;
  TKBDLLHOOKSTRUCT = tagKBDLLHOOKSTRUCT;
  PKBDLLHOOKSTRUCT = ^TKBDLLHOOKSTRUCT;

type
  TForm1 = class(TForm)
    procedure FormDestroy(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  khk: HHOOK;

implementation

{$R *.dfm}

function KeyboardHookProc(Code: Integer; wParam : WPARAM; lParam : LPARAM): NativeInt; stdcall;
var
p:PKBDLLHOOKSTRUCT;
begin
p := PKBDLLHOOKSTRUCT(lParam);
if (Code = HC_ACTION) and (wParam = $0100) then
if (p.vkCode = VK_ESCAPE) then
Result := 1 else Result := CallNextHookEx(0, Code, wParam, lParam);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
khk := SetWindowsHookEx(13, KeyboardHookProc, hInstance, 0);
if khk = 0  then ShowMessage('Error on start hook')
else ShowMessage('Hook started');
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
UnhookWindowsHookEx(khk);
end;

end.

This will install a ) on the system to intercept the Esc key, so we can change its behavior, such as abort.

Now another example ( Console Application ) that aborts the operation of the key combination Alt + Tab .

 
{ Anula o funcionamento da combinação de teclas Alt + Tab }
program Project2;

{$APPTYPE CONSOLE}

uses
  Windows;

type
  tagKBDLLHOOKSTRUCT = record
  vkCode: DWord;
  scanCode: DWord;
  flags: DWord;
  time: DWord;
  dwExtraInfo: PDWord;
  end;
  TKBDLLHOOKSTRUCT = tagKBDLLHOOKSTRUCT;
  PKBDLLHOOKSTRUCT = ^TKBDLLHOOKSTRUCT;

var
  khk: HHOOK;
  MSG: tmsg;

function KeyboardHookProc(Code: Integer; wParam : WPARAM; lParam : LPARAM): NativeInt; stdcall;
var
  p:PKBDLLHOOKSTRUCT;
begin
p := PKBDLLHOOKSTRUCT(lParam);
if (Code = HC_ACTION) and (wParam = $0100) then
if (p.vkCode = VK_LMENU) or (p.flags = VK_TAB)  then
Result := 1 else Result := CallNextHookEx(0, Code, wParam, lParam);
end;

begin
khk := SetWindowsHookEx(13, KeyboardHookProc, hInstance, 0);
if khk = 0  then 
  writeln('Error on start hook') 
else 
  writeln('Hook started');

while GetMessage(MSG, 0, 0, 0) do begin
  TranslateMessage(MSG);
  DispatchMessage(MSG);
end;

UnhookWindowsHookEx(khk);
end.

Hooks (< in> Virtual-Key Codes ) you will find the key code.

    
16.05.2014 / 20:13
2

I found a solution!

Disable Esc and :

WindowsRegistryEditorVersion5.00[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\KeyboardLayout]"Scancode Map"=hex:00,00,00,00,00,00,00,00,05,00,00,00,00,00,5B,E0,00,00,5C,E0,00,00,5D,E0,00,00,01,00,00,00,00,00
kbd>:

  • Type gpedit.msc in the Windows Run box and type Enter .
  • Select User Configuration - Administrative - Templates - System - Ctrl-Alt-Del Options .
  • Double-click Remove Change Password , Remove Computer Lock , Remove Task Manager and Remove Logoff and select Enable and then Ok .
  • Select Computer Configuration - Administrative Templates - System - Logon .
  • In the right pane, double-click Hide for quick user switching.
  • Select Enabled and click OK .
  • 16.05.2014 / 00:48