Author |
Topic: Control keys capture (i.e. F1 for help) (Read 554 times) |
|
flotulopex
Junior Member
member is offline
Gender:
Posts: 94
|
|
Control keys capture (i.e. F1 for help)
« Thread started on: Mar 24th, 2014, 1:27pm » |
|
Hi there,
I was wondering if some more keys than the usual "Ctrl", "Alt", "Esc" etc such as the standard F1 (for "help") could be captured (scanned) within an LBB compiled program?
IMHO, it is a very restrictive usage to enable this ability only in graphic windows or am I wrong?
|
|
Logged
|
Roger
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Control keys capture (i.e. F1 for help)
« Reply #1 on: Mar 24th, 2014, 2:45pm » |
|
on Mar 24th, 2014, 1:27pm, flotulopex wrote:I was wondering if some more keys than the usual "Ctrl", "Alt", "Esc" etc such as the standard F1 (for "help") could be captured (scanned) within an LBB compiled program? |
|
The same question (or something very like it) was asked recently over at the LBB Yahoo group:
https://groups.yahoo.com/neo/groups/lbb/conversations/messages/1093
My suggestion was either to test the key asynchronously (the example program keypress.bas is supplied with LB 4.04), when that is acceptable, or if you must see the keypress 'event' to use a Windows hook.
This program illustrates how you can use a WH_KEYBOARD_LL hook to monitor keypress events. It works with function keys just as well as regular keys:
Code: open "Hook test" for text as #w
struct kbhs, vkCode as ulong, scanCode as ulong, _
flags as ulong, time as ulong
callback lpfnHook, KeyboardLLHook(long, ulong, ulong), long
calldll #user32, "SetWindowsHookExA", _
_WH_KEYBOARD_LL as long, _
lpfnHook as ulong, _
0 as long, _
0 as long, _
hHook as ulong
wait
function KeyboardLLHook(lMsg, wParam, lParam)
kbhs.struct = lParam
if wParam=256 print chr$(kbhs.vkCode.struct);
end function It doesn't directly address your question but in LBB you can 'program' a function key to return any string you like in the INPUT statement, by incorporating a little bit of BBC BASIC code (here the |M signifies CR):
Code: !*key 1 "Hello world!|M"
do
input r$
loop until 0 Richard.
|
|
|
|
|