"^+s" is not alpha-numeric. You can see this by simplifying your code to:
Code: Select all
ProgramKey := []
ProgramKey.cmd := "^+s"
temp := ProgramKey["cmd"]
If temp is alnum
MsgBox, That is alpha-numeric!
The condition is not satisfied; whereas, if you change "^+s" to, simply, "s", it
is satisfied.
As for why your
If % ProgramKey["cmd"] is alnum statement is satisfied, my guess is that it's a fluke. According to the help file, forcing expressions (with %) "can be used in the InputVar parameters of all commands except the traditional IF commands (use If (expression) instead)." A traditional IF statement is what you're using. On top of that, there's another note in the help file that says that "is" can't be used in expressions. Both of these probably should throw errors, but, instead, the statement is somehow evaluating to true when, as I showed above, it should not be.
Anyways, since checking for alnum is going to fail when the code is correct, you should probably scrap that idea and check for something else, instead. For example, if what you're doing is checking whether a given hotkey is valid, you can use the
IsLabel() function, like so:
Code: Select all
ProgramKey := []
ProgramKey.cmd := "^+s"
If IsLabel(ProgramKey["cmd"]) {
MsgBox, That is a valid hotkey!
}
^+s::Return