Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2002.12.09;
Скачать: CL | DM;

Вниз

KeyDown   Найти похожие ветки 

 
kex86 ©   (2002-11-27 13:55) [0]

Как отлавливать нажатия клавиш, даже когда программа консольная и не активна?


 
Song ©   (2002-11-27 15:51) [1]

Консольная - нужно окно (можно скрытое) и обработчка очереди сообщений для него. После этого - RegisterHotKey()


 
kex86 ©   (2002-11-29 11:56) [2]

А если научно-популярней?


 
BoxTer ©   (2002-11-29 12:07) [3]

делай hook. Как? - не спрашивай - не скажу. Ищи на форуме - тьма..


 
asmith   (2002-11-29 14:27) [4]

Вот пример обработки консольного ввода безо всяких окон:

{$APPTYPE CONSOLE}
program ConsoleInput;

uses
Windows;

var
hInput: THandle;
arrInputRecs: array[0..9] of TInputRecord;
dwCur, dwCount: DWORD;
cCur: Char;
coorCur: TCoord;

begin
hInput := GetStdHandle(STD_INPUT_HANDLE);
while True do
begin
ReadConsoleInput(hInput, arrInputRecs[0], 10, dwCount);
for dwCur := 0 to dwCount - 1 do
case arrInputRecs[dwCur].EventType of
KEY_EVENT: with arrInputRecs[dwCur].Event.KeyEvent do
begin
cCur := AsciiChar;
if cCur = "" then
if bKeyDown then
WriteLn("Unprintable key pressed.")
else
Writeln("Unprintable key released.")
else
if bKeyDown then
WriteLn("Pressed ", cCur, " ", wRepeatCount, " times.")
else
WriteLn("Released ", cCur, " key.");
end;

{*** Delphi has renamed MOUSE_EVENT to avoid a conflict ***}
{*** with a windows function mouse_event() ***}
_MOUSE_EVENT: with arrInputRecs[dwCur].Event.MouseEvent do
begin
coorCur := dwMousePosition;
if dwEventFlags = 0 then
WriteLn("Button Pressed at ", coorCur.X, ",", coorCur.Y);
end;
end;
end;
end.



Страницы: 1 вся ветка

Текущий архив: 2002.12.09;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.02 c
1-28042
34
2002-11-30 14:11
2002.12.09
not uses StdCtrls


1-27978
jen_bond
2002-11-27 09:31
2002.12.09
индетификатор графического объекта


1-27924
KPV-10k
2002-11-28 22:52
2002.12.09
Создание директории...


3-27817
Dbrf
2002-11-20 08:54
2002.12.09
Автозаполнение


6-28183
jel
2002-10-15 17:15
2002.12.09
Окошко, не желающее становиться активным