Solved

How do i  block certain keys in Windows?

Posted on 2001-08-24
10
176 Views
Last Modified: 2010-04-06
I am looking for code examples in order to prevent the start menu from popping up when one presses the window's key or any other key combination that i don't want going thru to windows.

Rob
0
Comment
Question by:Rob Siddell
10 Comments
 
LVL 4

Expert Comment

by:albay
ID: 6423864
hi sorlus. try this.
it disables Alt+TAB and Ctrl+ESC keys.

var OldVal : Longint;
begin
   SystemParametersInfo(97, Word(True), @OldVal, 0); //disable;

change Word(True) -> Word(False) to enable keys...
end;

hope this helps
best wishes
albay
0
 
LVL 9

Expert Comment

by:ITugay
ID: 6424484
Hi sorlus,

you can register system wide hotkey with virtual code the same as key you want to lock, and then do nonthig on WM_HOTKEY message.

-----
Igor
0
 
LVL 3

Expert Comment

by:rondi
ID: 6424555
albay,

what's 97, the screen saver message ?

rondi.
0
 
LVL 2

Expert Comment

by:Tasomia
ID: 6424610
Install a message-filter hook.
0
 
LVL 7

Author Comment

by:Rob Siddell
ID: 6426040
Igor or Tasomia if you could please elaborate a little more as i would like coded examples and such

Thank you

Rob
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 9

Accepted Solution

by:
ITugay earned 200 total points
ID: 6426079
Hi Rob,

here is sample:

it allow you intercept [Alt]+[F12] and [Ctrl]+[F8] key.

----
Igor.

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
  public
    procedure WMHotKey(var Msg : TWMHotKey); message WM_HOTKEY;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

const
  AltF12_HotKey = 1110;
  CtrlF8_HotKey = 1111;

procedure TForm1.FormCreate(Sender: TObject);
begin
   RegisterHotKey(Handle,AltF12_HotKey,MOD_ALT,VK_F12);
   RegisterHotKey(Handle,CtrlF8_HotKey,MOD_CONTROL,VK_F8);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  UnregisterHotKey(Handle,AltF12_HotKey);
  UnregisterHotKey(Handle,CtrlF8_HotKey);
end;

procedure TForm1.WMHotKey(var Msg : TWMHotKey);
begin
  case MSG.HotKey of
  AltF12_HotKey:
    begin
      Application.BringToFront;
      ShowMessage('Alt-F12');
    end;
  CtrlF8_HotKey:
    begin
      Application.BringToFront;
      ShowMessage('Ctrl-F8');
    end;
  end;
end;


end.
0
 
LVL 7

Author Comment

by:Rob Siddell
ID: 6427010
Ok Igor so far the points are in you pocket but i would like to know how to apply that to other key combos like if they press the window's key or any other key i choose i would like to know how to apply it to that.

Rob
0
 
LVL 7

Author Comment

by:Rob Siddell
ID: 6430069
ok after looking at the code a bit that will do the points are yours :)

Rob
0
 
LVL 7

Author Comment

by:Rob Siddell
ID: 6430070
Thank you

Rob
0
 
LVL 9

Expert Comment

by:ITugay
ID: 6431294
thank you too :-)
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now