title: How to stop an infinite loop in autohotkey using the key you start it with
body: <p>So i just started using autohotkey and i made this script to spam the trade chat in a game called path of exile, it works pretty well, but i cant get it to stop when i press f1 again, i've tried countles times, but the loop just won't stop</p>
  
  <pre><code>#MaxThreads 2
  wintitle=Path of Exile
  SetTitleMatchMode,2
  DetectHiddenWindows,On
  setkeydelay,2500,0
  f1::
  toggle:=!toggle
  Loop
  {
    if toggle
      controlsend,,{enter}{up}{enter}, %wintitle%
    else
      break
  }
  return
  </code></pre>