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" ).
albertiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.