[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 344
  • Last Modified:

Lock a Keyboard?

Is it possible to lock the keyboard under win98. I want to make a prog which can control the keyboard ( "if that happened, the keyboard (or win98)does not recognize the user" ).
0
alberti
Asked:
alberti
  • 18
  • 9
  • 7
  • +1
1 Solution
 
intheCommented:
Hi
sure actually you generally need to write a hook for this but heres an easy way to disable and re-enable the keyboard :

procedure TForm1.Button1Click(Sender: TObject);
//to disable keyboard
begin
 Asm
  in  al,21h
  or al,00000010b
  out 21h,al
 end;
end;

procedure TForm1.Button2Click(Sender: TObject);
//to re-enable keyboard
begin
 Asm
  in  al,21h
  mov al,0
  out 21h,al
 end;
end;

Regards Barry
0
 
albertiAuthor Commented:
Adjusted points to 100
0
 
albertiAuthor Commented:
What do you mean with easy, does it work or not? I want to combine this with an chipcard-keyboard.
And it is important that the user does not be able to do anything.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
intheCommented:
Hi
i just mean its easier than writing a hook and yes it works well ...
0
 
craig_capelCommented:
Hi barry... a slightly easier way (different varation of yours)

asm
  in al,21h;
  or al,2;
  out 21h,al;
end;

 Asm
                     in  al,21h
                     mov al,0
                     out 21h,al
  end;

Re able..... Learned that trick in dos pascal... also why have they stopped port[$60]? why when in al,60h works great?
0
 
albertiAuthor Commented:
thanx a lot it works i will give you the points can we communicate in irc or something like this or via email i´m online the whole day

alberti@dig-it-computer.net
0
 
albertiAuthor Commented:
Adjusted points to 150
0
 
albertiAuthor Commented:
I want to do the same with the mouse ;-)
0
 
albertiAuthor Commented:
I want to do the same with the mouse ;-)
0
 
craig_capelCommented:
same with the mouse? how do you mean?
0
 
albertiAuthor Commented:
Adjusted points to 200
0
 
albertiAuthor Commented:
What is about Strg + Alt + Entf, does it not work to deaktivate this.

Please answer its very important for me that i get an fast answer.

What is about the mouse?

Thanx a lot.
0
 
albertiAuthor Commented:
It has to be work under Win98.

Thanx
0
 
albertiAuthor Commented:
I want to deaktivate (input devices) mouse and keyboard.

Thanx craig

is it possible to meet you in a chat
0
 
intheCommented:
to deactivate the mouse call:

showcursor(false)

and to activate it again do:

showcursor(true);
0
 
intheCommented:
>>What is about Strg + Alt + Entf, does >>it not work to deaktivate this.

yes it(the code i put) will deactivate all keys.



0
 
intheCommented:
and yes this is too work under win98
0
 
albertiAuthor Commented:
showcursor is not present in delphi 4, ?? is there a possibility to deactivate the mouse like the keyboard with assembler ??
0
 
albertiAuthor Commented:
Adjusted points to 300
0
 
albertiAuthor Commented:
i test the deaktivation (keyboard) under win98, but if i press strg+alt+entf the taskmanager comes up and if i press strg+alt+entf a second time the pc reboot.

thanx for your time
0
 
topkapiCommented:
the structure of the operating system prevents a single process from gaining control to the whole pc. so you may disable input to your process, but not to that of others, including the os itself.
0
 
craig_capelCommented:
no.... yes, Barry (inthe) deserves the points not me.... yes i am with yahoo chat... just arrange the time and what about you Barry?
0
 
albertiAuthor Commented:
now? IRC ? channel #alberti ?
0
 
craig_capelCommented:
dont use IRC or ICQ

Just Yhcat, Ymessenger... www.yahoo.com  just get yahoo messenger
0
 
albertiAuthor Commented:
got it alberti_johannes is my ID
yahoo messenger
0
 
intheCommented:
>>showcursor is not present in delphi 4,


er.. yes it is i paste a complete example in a while(when i get home) to detivate the keyboard and mouse,i know it works on win98 as i tested it,
 
0
 
craig_capelCommented:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
showcursor(false);
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
showcursor(true);
end;

end.

works fine, the assembler code works good too.....
0
 
intheCommented:
Hi
yep you got it (nearly ;-)

im sorry alberti you were right we need to also add something to disable the system keys like alt/tab and crtl/esc and crtl-alt-del
(in your language Strg + Alt + Entf)
you must add the systemparametersinfo() call .
note also to completely make it work so no input by keyboard or mouse works is you should have a form1 and have your main program on form2,then on form1.activate event call
form1.hide;
form2.showmodal;
 this stops the mouse from being able to do anything with the background apps because it is on a modal form.
please try it but please do note that if you do this to disable everything ,how is the form going to be able to be closed etc ?
how to give control back to system?
are you using a timer maybe?


unit Unit2;

interface

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

type
  TForm1 = class(TForm)
   procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
var
  L : LongInt;
begin
  SystemParametersInfo (97, Word (True), @L, 0);
  showcursor(false);
  Asm
    in  al,21h
    or al,00000010b
 out 21h,al
End;
  end;

procedure TForm1.FormDestroy(Sender: TObject);
var
  L : LongInt;
begin
  SystemParametersInfo (97, Word (False), @L, 0);
  showcursor(true);
  Asm
    in  al,21h
    mov al,0
 out 21h,al
End;
  end;

end.



Regards Barry
0
 
craig_capelCommented:
or... systemparametersinfo(spi_screensaverrunning,1,nil,0);


What Barry, has done has to trick windows into thinking there is a screen saver so the Special keys do not work..... if you were wondering.....


 systemparametersinfo(spi_screensaverrunning,0,nil,0);  to disable it.... it says in the win32 help you should not use this!....
0
 
craig_capelCommented:
or... systemparametersinfo(spi_screensaverrunning,1,nil,0);


What Barry has done is; tricked windows into thinking there is a screen saver going on so the Special keys do not work..... if you were wondering.....


 systemparametersinfo(spi_screensaverrunning,0,nil,0);  to disable it.... it says in the win32 help you should not use this!....

P.S once you disabled both Keyboard And Mouse..... What you planning on doing?
0
 
albertiAuthor Commented:
Works fine thanks
0
 
craig_capelCommented:
ah.... theres a bug in EE!!!!!!
0
 
albertiAuthor Commented:
which one?? Thanx
0
 
craig_capelCommented:
Which one? Either... Which ever you can read.... but as long as Barry gets the points, it dont matter which...
0
 
albertiAuthor Commented:
i will ask a new question.

Q.10288842 is the new one.

Thanx
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 18
  • 9
  • 7
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now