title: AHK script designed to toggle based on CapsLock Status always toggles on 'off' and I cannot change it to 'on'
body: <p>(Note: Very new to scripting, borrowed some phrases from other scripts I've online.)  I have Carpal Tunnel and play a video game that does not have any key-bind options not set to the F1-F0 keys so I want to rebind the F1-F4 keys to Z-V but only when capslock is enabled, to prevent being unable to type in chat windows and in other programs without closing the script.  However, the script re-binds the basic keys to the f-keys ONLY when capslock is OFF, rather than allowing me to change it to ON.  Not sure why.  </p>
  
  <p>I've tried 'hotfixing' it by rebinding it to Numlock, but when I moved to CapsLock changing 'OFF' to 'ON' did not keep the script from only rebinding the keys while CapsLock was OFF.  Not sure why.  </p>
  
  <pre><code>$Z::
    GetKeyState, state, NumLock, T
    if state = D ; NumLock is toggled ON
      send, {z}
    else
      send, {F1}
    Return 
  
  
  $X::
    GetKeyState, state, NumLock, T
    if state = D ; NumLock is toggled ON
      send, {x}
    else
      send, {F2}
    Return 
  
  etc...
  etc...
  </code></pre>
  
  <p>I expected changing the value 'OFF' to 'ON' would result in the key rebinds only happening during the CapsLock status being toggled on.</p>