Board index » delphi » Alt+anykey help...heres an example and ideas?

Alt+anykey help...heres an example and ideas?

Hello!

    A few days ago I asked about how to make Alt+anykey do something
specific I want. Here is an example of what I want it to do. I've messed
around with the code, but I can't get it to work when I try and input it
into the program I want it in! If someone could look at it and tell me what
code I actually need, or show me the sytax of another way I can do it, it
would be greatly appreciated: I don't want it to repeat or anything. Just so
that if someone presses Alt+F1 or Alt+Fwhatever it will perform something
specific.

    Heres the sample example I found. What code do I need to put into my
program I want it in?

Uses Crt;
var ch: char;

begin
TextMode (co80);
TextColor (15);
TextBackGround (1);
ClrScr;
WriteLn ('Press ESC to quit!');
Repeat

ch := ReadKey;

 If ch = #0 Then
    Begin

     Ch := readKey;

       If ch = #104 Then WriteLn ('Alt+F1');
       If ch = #105 Then WriteLn ('Alt+F2');
       If ch = #106 Then WriteLn ('Alt+F3');
       If ch = #107 Then WriteLn ('Alt+F4');
       If ch = #108 Then WriteLn ('Alt+F5');
       If ch = #109 Then WriteLn ('Alt+F6');
       If ch = #110 Then WriteLn ('Alt+F7');
       If ch = #111 Then WriteLn ('Alt+F8');
       If ch = #112 Then WriteLn ('Alt+F9');
       If ch = #113 Then WriteLn ('Alt+F10');

       ch := #0;

    End;

 If (ch <>#0) and (ch <> #8) and (ch <> #13) and (ch <> #32) Then WriteLn
(ch);
Until ch = #27;  {Esc pressed?}
 WriteLn ('Esc');
end.

    Thanks!!!

    :) Evan Anderson

 

Re:Alt+anykey help...heres an example and ideas?


Quote
Evan Anderson wrote in message <8eaimn$...@news.dx.net>...
>Hello!

>    A few days ago I asked about how to make Alt+anykey do something
>specific I want. Here is an example of what I want it to do. I've messed
>around with the code, but I can't get it to work when I try and input it
>into the program I want it in! If someone could look at it and tell me what
>code I actually need, or show me the sytax of another way I can do it, it
>would be greatly appreciated: I don't want it to repeat or anything. Just
so
>that if someone presses Alt+F1 or Alt+Fwhatever it will perform something
>specific.

>    Heres the sample example I found. What code do I need to put into my
>program I want it in?

>Uses Crt;
>var ch: char;

>begin
>TextMode (co80);
>TextColor (15);
>TextBackGround (1);
>ClrScr;
>WriteLn ('Press ESC to quit!');
>Repeat

>ch := ReadKey;

> If ch = #0 Then
>    Begin

>     Ch := readKey;

>       If ch = #104 Then WriteLn ('Alt+F1');
>       If ch = #105 Then WriteLn ('Alt+F2');
>       If ch = #106 Then WriteLn ('Alt+F3');
>       If ch = #107 Then WriteLn ('Alt+F4');
>       If ch = #108 Then WriteLn ('Alt+F5');
>       If ch = #109 Then WriteLn ('Alt+F6');
>       If ch = #110 Then WriteLn ('Alt+F7');
>       If ch = #111 Then WriteLn ('Alt+F8');
>       If ch = #112 Then WriteLn ('Alt+F9');
>       If ch = #113 Then WriteLn ('Alt+F10');

>       ch := #0;

>    End;

> If (ch <>#0) and (ch <> #8) and (ch <> #13) and (ch <> #32) Then WriteLn
>(ch);
>Until ch = #27;  {Esc pressed?}
> WriteLn ('Esc');
>end.

>    Thanks!!!

>    :) Evan Anderson

Evan,

To get this program to do something useful you change
(as an example) the line
If ch = #104 Then WriteLn ('Alt+F1');
to something like
If ch = #104 Then DoSomethingUseful;
Where DoSomethingUseful is your own Procedure.

In order to be successful at writing a useful program you
must acquire a good understanding of what each line of
code does. Just copying somebody's code and lopping
off pieces at random will never work.

KlausL

Other Threads