title: How to encapsule the following AutoHotKey statements into functions?
body: <p>I'm using Barrier to control a Windows machine from macOS, and I would like to remap Windows key to Command key to perform more efficient shortcuts.</p>
  <p>Traditionally, simple one line statements (e.g. <code>#c::Send ^c</code>) will work, but have one shortcomming: if you hold pressing Command key then press &quot;c&quot; repeatly, you won't get repeating copy actions as expected, you will get <strong>one copy action</strong> and <strong>multiple typing of &quot;c&quot;s</strong>, which is annoying and not as natural as genuine &quot;Command+C&quot;.</p>
  <p>In order to have real &quot;Command+C&quot; &amp; &quot;Command+V&quot; experience (&amp; many other shortcuts perfectly remapped), I figured out a more complex (but working) apporach:</p>
  <pre><code>LWin &amp; c::
      StateWindowsPressC := true
      Send {Ctrl Down}c
  #If (StateWindowsPressC)
      ~*LWin Up::
          Send {Ctrl Up}
          StateWindowsPressC := false
      return
  #If
  
  LWin &amp; v::
      StateWindowsPressV := true
      Send {Ctrl Down}v   
  #If (StateWindowsPressV)
      ~*LWin Up::
          Send {Ctrl Up}
          StateWindowsPressV := false
      return
  #If
  </code></pre>
  <p>Please note that variables like <code>StateWindowsPressC</code> and <code>StateWindowsPressV</code> should not be the same name or they will cause chaos.</p>
  <p>These statements work, but have too many duplicate statements, is there any way to encapsule them into functions?</p>