AutoHotkey Community

It is currently May 26th, 2012, 8:25 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: June 24th, 2008, 1:23 pm 
Offline

Joined: October 18th, 2006, 8:07 pm
Posts: 169
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 24th, 2008, 8:11 pm 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
"#" 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".


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 25th, 2008, 9:36 am 
Offline

Joined: October 18th, 2006, 8:07 pm
Posts: 169
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 25th, 2008, 5:29 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
on a US english keyboard, I would use +3 instead of #

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, poserpro, RaptorX, sjc1000 and 59 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Powered by phpBB® Forum Software © phpBB Group