| View previous topic :: View next topic |
| Author |
Message |
daorc
Joined: 18 Oct 2006 Posts: 78
|
Posted: Tue Jun 24, 2008 12:23 pm Post subject: checking if a hotkey is using a valid key name |
|
|
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 |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 1145 Location: The Interwebs
|
Posted: Tue Jun 24, 2008 7:11 pm Post subject: |
|
|
| "#" 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 |
|
 |
daorc
Joined: 18 Oct 2006 Posts: 78
|
Posted: Wed Jun 25, 2008 8:36 am Post subject: |
|
|
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 |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6847 Location: Pacific Northwest, US
|
Posted: Wed Jun 25, 2008 4:29 pm Post subject: |
|
|
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 |
|
 |
|