Solved

How do i  block certain keys in Windows?

Posted on 2001-08-24
10
181 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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
 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses
Course of the Month3 days, 17 hours left to enroll

630 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