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

  • Home
  • SEARCH
  • 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 1808404
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:15:26+00:00 2026-05-17T06:15:26+00:00

my question is how to send some key’s to any application from application that

  • 0

my question is how to send some key’s to any application from application that is running in background? Let’s say that I made shortcut to LEFT ARROW key which is ALT+S, and than I want whenever I’m in any application and when I press ALT+S that background application response that shortcut and send to currently opened program LEFT ARROW key.
Here is a code that I made in Embarcadero c++ 2010 to simulate arrow left when pressing alt+s every 200 milisecond’s:

void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
     bool bBothPressed = GetAsyncKeyState(VK_MENU)  && GetAsyncKeyState(0x53);
    if(bBothPressed){
        // ShowMessage("control!");
        keybd_event(VK_LEFT, 0, 0, 0);
    }
} 

… and this work fine for my application, but what I want to know is how to include that code for global scope (any application), not just for this application.

  • 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-17T06:15:26+00:00Added an answer on May 17, 2026 at 6:15 am

    I strongly encourage you to use RegisterHotKey instead of GetAsyncKeyState. That way you won’t need a loop nor a Timer, thus making your application more reliable and responsive.

    To simulate the keypresses to another application/window, you need to:

    A) Focus the specific window:

    BringWindowToTop(hwnd);
    SetForegroundWindow(hwnd);
    SetFocus(hwnd);
    

    B) Send the keydown + keyup events:

    keybd_event(keycode, 0, KEYEVENTF_KEYDOWN, 0);
    keybd_event(keycode, 0, KEYEVENTF_KEYUP, 0);
    

    This should suffice. However, keep in mind the user might be already pressing one of the keys you’re simulating, thus the result might not be what you’re expecting. To avoid that, you need to check if the keys are already being pressed (use GetAsyncKeyState here), then send a keyup before doing B.

    UPDATE:

    If you wish to send the keypresses to whatever application is currently on the foreground (being focused), you can skip A.

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

Sidebar

Related Questions

I'm not understanding some key bit of ExtJs idiom so this question is about
I embedded .NET's WebBrowser into a form that has some other buttons. The application
This question and answer shows how to send a file as a byte array
So my question is if I can somehow send data to my program and
Question Can I build a image database/library that has an e-commerce style checkout system
Question says it all, really. My application is a time tracker. It's currently written
I'd like some feedback on my current architecture. I have a Person resource that
I'd like to store a set of key/value pairs in the application settings of
I have a feeling that I am going to ask a stupid question, yet
This is almost exactly the same as this question json get key names as

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.