if ((GetNumLock = true) and (SetOn = false))
or ((GetNumLock = false) and (SetOn = true)) then
Sorry, I cannot resist...
Yes it works, but it is so ugly. You can do better than that.
if GetNumLock xor SetOn then
You could also replace "xor" with "<>" if you prefer. But at least, please don't use "= true" and "= false".
On the other hand, you can add as many "= true" as you want, it would also work:
if ((((((GetNumLock = true) = true) = true) = true) and (((SetOn = false) = true) = true) = true)
or (((((GetNumLock = false) = true) = true) = true) and (((SetOn = true) = true) = true) = true)) = true
then