Why Keys blocked?

Just starting out? Need help? Post your questions and find answers here.
LCD
Enthusiast
Enthusiast
Posts: 206
Joined: Sun Jun 01, 2003 10:55 pm
Location: Austria, Vienna
Contact:

Why Keys blocked?

Post by LCD »

ExamineKeyboard()
If KeyboardPushed(#PB_Key_A):....:EndIf

after return from the subroutine which uses this kind of control, the keyboard did not work anymore in the ExplorerTreeGadged, String Gadget and probably other gadgets too. I can then use mouse only to select files/text. ExamineKeyboard() itself is harmless, but KeyboardPushed()/KeyboardReleased() blocks the complete keyboard input to the gadgets. Is there a way to unblock keyboard, so the keys will work again with windows gadgets, or is it a bug?
My PC
Ryzen 9 5950, 64 GB RAM, nVidia RTX A4000, Win 10
Ryzen 7 1700, 32 GB RAM, nVidia RTX A2000, Win 10
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

I'm not sure about using the keyboard lib in an application... This is one way to check for enter being pressed :

Code: Select all

       Select MyEventID
         
          Case #WM_KEYDOWN
           
            If EventwParam() = 13
           
              Select EventGadgetID()
             
                Case #String_Gadget_Here
               
                  Debug "Return key pressed in string gadget"
                 
              EndSelect

            EndIf

         EndSelect 
.. It should work for any key.. Most would suggest using AddKeyboardShortcut() though as it's a bit more reliable...
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

Code: Select all

InitKeyboard()
ExamineKeyboard() 
If KeyboardPushed(#PB_Key_A):....:EndIf
etc...
These commands use DirectX v7.0+ and should not really be used in apps (unless you need to use DirectX for something else e.g. a windowed screen.).

You could maybe use a CallBack or shortcuts as Karbon said.
--Kale

Image
LCD
Enthusiast
Enthusiast
Posts: 206
Joined: Sun Jun 01, 2003 10:55 pm
Location: Austria, Vienna
Contact:

Post by LCD »

I use the DX7 keyboard control to control the scrolling in zoom mode of my application, and it is working in windowed screen mode.
Shortcuts for scrolling is a bit unusual, but I will test the other method tomorrow. Any idea why it blocks gadgets?
My PC
Ryzen 9 5950, 64 GB RAM, nVidia RTX A4000, Win 10
Ryzen 7 1700, 32 GB RAM, nVidia RTX A2000, Win 10
Skipsy
User
User
Posts: 98
Joined: Wed Apr 30, 2003 12:26 pm
Location: France

Post by Skipsy »

Hello,

Try : GetAsyncKeyState_(ascii_key) instead of KeyboardPushed()


Enjoy.
Beware of the man who has the solution before he understands the problem...
LCD
Enthusiast
Enthusiast
Posts: 206
Joined: Sun Jun 01, 2003 10:55 pm
Location: Austria, Vienna
Contact:

Post by LCD »

GetAsyncKeyState_(ascii_key) returns zero (ascii_key=97 for "a") if key pressed. It works well with (13), so I hope, it will work with cursors too, but what are the ASCII for cursor keys?
My PC
Ryzen 9 5950, 64 GB RAM, nVidia RTX A4000, Win 10
Ryzen 7 1700, 32 GB RAM, nVidia RTX A2000, Win 10
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post by Pupil »

Check win32 API, for virtual key codes:

Code: Select all

#VK_LEFT = 25 ;LEFT ARROW key 
#VK_UP =26 ;UP ARROW key 
#VK_RIGHT = 27 ;RIGHT ARROW key 
VK_DOWN = 28 ;DOWN ARROW key 
You probably don't have to define the constants though as they're probably already available in PB.
LCD
Enthusiast
Enthusiast
Posts: 206
Joined: Sun Jun 01, 2003 10:55 pm
Location: Austria, Vienna
Contact:

Post by LCD »

Thx, Pupil, it works fine, except the CHR codes are wrong, for example #VK_DOWN is the constant for 40 (probably because I'm damned to use a german keyboard?), but it works with these constants. Excellent. I guess, I can now throw out all DX keyboard command. Still no idea why it kills API input? (Don´t says because these are Micro$oft products) :twisted:
My PC
Ryzen 9 5950, 64 GB RAM, nVidia RTX A4000, Win 10
Ryzen 7 1700, 32 GB RAM, nVidia RTX A2000, Win 10
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

This is a total guess but if you use the DX keyboard controls then the app is handing over all control of the keyboard to DX?
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post by Pupil »

LCD wrote:Thx, Pupil, it works fine, except the CHR codes are wrong, for example #VK_DOWN is the constant for 40 (probably because I'm damned to use a german keyboard?)...
Hmm, that's because they are hex values :) only i forgot to add the '$' to make them so when i was doing the copy n' paste routine ;)
LCD
Enthusiast
Enthusiast
Posts: 206
Joined: Sun Jun 01, 2003 10:55 pm
Location: Austria, Vienna
Contact:

Post by LCD »

@Pupil: Eh, Hex... I see. Should figure this out next time. I do not care about how you write hex (0xFF or $FF for 255).
@Karbon: But after the DX handling is over, should it not hand over the keyboard controls to the app? If it sounds like a bug, it is probably a bug. I´m just curious what Fred says about this.
My PC
Ryzen 9 5950, 64 GB RAM, nVidia RTX A4000, Win 10
Ryzen 7 1700, 32 GB RAM, nVidia RTX A2000, Win 10
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> the CHR codes are wrong [for letters]

Use #VK_A through #VK_Z for letters.
LCD
Enthusiast
Enthusiast
Posts: 206
Joined: Sun Jun 01, 2003 10:55 pm
Location: Austria, Vienna
Contact:

Post by LCD »

PB wrote:> the CHR codes are wrong [for letters]

Use #VK_A through #VK_Z for letters.
Okay, thanks!!!
My PC
Ryzen 9 5950, 64 GB RAM, nVidia RTX A4000, Win 10
Ryzen 7 1700, 32 GB RAM, nVidia RTX A2000, Win 10
Post Reply