IF statement - Evaluate expression from GetKeyState variable?
I have a loop where I have a few GetKeyState commands:
GetKeyState CtrlState, Control
GetKeyState dkeyState, d
GetKeyState ShiftKeyState, Shift
The following returns a message with the expected values (D for each):
Code: Select all
(What you see in MacroCreator window:)
Compare Variables CtrlState = D
Compare Variables ShiftKeyState = D
Compare Variables dkeySate = D
[MsgBox] CtrlSate : %CtrlState% ShiftKeyState, %ShiftKeyState% dkeySate: %dkeyState%
[End If]
[End If]
[End If]
But when I attempt to use a Compare Expression, I can't get even one of these to evaluate orrectly. What am I doing wrong with the following supposedly equivalent expressions (for just the Ctrl query) using "Evaluate Expression"?
(example of what it looks like in MacroCreator:)
Code: Select all
Evaluate Expression CtrlSate = "D"
[MsgBox] CtrlState: %CtrlState%
[End If]
The following statements entered into the "IF evaluate expression entry area do not present a messagebox when either Ctrl key is pressed:
CtrlState = "D"
CtrlState == D
The following statements evaluate to true, even when the CtrlState variable value is "U" as indicated by the messagebox:
CtrlState = D
%CtrlState% = D
CtrlState = 'D'
If I hold down the Ctrl key when I click on OK and it loops back, it displays a D, but it shouldn't display the msgbox in any case where Ctrl isn't pressed.
1. How do I properly evaluate expressions using the IF statement? It would appear %CtrlState% = D would work, but it evaluated to true even though the messagebox displayed the variable value as "U". The messagebox should only display when the value is "D" When should I use quotes in my expression? Should I use one or two equal signs?
2. Once I get that, do I use the keyword "AND" and "OR" between expressions where I want to evaluate multiple expressions? Do I use && and ||? Does NOT work?
Thanks in advance. While i can get by doing three nested IF statements, I'd much rather do one where i evaluate the exact sequence.
Tom