Solved

How do i  block certain keys in Windows?

Posted on 2001-08-24
10
178 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi cmd execution 6 60
Communication Between RC4 Delphi <-> PHP 3 113
Create a path if not exists 7 77
How to Get Images From Server using App Tethering 11 22
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…
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

776 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