Hi!
I'd like to add additional hidden options to button gadgets and made them available only when a specific key combination is pressed.
Could you please advise an easiest way to read pressed key/s when the button gadget is kicked?
Thank you in advance!
check pressed key/combination
Re: check pressed key/combination
A Windows-only solution:Yuri_D wrote:...an easiest way to read pressed key/s when the button gadget is kicked?
Code: Select all
Enumeration
#MainWindow
#Button
EndEnumeration
wFlags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
OpenWindow(#MainWindow, #PB_Any, #PB_Any, 300, 200, "Masked-Click (Windows Only)", wFlags)
ButtonGadget(#Button, 100, 80, 100, 30, "Button")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
appQuit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case #Button
If GetAsyncKeyState_(#VK_SHIFT)
Debug "Button clicked with shift"
ElseIf GetAsyncKeyState_(#VK_CONTROL)
Debug "Button clicked with control"
Else
Debug "Button clicked"
EndIf
EndSelect
EndSelect
Until appQuit

Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 

Re: check pressed key/combination
Thank you, GetAsyncKeyState_ command is what I was looking for!
- doctorized
- Addict
- Posts: 882
- Joined: Fri Mar 27, 2009 9:41 am
- Location: Athens, Greece
Re: check pressed key/combination
Once upon a time, I used GetAsyncKeyState in an app of mine and some antivirus solutions reported that my app is a variant of a keylogger because of the use of this API. So, I replaced it with a hotkey and since then I have no problem. Tell me if you want the code.Yuri_D wrote:Thank you, GetAsyncKeyState_ command is what I was looking for!