GetGadgetText for ShortcutGadget
GetGadgetText for ShortcutGadget
Returns the actual text like "STRG + A"
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

- Fangbeast
- PureBasic Protozoa
- Posts: 4789
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
Re: GetGadgetText for ShortcutGadget
Code: Select all
;==========================================================================================================================
; Get the text of the associated shortcut constant
;==========================================================================================================================
Procedure.s GetShortcutText(Constant.i)
;------------------------------------------------------------------------------------------------
; Sroddy code
;------------------------------------------------------------------------------------------------
; Protected ResultString.s
; If Constant & #PB_Shortcut_Control
; ResultString.s = "Ctrl + "
; EndIf
; If Constant & #PB_Shortcut_Shift
; ResultString.s + "Shift + "
; EndIf
; If Constant & #PB_Shortcut_Alt
; ResultString.s + "Alt + "
; EndIf
; Constant & ~ (#PB_Shortcut_Shift | #PB_Shortcut_Control | #PB_Shortcut_Alt)
; Select Constant
; Case '0' To '9', 'A' To 'Z'
; ResultString.s + Chr(Constant)
; Case #PB_Shortcut_F1 To #PB_Shortcut_F24
; ResultString.s + "F" + Str(Constant - #PB_Shortcut_F1 + 1)
; Case '~' To '='
; ResultString.s + Chr(Constant)
; EndSelect
; ProcedureReturn ResultString.s
;------------------------------------------------------------------------------------------------
; NetMaestro 2009. NetMaestro code modded by Sroddy code ; Unused mod$, ctrl$, shift$, alt$
;------------------------------------------------------------------------------------------------
;
Protected KeyLocale, VirtualKey, KeyString.s, ResultString.s
If Constant.i & #PB_Shortcut_Control
ResultString.s = "Ctrl + "
EndIf
If Constant.i & #PB_Shortcut_Shift
ResultString.s + "Shift + "
EndIf
If Constant.i & #PB_Shortcut_Alt
ResultString.s + "Alt + "
EndIf
KeyLocale = GetKeyboardLayout_(GetCurrentThreadId_())
KeyString.s = Space(100)
; Virtual key
VirtualKey = MapVirtualKeyEx_(Constant.i & $FF, 0, KeyLocale) << 16
If Constant.i >> 8 & #HOTKEYF_EXT Or (Constant.i & $FF >= #PB_Shortcut_Prior And Constant.i & $FF <= #PB_Shortcut_Down)
VirtualKey | (1 << 24) ; Set the extended key bit
EndIf
GetKeyNameText_(VirtualKey, @KeyString, 100)
ResultString.s + KeyString.s
If ResultString.s = ""
ResultString.s = "None"
EndIf
ProcedureReturn ResultString.s
EndProcedure
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
Re: GetGadgetText for ShortcutGadget
Note the difference between "Strg" in German and "Ctrl" in English. There are a lot other combinations as well.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Re: GetGadgetText for ShortcutGadget
Thx, but doesn't work correct and use API!
Comes Ctrl and not STRG for German, EINGABE (Return) doesn't work,
and with API it is useless for me.
Comes Ctrl and not STRG for German, EINGABE (Return) doesn't work,
and with API it is useless for me.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Re: GetGadgetText for ShortcutGadget
I just got the idea that it might be more useful to add a complete new function for this, so we don't have to create a ShortcutGadget() just to get the text of a key combination.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!