AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

checking if a hotkey is using a valid key name

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
daorc



Joined: 18 Oct 2006
Posts: 78

PostPosted: Tue Jun 24, 2008 12:23 pm    Post subject: checking if a hotkey is using a valid key name Reply with quote

Hello.

Does anyone know how to check if a key exists on the user’s keyboard?

I created a script in which the ‘#’ key was a hotkey (using the “hotkey,#,subroutine” command). When this was run on a mac (running Windows XP), which has no “#” key, the following error appeared:

‘#’ is not a valid key name. The current thread will exit.

Is there any way to check if a key such as “#” is a valid key name before attempting to register it as a hotkey?

Cheers,

Daorc
Back to top
View user's profile Send private message
Krogdor



Joined: 18 Apr 2008
Posts: 1145
Location: The Interwebs

PostPosted: Tue Jun 24, 2008 7:11 pm    Post subject: Reply with quote

"#" is never a valid hotkey. It is only a modifier key. To have the Windows Key as a hotkey, you should use "RWin" or "LWin".
Back to top
View user's profile Send private message AIM Address
daorc



Joined: 18 Oct 2006
Posts: 78

PostPosted: Wed Jun 25, 2008 8:36 am    Post subject: Reply with quote

thanks, but I was meaning teh actual hash key, not a windows key. I have found the answer to my question, though, so for anyone wanting to do the same:

specify "useerrorlevel" in the hotkey command's options. if teh keyname is invalid, it will give an error of 2.

Code:
#persistent

hotkey,F2,ok
hotkey,some_invalid_keyname,ok,useerrorlevel
msgbox %errorlevel%

return

ok:
msgbox ok
return


Hope that helps,

Daorc
Back to top
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 6847
Location: Pacific Northwest, US

PostPosted: Wed Jun 25, 2008 4:29 pm    Post subject: Reply with quote

on a US english keyboard, I would use +3 instead of #
_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group