Does anyone know what's up with the Pause key in Windows? Is there some way to tell if it was pushed?
I have a need for the user to pause execution of my Freepascal program, I have a pause key.. seems like there should be some way to use it.
James

Mailing lists / fpc-pascal / 2023-04
11 messages · 9 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Does anyone know what's up with the Pause key in Windows? Is there some way to tell if it was pushed?
I have a need for the user to pause execution of my Freepascal program, I have a pause key.. seems like there should be some way to use it.
James
James Richters wroteDoes anyone know what's up with the Pause key in Windows? Is there some way to tell if it was pushed?
Hi James,
//____________________________
Tform.FormKeyDown(Sender:TObject; var Key:Word; Shift:TShiftState);
begin
if Key=VK_PAUSE then
begin
do_something;
Key:=0;
end;
end;
//_____________________________cheers,
Martin.
Does anyone know what's up with the Pause key in Windows? Is there some way to tell if it…
I know of no way to obtain the pause key status under windows. I can get the scroll lock status, but not the pause key, never did figure that one out. Windows uses it though, I don't know if it's a standard thing, or something I have installed, (though if it is an installed program, I haven't a clue which one). When I hit the pause key, it brings up the screen snippet dialog.
Since the scroll lock key is readable though, you could use that for a pause function. Almost nobody uses that key, so interference should be minimal.
I think any function where you provide the key code value and obtain the status of the key should work.
From the Linux Documenation Project:
The two keys
PrintScrn/SysRq and Pause/Break are special in that they have two keycodes: the former has keycode 84 when Alt is pressed simultaneously, and keycode 99 otherwise; the latter has keycode 101 when Ctrl is pressed simultaneously, and keycode 119 otherwise.
//____________________________ Tform.FormKeyDown(Sender:TObject; var Key:Word;…
Yes. And I tested the Pause/Break key in the Lazarus program CudaText. I can assign the key to any action (in the Command Palette, press F9), and it works then. E.g. action "toggle statusbar" works then.
ShortcutToText() for this key shows "Break".
Alex
//____________________________ Tform.FormKeyDown(Sender:TObject; var Key:Word;…
... I wouldn't be surprised that James's program is a console one, not using TForm nor any windows message loop to process WM_ messages, but I may be wrong.
It can be more tricky in this case.
I know of no way to obtain the pause key status under windows. I can get the scroll…
Travis Siegel wroteI know of no way to obtain the pause key status under windows. I can
Considering, that only Caps Lock, Scroll Lock and Num Lock keys have status lights on keyboard I would suspect, that there is not such thing as Pause status on PC keyboard.
... I wouldn't be surprised that James's program is a console one, not using TForm nor…
> ... I wouldn't be surprised that James's program is a console one, not
using TForm nor any windows message loop to process WM_ messages, but I may be wrong.
Indeed you are correct, it is a very extensive console application which uses PTCGraph. I do accept keyboard input on both the Console window and the PTCGraph window. I have a keytest function that I can run in my application that reports the returned keycodes every time a key is pressed in either window, but pushing the Pause key is the same as doing nothing, it does not trigger keypressed.
However I was already doing:
isShiftDown := GetAsyncKeyState(VK_Shift);
because I want to know if shift was held down, I can't rely on just if I get a capital or lower case letter because caps lock might be on, and I want my key command to work the same regardless of caps lock.
So I just added a new function that does:
isPausePushed := GetAsyncKeyState(VK_PAUSE);and check the pause key every time I check for keypressed (instead of inside keypressed) and if it finds it, it executes my Pause routine.
It's working GREAT! So Thank you for the help getting it to work in my console program!
Pause is Back!! Now I can use F12 for something more useful.
James
Considering, that only Caps Lock, Scroll Lock and Num Lock keys have status lights on…
There is such a thing under DOS, because the BIOS treats the Pause key in a special way. When you press it, the BIOS enters a loop and stops execution of your program, until you press Pause again. This is done, so that you can pause the output to the console, in case it is scrolling too fast, so that you can examine it. For this purpose, there's a flag in the BIOS data area, which is documented here:
http://www.techhelpmanual.com/58-keyboard_shift_status_flags.html
Bit 3 (mask 08h) at 0040h:0018h contains the Pause status. However, I don't think there's such an equivalent under Windows and Linux. Actually, the Linux console (but not X11!) uses Scroll Lock to pause the console output, pretty much the same way DOS and BIOS used the Pause key. Why didn't Linus Torvalds use the Pause key is beyond me.
Nikolay
On Sat, 15 Apr 2023 14:23:12 +0300, Nikolay Nikolov via fpc-pascal declaimed
the following:
Actually, the Linux console (but not X11!) uses Scroll Lock to pause the console output, pretty much the same way DOS and BIOS used the Pause key. Why didn't Linus Torvalds use the Pause key is beyond me.
Why didn't either use the long established X-on/X-off <ctrl-q>/<ctrl-s> convention?
There is such a thing under DOS, because the BIOS treats the Pause key in a special way.…
It occurs to me that since Pause is independent of keypressed, I could actually us it as an extra modifier key if I wanted to... "Pause-A" could be different than "A", and also different than "CRTL-A" or "ALT-A", in fact I could do "Pause-CTRL-ALT-A" and have that be different than "CTRL-ALT-A"
I could have all kinds of secret command key combinations and no one would ever discover them because almost nobody ever pushes the pause key anymore, and even if they do, even fewer people would ever uses it as a modifier.
Fun!