Thanks, haven't seen that :roll:netmaestro wrote:For the font just look up a few posts...
Hotkey gadgets would be nice!
- Michael Vogel
- Addict
- Posts: 2797
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Michael Vogel wrote:...is there also a possibility to check combinations including the Windows key (#VK_MOD)?
VK_MOD isn't one of the modifiers returned, so I'd say not. Surely there are more than enough available combinations without it, don't you think?MSDN re: HKM_GETHOTKEY wrote:Returns the virtual key code and modifier flags. The virtual key code is in the low-order byte, and the modifier flags are in the high-order byte. The modifier flags can be a combination of the following values:
Value.......................Meaning
HOTKEYF_ALT...........ALT key
HOTKEYF_CONTROL..CONTROL key
HOTKEYF_EXT...........Extended key
HOTKEYF_SHIFT........SHIFT key
BERESHEIT
- Michael Vogel
- Addict
- Posts: 2797
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
I never can have enough!netmaestro wrote:...more than enough..., don't you think?

___
the following lines have absolute nothing to do with the thread, but however...
PS I still can remember when someone thought to start the video memory area at 640k, because below that everyone would have enough main memory

PSS my PET had 8K (!) memory at this time and a simple IBM PC with 64K memory and 10MB hard disk did cost more than 10.000 Euro/$

- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
-
- Enthusiast
- Posts: 469
- Joined: Sun Mar 16, 2008 9:18 am
Re:
Hi netmaestro, I was looking at your hotkey code above and it's great that it returns the text string, which means I can store it in my INI file nicely, but how would I turn that string back into flags for use with the RegisterHotkey API? I can get the mods easily enough (just a FindString for "Shift +" etc) but the last part (the non-mod key) stumps me... for example, if it's just the letter A, or what if it's the the Break key? Is there an easy way to determine that final part of non-mod key without doing a whole If/ElseIf block? I think it may be to do with the GetKeyNameText API but not sure.
-
- Enthusiast
- Posts: 469
- Joined: Sun Mar 16, 2008 9:18 am
Re: Hotkey gadgets would be nice!
That forum is for the AutoHotKey application, and doesn't directly help with netmaestro's code above.
Re: Re:
Better just store the hotkey number as a string. Use Str(wHotkey). To get it back, just use Val() on the string.UserOfPure wrote:Hi netmaestro, I was looking at your hotkey code above and it's great that it returns the text string, which means I can store it in my INI file nicely, but how would I turn that string back into flags for use with the RegisterHotkey API? I can get the mods easily enough (just a FindString for "Shift +" etc) but the last part (the non-mod key) stumps me... for example, if it's just the letter A, or what if it's the the Break key? Is there an easy way to determine that final part of non-mod key without doing a whole If/ElseIf block? I think it may be to do with the GetKeyNameText API but not sure.
-
- Enthusiast
- Posts: 469
- Joined: Sun Mar 16, 2008 9:18 am
Re: Re:
I am storing it as a string, as I said (the INI file comment). But when I read it back, the RegisterHotKey API doesn't take a string, but a virtual key code. So if the hotkey is Ctrl + Break, how do you make the Break key value (#VK_CANCEL) work with Val()? Now you see the problem. 

Re: Re:
No, you didn't read what I wrote. Use Str() on the keycode. Don't use GetHotkeyText().UserOfPure wrote:I am storing it as a string, as I said (the INI file comment). But when I read it back, the RegisterHotKey API doesn't take a string, but a virtual key code. So if the hotkey is Ctrl + Break, how do you make the Break key value (#VK_CANCEL) work with Val()? Now you see the problem.
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Hotkey gadgets would be nice!
I'm currently using this code for translating the contents of a hotkey control into something usable with RegisterHotkey_():
PB 4.40 of course, as I'm using a map. Hope it's helpful!
Code: Select all
Global NewMap MapModifier()
MapModifier(Str(#HOTKEYF_ALT)) = #MOD_ALT
MapModifier(Str(#HOTKEYF_CONTROL)) = #MOD_CONTROL
MapModifier(Str(#HOTKEYF_SHIFT)) = #MOD_SHIFT
Procedure SetHotkey(HotKey.w)
Protected mod, key
mod = MapModifier(Str(HotKey>>8)) : key = HotKey & $FF
hID = GlobalAddAtom_("QuickSnap HotKey")
ProcedureReturn RegisterHotKey_(WindowID(#wMain), hID, mod, key)
EndProcedure
; [...]
Case #gPref_SetHotKey
thisHotkey.w = SendMessage_(hwndHot, #HKM_GETHOTKEY, 0, 0)
If HotkeyIsValid(GetHotkeyText(thisHotkey))
If SetHotkey(thisHotkey)
; [...]
BERESHEIT
-
- Enthusiast
- Posts: 469
- Joined: Sun Mar 16, 2008 9:18 am
Re: Hotkey gadgets would be nice!
Thanks for both of you replying, but I'm nowhere near understanding. If my INI file saves the hotkey like this:
Then how do I read that and turn it into something that RegisterHotKey can use? Okay, ignore the mods, because that's easy, and we're left with "F1". How would my app know that the text "F1" = #VK_F1? I don't want to store it as a raw keycode because it's not user-friendly. I want it stored as plain text like the above. It seems to me that the only way is to do a whole bunch of If/Then to check every text scenario. Surely there's an API call that can convert "F1" to #VK_F1? I've tried GetKeyNameText and MapVirtualKey without success so far.
Code: Select all
apphotkey = Ctrl + Shift + F1
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Hotkey gadgets would be nice!
Application_Hotkey_Code =
Application_Hotkey_FriendlyName =
Application_Hotkey_FriendlyName =
BERESHEIT
-
- Enthusiast
- Posts: 469
- Joined: Sun Mar 16, 2008 9:18 am
Re: Hotkey gadgets would be nice!
Still no good because I want to be able to edit the INI file manually with the hotkey, which is the reason for it being stored friendly. No problem, I can just do a comparison block of code after all. It won't be too hard, it's just time-consuming and boring to write. 
