Repeatedly calling a hotkey









up vote
1
down vote

favorite












I've tried to implement a t flip flop(I think this is what it's called) into my program but am having some issues with it. The idea is to have the program start and stop while using the same hotkey. This is what I have so far.



looping := false
pass = 0
max = 2

^r::
pass++
looping := true
while(looping = true AND pass < max)

Send, stack overflow, save me!


looping := false
pass = 0
return


When I run the program and hit the hotkey the while loop starts. However, when I attempt to break the loop by pressing ^r I get no response and the program keeps looping.










share|improve this question

























    up vote
    1
    down vote

    favorite












    I've tried to implement a t flip flop(I think this is what it's called) into my program but am having some issues with it. The idea is to have the program start and stop while using the same hotkey. This is what I have so far.



    looping := false
    pass = 0
    max = 2

    ^r::
    pass++
    looping := true
    while(looping = true AND pass < max)

    Send, stack overflow, save me!


    looping := false
    pass = 0
    return


    When I run the program and hit the hotkey the while loop starts. However, when I attempt to break the loop by pressing ^r I get no response and the program keeps looping.










    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I've tried to implement a t flip flop(I think this is what it's called) into my program but am having some issues with it. The idea is to have the program start and stop while using the same hotkey. This is what I have so far.



      looping := false
      pass = 0
      max = 2

      ^r::
      pass++
      looping := true
      while(looping = true AND pass < max)

      Send, stack overflow, save me!


      looping := false
      pass = 0
      return


      When I run the program and hit the hotkey the while loop starts. However, when I attempt to break the loop by pressing ^r I get no response and the program keeps looping.










      share|improve this question













      I've tried to implement a t flip flop(I think this is what it's called) into my program but am having some issues with it. The idea is to have the program start and stop while using the same hotkey. This is what I have so far.



      looping := false
      pass = 0
      max = 2

      ^r::
      pass++
      looping := true
      while(looping = true AND pass < max)

      Send, stack overflow, save me!


      looping := false
      pass = 0
      return


      When I run the program and hit the hotkey the while loop starts. However, when I attempt to break the loop by pressing ^r I get no response and the program keeps looping.







      autohotkey






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 10 at 20:52









      Jack

      82




      82






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          I think you are referring to a "toggle" script. I am not what sure you are trying to achieve exactly, but the key is using a logical not: looping := !true. More about it here.



          looping := false
          pass = 0
          max = 2

          ^r::
          pass++
          looping := !true
          while (looping & pass < max)

          Send, stack overflow, save me!

          pass = 0
          return


          There's a lot of resources for this, here are a few:
          https://autohotkey.com/boards/viewtopic.php?t=11952
          http://maul-esel.github.io/ahkbook/en/toggle-autofire.html
          https://www.reddit.com/r/AutoHotkey/comments/6wqgbu/how_do_i_toggle_hold_down_a_key/dmad0xx






          share|improve this answer




















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53243300%2frepeatedly-calling-a-hotkey%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote



            accepted










            I think you are referring to a "toggle" script. I am not what sure you are trying to achieve exactly, but the key is using a logical not: looping := !true. More about it here.



            looping := false
            pass = 0
            max = 2

            ^r::
            pass++
            looping := !true
            while (looping & pass < max)

            Send, stack overflow, save me!

            pass = 0
            return


            There's a lot of resources for this, here are a few:
            https://autohotkey.com/boards/viewtopic.php?t=11952
            http://maul-esel.github.io/ahkbook/en/toggle-autofire.html
            https://www.reddit.com/r/AutoHotkey/comments/6wqgbu/how_do_i_toggle_hold_down_a_key/dmad0xx






            share|improve this answer
























              up vote
              0
              down vote



              accepted










              I think you are referring to a "toggle" script. I am not what sure you are trying to achieve exactly, but the key is using a logical not: looping := !true. More about it here.



              looping := false
              pass = 0
              max = 2

              ^r::
              pass++
              looping := !true
              while (looping & pass < max)

              Send, stack overflow, save me!

              pass = 0
              return


              There's a lot of resources for this, here are a few:
              https://autohotkey.com/boards/viewtopic.php?t=11952
              http://maul-esel.github.io/ahkbook/en/toggle-autofire.html
              https://www.reddit.com/r/AutoHotkey/comments/6wqgbu/how_do_i_toggle_hold_down_a_key/dmad0xx






              share|improve this answer






















                up vote
                0
                down vote



                accepted







                up vote
                0
                down vote



                accepted






                I think you are referring to a "toggle" script. I am not what sure you are trying to achieve exactly, but the key is using a logical not: looping := !true. More about it here.



                looping := false
                pass = 0
                max = 2

                ^r::
                pass++
                looping := !true
                while (looping & pass < max)

                Send, stack overflow, save me!

                pass = 0
                return


                There's a lot of resources for this, here are a few:
                https://autohotkey.com/boards/viewtopic.php?t=11952
                http://maul-esel.github.io/ahkbook/en/toggle-autofire.html
                https://www.reddit.com/r/AutoHotkey/comments/6wqgbu/how_do_i_toggle_hold_down_a_key/dmad0xx






                share|improve this answer












                I think you are referring to a "toggle" script. I am not what sure you are trying to achieve exactly, but the key is using a logical not: looping := !true. More about it here.



                looping := false
                pass = 0
                max = 2

                ^r::
                pass++
                looping := !true
                while (looping & pass < max)

                Send, stack overflow, save me!

                pass = 0
                return


                There's a lot of resources for this, here are a few:
                https://autohotkey.com/boards/viewtopic.php?t=11952
                http://maul-esel.github.io/ahkbook/en/toggle-autofire.html
                https://www.reddit.com/r/AutoHotkey/comments/6wqgbu/how_do_i_toggle_hold_down_a_key/dmad0xx







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 10 at 23:12









                Joe DF

                3,28152948




                3,28152948



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53243300%2frepeatedly-calling-a-hotkey%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Top Tejano songwriter Luis Silva dead of heart attack at 64

                    ReactJS Fetched API data displays live - need Data displayed static

                    政党