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 58463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:51:07+00:00 2026-05-10T17:51:07+00:00

I would like to send some keystrokes from a C++ program into another window.

  • 0

I would like to send some keystrokes from a C++ program into another window.

For that reason I would like to have the user select the target window similar to how it is done in the Spy++ utility that comes with Visual Studio (drag a crosshair cursor over target window and have target window highlighted by a frame).

How is this dragging and selecting done in Windows? I am completely lost as to where I might start to look for a mechanism to implement this feature.

  • 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. 2026-05-10T17:51:07+00:00Added an answer on May 10, 2026 at 5:51 pm

    Here’s how it’s usually done:

    1. Capture the mouse using SetCapture. This will cause all mouse messages to be routed toward your app’s window.
    2. Handle the WM_MOUSEMOVE message. In your handler code, grab the window underneath the mouse using WindowFromPoint. That will get you the HWND of the window the mouse is currently over.
    3. Now that you’ve got the window, you need a device context (HDC). You can get one using GetWindowDC for the specified window.
    4. Now you can draw into the DC using typical GDI functions.

    There are some things you have to look out for – cleanly erasing the selection rectangle and so forth, but that’s one way to do it.

    You could also draw into a screen DC to do this, but in any case you’ll need the window handle in order to get the window rect.

    If you Google around Spy++ source code you’ll see a few examples of this technique.

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

Sidebar

Ask A Question

Stats

  • Questions 61k
  • Answers 61k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Table with 1 row: SELECT t1.*, t2.col2 FROM t1, (… May 11, 2026 at 9:50 am
  • added an answer Add the context menu to the rich text box, as… May 11, 2026 at 9:50 am
  • added an answer Maybe I read the problem wrong, but I believe you… May 11, 2026 at 9:50 am

Related Questions

I would like to send some keystrokes from a C++ program into another window.
Some of my data are 64-bit integers. I would like to send these to
I would like to send mail from a script on a Windows Server 2003
I'm working on a VB6 application and I would like to send a Type
I would like to quickly send email from the command line. I realize there
I would like to be able to render a view and send it as
I would like to use NTLM authentication with Tomcat so that Iexplorer send automatically
I need to send hundreds of newsletters, but would like to check first if
I would like to test a string containing a path to a file for
I would like to sort an array in ascending order using C/C++ . The

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.