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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:27:30+00:00 2026-05-21T23:27:30+00:00

I need to send global keystrokes and mouse events to another application, which is

  • 0

I need to send global keystrokes and mouse events to another application, which is coincidentally using using DirectX. (No controls/handles other than the window itself)
For example, I need to hold key X for 2 seconds and then release it…
I need to push Right Click down on coordinates x:600 and y:350, move the mouse 100 pixels down and then release the Right Click.
I also need to push 2 or more keys at once, like X and Y, and stop X after 2 seconds and Y after 2 more seconds.
So basically I would need full control of the input system…
It would also be ideal if I could control the application while maximized or in background. (optionally)

For the skeptics… The teacher made a DirectX application for drawing for our school. I am asked to make an application that draws samples on it, like a train or flower or something… I will be reading images and use the input to set the color and click on the canvas…

  • 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-21T23:27:31+00:00Added an answer on May 21, 2026 at 11:27 pm

    There are some possibilities. You may have a look at System.Windows.Forms.SendKeys and you can pInvoke some Win32 functions like SetForegroundWindow(), LockSetForegroundWindow() from gdi32.dll or from user32.dll SetCursorPos() and mouse_event to perform clicks:

    Here a snippet for the Mouse events I used a while ago.

        /**
         * Mouse functions
         */
        [DllImport("user32.dll", ExactSpelling=true)]
        public static extern long mouse_event(Int32 dwFlags, Int32 dx, Int32 dy, Int32 cButtons, Int32 dwExtraInfo);
    
        [DllImport("user32.dll", ExactSpelling=true)]
        public static extern void SetCursorPos(Int32 x, Int32 y); 
    
        public const Int32 MOUSEEVENTF_ABSOLUTE = 0x8000;
        public const Int32 MOUSEEVENTF_LEFTDOWN = 0x0002;
        public const Int32 MOUSEEVENTF_LEFTUP = 0x0004;
        public const Int32 MOUSEEVENTF_MIDDLEDOWN = 0x0020;
        public const Int32 MOUSEEVENTF_MIDDLEUP = 0x0040;
        public const Int32 MOUSEEVENTF_MOVE = 0x0001;
        public const Int32 MOUSEEVENTF_RIGHTDOWN = 0x0008;
        public const Int32 MOUSEEVENTF_RIGHTUP = 0x0010;
    
        public static void PerformLeftKlick(Int32 x, Int32 y)
        {
            SetCursorPos(x, y);
            mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
            mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
        }
    

    Hope that pushes you in the right direction. A good resource is http://pinvoke.net/

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

Sidebar

Related Questions

I am working on a simple application in which I need send sms programmatically
I need to send signed emails from within my C# .NET application. Which is
I need to send MMS thought a C# application. I have already found 2
We need to send email which contains Pound (currency) symbols in ColdFusion. Before sending
I need to send emails to a list of IDs from the contact application,
I have a C++/CLI based install application which needs to close another app I've
I need to send messages to the GUI thread which should be processed the
I need to send documents to a network printer (\myserver\myprinter). I'm using the System.Printing
I need to send hundreds of newsletters, but would like to check first if
I need to send and receive data over serial connections (RS-232 and RS-422). How

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.