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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:25:43+00:00 2026-06-16T01:25:43+00:00

I have been trying to send mouse clicks to a WebBrowser control inside of

  • 0

I have been trying to send mouse clicks to a WebBrowser control inside of my form using PostMessage(), and I have run into a rather significant issue. What I am trying to achieve is to simulate mouse clicks on this WebBrowser while my form is minimized. Usually PostMessage() would work just fine doing this, but it seems that it only works while my form has focus. This leads me to believe that there is some check going on to see if the particular website I am loading into my WebBrowser control is in focus before it handles mouse events.

This is how I send the clicks with my program:

private void SendClick(Point location)
    {            
        resetHandle = true;
        StringBuilder className = new StringBuilder(100);
        while (className.ToString() != "Internet Explorer_Server") 
        {
            handle = GetWindow(handle, 5); // 5 == child
            GetClassName(handle, className, className.Capacity);
            //MessageBox.Show(className.ToString());
        }
        IntPtr lParam = (IntPtr)((location.Y << 16) | location.X); 
        IntPtr wParam = IntPtr.Zero; 
        const uint downCode = 0x201; 
        const uint upCode = 0x202;
        const uint moveCode = 0x200;
        PostMessage(handle, moveCode, wParam, lParam); //move mouse
        PostMessage(handle, downCode, wParam, lParam); // mousedown
        PostMessage(handle, upCode, wParam, lParam); // mouseup
    }

This is what the resetHandle does:

private void timer3_Tick(object sender, EventArgs e)
    {
        if (resetHandle == true)
        {
            handle = webBrowser1.Handle;
            resetHandle = false;
        }
    }

I’m not sure if there is a better way of sending mouse events to a background window and I am open to any ideas. What I am really asking though is if it is at all possible to make a window believe it is in focus when it is actually still minimized?

Any help at all would be much appreciated!

  • 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-06-16T01:25:44+00:00Added an answer on June 16, 2026 at 1:25 am

    Rather than keep the window minimized, keep it normal (restored), but set its X or Y coordinate so that it is positioned off screen.

    If you want give the user the illusion of minimizing and restoring it, use HwndSource.AddHook to watch for SC_MINIMIZE. In your HwndSourceHook handler, move the window on or off screen according to the pseudo-minimized state, and set handled to true.

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

Sidebar

Related Questions

I have been struggling with trying to send an email with an attachment using
I have been trying to send a big attachment (9 MB) using C# ASP.NET
Hello I have been trying to send an email in magento with out a
I have been trying to create a ListView which I can sort using drag
I have been trying to make custom radio buttons using HTML, CSS, and JavaScript.
I am trying to send some simple mouse down/up messages to Windows Calculator using
I have been trying to send out html emails through a PHP mail script
I have been trying to send an email by C#. I have Googled for
I have been trying to find out if MSbuild can send an email to
I have been trying to develop a Java ME application using WTK 2.5.2 (Java

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.