title: Autohotkey send key, let it trigger other hotkeys (#InputLevel confusion)
body: <p>I want to create a hotkey that sends some key, and then another hotkey for that very just sent key, that in turn sends a third key.</p>
  
  <p>That seems to be possible, using <a href="http://l.autohotkey.net/docs/commands/_InputLevel.htm" rel="nofollow"><code>#InputLevel</code></a>:</p>
  
  <pre><code>#InputLevel 1
  a::b
  #InputLevel 0
  b::c
  </code></pre>
  
  <p>The above works as intended: By pressing <strong>a</strong> I get <strong>c</strong>.</p>
  
  <p>However, I want not only to remap the first key: I want to do more before sending the key. So I thought I could just rewrite the above a little bit:</p>
  
  <pre><code>#InputLevel 1
  Hotkey *a, foo
  #InputLevel 0
  b::c
  
  foo:
      ; Do something more here …
      SendInput {Blind}b
      return
  </code></pre>
  
  <p>The above however does not work as intended: By pressing <strong>a</strong> I get <strong>b</strong> (not <strong>c</strong>).</p>
  
  <p>Update: @Robert Ilbrink reminded me that you can execute more than one command, without using the <code>Hotkey</code> command:</p>
  
  <pre><code>#InputLevel 1
  *a::
      ; Do something here …
      SendEvent {Blind}b
      return
  #InputLevel 0
  b::c
  </code></pre>
  
  <p>The above does give the intended effect: Pressing <strong>a</strong> results in <strong>c</strong>. However, I have to rephrase my problem. I guess the problem is: I need to set the hotkeys dynamically, which means I have to use the <code>Hotkey</code> command with a label (as far as I know). (Also notice that I use <code>SendEvent</code> above. Using <code>SendInput</code> produces a <strong>b</strong>. Odd.)</p>
  
  <p>(End of update.)</p>
  
  <p>I know there is a companion command to <code>#InputLevel</code>—<a href="http://l.autohotkey.net/docs/commands/SendLevel.htm" rel="nofollow"><code>SendLevel</code></a>—which might be relevant. I've tried putting it many places but it has never made any difference.</p>
  
  <p>So, that was the reduced, theoretical example. Remapping a to b to c is of course useless in reality (and the net result could of course be achieved by <code>a::c</code>). On to my use case. Just keep in mind that if it turns out that the "real" solution means doing what I'm trying to do some other way, I'm still interested in knowing more about <code>#InputLevel</code> and <code>SendLevel</code>, and why my example does not work as intended.</p>
  
  <p>I'm working on implementing <a href="http://en.wikipedia.org/wiki/Modifier_key#Dual-role_keys" rel="nofollow">dual-role modifier keys</a>. For example, send <strong>)</strong> when pressing <strong>RShift</strong> alone, but <strong>RShift+<em>key</em></strong> when pressed together with some other key. Basically, <strong>RShift</strong> on keydown, and <strong>RShift up</strong> and <strong>)</strong> on keyup. However, that has one flaw: Even when combining <strong>RShift</strong> with some other key, <strong>)</strong> is still sent. So the script needs to know when there has been a combination. My solution is to add hotkeys to all letter keys, the arrow keys and some other keys, like this:</p>
  
  <pre><code>for comboKey in filteredComboKeys {
      Hotkey % "*" comboKey, Dual_comboKey
  }
  
  ; Later in script:
  
  Dual_comboKey:
  
      ; The following function lets the dual-role modifier keys know that they have 
      ; been combined with another key (and a few other things, which I don't think
      ; are important for the issue.)
      Dual.combo() ; 
  
      key := Dual.cleanKey(A_ThisHotkey)
      SendInput {Blind}%key%
  
      return
  </code></pre>
  
  <p>The above solution works very well for my purpose—except that the break all remappings and other hotkeys the user might have made: These simply never occur.</p>