Page 2 of 2

Posted: Fri Jul 24, 2009 1:36 pm
by Michael Vogel
netmaestro wrote:For the font just look up a few posts... :wink:
Thanks, haven't seen that :roll:

Posted: Sat Jul 25, 2009 5:30 pm
by netmaestro
Michael Vogel wrote:...is there also a possibility to check combinations including the Windows key (#VK_MOD)?
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
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?

Posted: Sat Jul 25, 2009 11:10 pm
by Michael Vogel
netmaestro wrote:...more than enough..., don't you think?
I never can have enough! :lol:

___
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 :wink:

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/$ :shock:

Posted: Sat Jul 25, 2009 11:15 pm
by netmaestro
IBM PC with 64K memory and 10MB hard disk did cost more than 10.000 Euro/$
Gotcha! No such thing as euros when they sold those... hehe :D

Re:

Posted: Tue Jan 26, 2010 1:15 pm
by UserOfPure
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.

Re: Hotkey gadgets would be nice!

Posted: Tue Jan 26, 2010 4:22 pm
by kernadec
hello

thank you, very nice

there is a hotkey forum here: http://www.autohotkey.com/forum/

bye

Re: Hotkey gadgets would be nice!

Posted: Tue Jan 26, 2010 8:22 pm
by UserOfPure
That forum is for the AutoHotKey application, and doesn't directly help with netmaestro's code above.

Re: Re:

Posted: Tue Jan 26, 2010 8:31 pm
by Trond
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.
Better just store the hotkey number as a string. Use Str(wHotkey). To get it back, just use Val() on the string.

Re: Re:

Posted: Tue Jan 26, 2010 8:40 pm
by UserOfPure
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:

Posted: Tue Jan 26, 2010 8:42 pm
by Trond
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. :)
No, you didn't read what I wrote. Use Str() on the keycode. Don't use GetHotkeyText().

Re: Hotkey gadgets would be nice!

Posted: Tue Jan 26, 2010 10:06 pm
by netmaestro
I'm currently using this code for translating the contents of a hotkey control into something usable with RegisterHotkey_():

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)
;       [...]
PB 4.40 of course, as I'm using a map. Hope it's helpful!

Re: Hotkey gadgets would be nice!

Posted: Wed Jan 27, 2010 10:40 am
by UserOfPure
Thanks for both of you replying, but I'm nowhere near understanding. If my INI file saves the hotkey like this:

Code: Select all

apphotkey = Ctrl + Shift + F1
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.

Re: Hotkey gadgets would be nice!

Posted: Wed Jan 27, 2010 12:43 pm
by netmaestro
Application_Hotkey_Code =
Application_Hotkey_FriendlyName =

Re: Hotkey gadgets would be nice!

Posted: Wed Jan 27, 2010 1:11 pm
by UserOfPure
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. :mrgreen: