Hi,
Just to be sure I did not overlooked something:
Is there a native PureBasic way of detecting key pressed on executable launch ?
Say I want to know if one of the SHIFT keys is pressed when the user launch the application.
I can't use ExamineKeyboard and the like as this require opening a screen. I want to detect keys even with Console applications (yet I'm not sure ExamineKeyboard would detect keys on application launch).
I'm well aware of the Windows API GetAsyncKeyState() which answers my question.
So if there is no native PureBasic way of doing this, what would be the equivalent of GetAsyncKeyState() on Linux and Mac OSX ?
Thanks.
Detect Keypress on Launch ?
- grabiller
- Enthusiast
- Posts: 309
- Joined: Wed Jun 01, 2011 9:38 am
- Location: France - 89220 Rogny-Les-Septs-Ecluses
- Contact:
Detect Keypress on Launch ?
guy rabiller | radfac founder / ceo | raafal.org
Re: Detect Keypress on Launch ?
OS X - I'm not familiar with console applications so you would have to check if it works there also
Code: Select all
#NSAlphaShiftKeyMask = 1 << 16
#NSShiftKeyMask = 1 << 17
#NSControlKeyMask = 1 << 18
#NSAlternateKeyMask = 1 << 19
#NSCommandKeyMask = 1 << 20
ImportC "/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation"
CGEventCreate(source)
CGEventGetFlags(event)
CFRelease(cf)
EndImport
event = CGEventCreate(#Null)
modifiers = CGEventGetFlags(event)
CFRelease(event)
If modifiers & #NSShiftKeyMask
; started with shift pressed
EndIf
- grabiller
- Enthusiast
- Posts: 309
- Joined: Wed Jun 01, 2011 9:38 am
- Location: France - 89220 Rogny-Les-Septs-Ecluses
- Contact:
Re: Detect Keypress on Launch ?
Thanks wilbert.
This works perfectly well.
Cheers.
This works perfectly well.
Cheers.
guy rabiller | radfac founder / ceo | raafal.org