I'm trying to send a non-break space ( ) through Space key only when CapsLock is On, ootherwise send the regular space key.
I've tried a bunch of different variations of the following but none of them exactly work right.
$~Space::
GetKeyState, state, CapsLock, T
if state = D
send, { } ; non-break space
else
send, { } ; regular space
Return
It seems to either always send the regular space ($~, or only ~) or not send it at all (only $), or not work at all (neither $ or ~).
Here's a list different variations of $/~ literals I've use with respective results:
For convenience, I'll pretend I want to use the character n instead of non-break space.
Keeping the above code same except the first line, on pressing the Space key:
$~Space::- caps lock off: Sends
<space>(good) - caps lock on: Sends
<space>n(why the extra space?)
- caps lock off: Sends
$Space::- caps lock off: Sends nothing!
- caps lock on: Sends
n(good)
~Space::- caps lock off: Sends
<space>(good) - caps lock on: Sends
<space>n(why the extra space?)
- caps lock off: Sends
Space::- caps lock off: Sends nothing!
- caps lock on: Sends
n(good)
What's the correct way to make this work?