Results 1 to 5 of 5
  1. #1
    258456's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    ghjghj
    Posts
    1,222
    Reputation
    18
    Thanks
    300
    My Mood
    Relaxed

    GetAsyncKeyState

    ok so here is my code, (not a keylogger).


    [php]#include <Windows.h>
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR CmdShow, int CmdLine)
    {


    MessageBox(NULL, TEXT("SUP"), TEXT("SUP"), NULL);


    if(GetAsyncKeyState(int (VK_NUMPAD9)) & 0)
    {
    MessageBox(NULL, TEXT("YES"), TEXT("SKD"), NULL);
    return 0;
    }

    }[/php]
    the problem is that after the user presses ok on the first message box the program shuts down, it doesn't wait until you press 9 on the num pad.

  2. #2
    C4P's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Posts
    34
    Reputation
    10
    Thanks
    2
    My Mood
    Happy
    use a loop

    Code:
    #include <Windows.h> 
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR CmdShow, int CmdLine) 
    { 
         
         
        MessageBox(NULL, TEXT("SUP"), TEXT("SUP"), NULL); 
         
     while (true)
    {
          if(GetAsyncKeyState(int (VK_NUMPAD9)) & 0) 
        { 
            MessageBox(NULL, TEXT("YES"), TEXT("SKD"), NULL); 
                             return 0; 
        } 
    }
    }
    this way, the code will wait untill you press numpad9, shows messagebox and will return from main (exit the program).

    a better way:
    while(!(GetAsyncKeyState(int (VK_NUMPAD9)) & 0)); // will till the key is pressed
    MessageBox(NULL, TEXT("YES"), TEXT("SKD"), NULL); // after the key is pressed the messagebox will appear
    return 0; //exit the program

  3. #3
    freedompeace's Avatar
    Join Date
    Jul 2010
    Gender
    female
    Posts
    3,033
    Reputation
    340
    Thanks
    2,792
    My Mood
    Sad
    You're checking if the key is pressed IMMEDIATELY after the user presses OKAY. Otherwise, you skip the code in the braces.

    use logic. The above code fixes it for you.

  4. #4
    258456's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    ghjghj
    Posts
    1,222
    Reputation
    18
    Thanks
    300
    My Mood
    Relaxed
    thanks guys, i tried ur code but it goes straight to the messagebox
    Last edited by 258456; 08-15-2010 at 02:00 AM.

  5. #5
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    Locked due to stupidity, try out stuff yourself and THINK >.>
    Ah we-a blaze the fyah, make it bun dem!

Similar Threads

  1. GetAsyncKeyState for Letters
    By ipwnuuaal5 in forum Combat Arms Hack Coding / Programming / Source Code
    Replies: 9
    Last Post: 08-17-2010, 05:36 PM
  2. GetAsyncKeyState how to properly use it?
    By Mr.Magicman in forum C++/C Programming
    Replies: 19
    Last Post: 07-30-2010, 03:42 AM
  3. [Help]GetAsyncKeyState
    By MintSlice in forum Visual Basic Programming
    Replies: 7
    Last Post: 03-22-2010, 10:49 AM
  4. Proper use of GetAsyncKeyState()
    By why06 in forum C++/C Programming
    Replies: 15
    Last Post: 02-28-2010, 04:07 AM
  5. [Help] GetAsyncKeyState(??) = X??
    By scriptkiddy in forum C++/C Programming
    Replies: 2
    Last Post: 10-12-2009, 10:59 AM