Solved

How do i  block certain keys in Windows?

Posted on 2001-08-24
10
177 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

920 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

17 Experts available now in Live!

Get 1:1 Help Now