LB Booster
« Control keys capture (i.e. F1 for help) »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 04:25am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Control keys capture (i.e. F1 for help)  (Read 554 times)
flotulopex
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 94
xx 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?
User IP Logged

Roger
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx 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.
« Last Edit: Mar 24th, 2014, 2:48pm by Richard Russell » User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls