Print Scrn key
BlitzMax Forums/BlitzMax Beginners Area/Print Scrn key
| ||
I've written a screen grab function and want to use the Print Scrn key to activate it. I've looked at the scan code chart and tried KEY_PRINT and KEY_SCREEN, but neither of these seem to be correct. I've tried another key to check the code and it works fine so it's definatly the scan code that is wrong. Does anyone know which is the correct scan code for this key? |
| ||
the scan code in the docs is correct, the problem appears to be that the print screen key is treated differently from all others. |
| ||
The Scancodes Picker App (in the Blitz Help Command reference area) says you're looking for scancode 183, which is labelled SysReq (it shares the same key as Print Scrn). |
| ||
BMax scancodes are different from B3D |
| ||
Windows intercepts that key to grab the contents of the screen into the clipboard. As far as I know, there's no native way within BlitzMax to disable this feature so that you can grab the key press yourself. I'm afraid you'll just have to use another key, F12 for example. Even commercial games tend to use one of the function keys to grab a screenshot. |
| ||
Solved it:Graphics 640,480,0,0 Extern "Win32" Function GetAsyncKeyState:Int(key:Int) End Extern While Not KeyDown(KEY_ESCAPE) Cls If GetAsyncKeyState(KEY_SCREEN) Then DrawText("Print Screen", 0,0) Flip Wend End |
| ||
Although that code works, it still grabs the screen into the clipboard. |
| ||
that's right, that's because you need to disable that as well.Graphics 640,480,0,0 Extern "Win32" Function GetAsyncKeyState:Int(key:Int) Function RegisterHotKey:Int(hwnd:Int, ID:Int, Modifiers:Int, VK:Int) Function GetActiveWindow:Int() End Extern Local hwnd = GetActiveWindow() RegisterHotKey(hwnd, 1, 0, KEY_SCREEN) While Not KeyDown(KEY_ESCAPE) Cls If GetAsyncKeyState(KEY_SCREEN) Then DrawText("Print Screen", 0,0) Flip Wend End |