Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6614367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:19:49+00:00 2026-05-25T20:19:49+00:00

So I decided that I wanted to write a little keylogger tonight, just to

  • 0

So I decided that I wanted to write a little keylogger tonight, just to learn about getAsyncKeyState. I’m trying to get my log to write to a file but the file’s contents either show up blank or throw a random memory address at me (0x28fef0 before). I’ve heard that getAsyncKeyState doesn’t function well with Windows 7 x64, is it true?

This is pretty aggravating, I was hoping to actually be able to get this running tonight.

    while(1)
    {
        Sleep(20);
        for(DWORD_PTR key = 8; key <= 190; key++)
        {
            if (GetAsyncKeyState(key) == HC_ACTION)
                checkKey(key);
        }
    }

Function definition

void checkKey(DWORD_PTR key)
{
    ofstream out;
    out.open("log.txt");

        if (key==8)
            out << "[del]";
        if (key==13)
            out << "n";
        if (key==32)
            out << " ";
        if (key==VK_CAPITAL)
            out << "[CAPS]";
        if (key==VK_TAB)
            out << "[TAB]";
        if (key==VK_SHIFT)
            out << "[SHIFT]";
        if (key==VK_CONTROL)
            out << "[CTRL]";
        if (key==VK_PAUSE)
            out << "[PAUSE]";
        if (key==VK_ESCAPE)
            out << "[ESC]";
        if (key==VK_END)
            out << "[END]";
        if (key==VK_HOME)
            out << "[HOME]";
        if (key==VK_LEFT)
            out << "[LEFT]";
        if (key==VK_UP)
            out << "[UP]";
        if (key==VK_RIGHT)
            out << "[RIGHT]";
        if (key==VK_DOWN)
            out << "[DOWN]";
        if (key==VK_SNAPSHOT)
            out << "[PRINT]";
        if (key==VK_NUMLOCK)
            out << "[NUM LOCK]";
        if (key==190 || key==110)
            out << ".";
        if (key >=96 && key <= 105)
        {
            key -= 48;
            out << &key; // had ampersand
        }
        if (key >=48 && key <= 59)
            out << &key; // amp'd
        if (key !=VK_LBUTTON || key !=VK_RBUTTON)
        {
            if (key >=65 && key <=90)
            {
                if (GetKeyState(VK_CAPITAL))
                out << &key; // amp;d
            else
            {
                key = key +32;
                out << &key; // amp'd
            }
        }
        }
}

I’m seriously stumped by this issue and any help would be greatly appreciated. Why would a function like this work differently on a 64 bit system? Considering it’s the only box I’ve got I can’t run it on a 32 bit to check whether or not it’s an isolated issue. Because I’m assuming that it’s related to getAsyncKeyState and not my code (which compiles and creates a blank log file) I only included those two code snippets.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:19:50+00:00Added an answer on May 25, 2026 at 8:19 pm

    You’re using the function incorrectly. Reading the documentation before requesting help is usually a good idea…

    I’ll just quote MSDN here:

    If the function succeeds, the return value specifies whether the key
    was pressed since the last call to GetAsyncKeyState, and whether the
    key is currently up or down. If the most significant bit is set, the
    key is down, and if the least significant bit is set, the key was
    pressed after the previous call to GetAsyncKeyState. However, you
    should not rely on this last behavior; for more information, see the
    Remarks.

    That last part also means it’s completely useless for a key logger.

    PS: Consider using GetKeyNameText for translating virtual key codes into meaningful names.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to speed up my Numpy code and decided that I wanted
I created a Summer project for myself and decided that I wanted to write
Greetings, everyone. I'm trying to learn some Silverlight basics, and have decided to write
Update: Last night, I decided that this is just too much work to change
Just a technology update, now that .NET 4.0 is out. I write an application
Some days ago, I decided that it would be fun to write a streambuf
In designing my service, I decided that I wanted to customize the namespaces that
I've decided that I'm going to write an API for my music site. Something
I just read about the *args and **kwargs notation in python and decided to
I recently decided that I wanted to try learning how to program in assembly.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.