Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How do i  block certain keys in Windows?

Posted on 2001-08-24
10
Medium Priority
?
183 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

705 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