CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2009
    Posts
    3

    How do i enable/disable a loop with getasynckeystate()

    I need a code example of being able to put something in a loop and then being able to disable and enable it by pressing a key.

    I know how to enable and disable stuff

    Code:
    if (GetAsyncKeyState(VK_F11))
                        {
                        if(!keyWasPressed)
                            {
                            keyWasPressed = true;
                                cout << "\n Enabled" << endl;
    Skip();
                                Sleep(400);
                            }
                        else
                            {
                            keyWasPressed = false;
                                cout << "\n Disabled" << endl;
                               Sleep(400);
                            }
                        }
    But how do i make it so that when they press F11 it constantly does this code
    Code:
    cout << "\n Enabled" << endl;
    Skip();
    but as soon as they hit F11 again is disables the loop

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: How do i enable/disable a loop with getasynckeystate()

    You'd be better explain what you are trying to achieve!
    Then you could, perhaps get some suggestions about how to do/implement it.

    BTW, where is the code you posted supposed to work? In what application/process/thread?
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured