[fpc-pascal] Pause Key

James Richters james.richters at productionautomation.net
Sat Apr 15 03:10:11 CEST 2023


>> ... 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




More information about the fpc-pascal mailing list