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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:34:35+00:00 2026-06-02T18:34:35+00:00

I’ve got a C# problem, I am able to simulate a click to the

  • 0

I’ve got a C# problem,

I am able to simulate a click to the current window, but I would like to do it if the window is minimized or hidden.

Any ideas?

  • 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-02T18:34:36+00:00Added an answer on June 2, 2026 at 6:34 pm

    Here is a fully working snippet which will give you the window handle, target sub window and post a message to that subwindow.

    #include "TCHAR.h"
    #include "Windows.h"
    
    int _tmain(int argc, _TCHAR* argv[])
    {
        HWND hwndWindowTarget;
        HWND hwndWindowNotepad = FindWindow(NULL, L"Untitled - Notepad");
        if (hwndWindowNotepad)
        {
            // Find the target Edit window within Notepad.
            hwndWindowTarget = FindWindowEx(hwndWindowNotepad, NULL, L"Edit", NULL);
            if (hwndWindowTarget) {
                PostMessage(hwndWindowTarget, WM_CHAR, 'G', 0);
            }
        }
    
        return 0;
    }
    

    At the moment it will send the G character to notepad “Untitled” (open a new notepad, do nothing.

    You can find the sub-window using spy++ which comes with visual studio.

    Here is an example using SendInput to send mouse events:

    #include "TCHAR.h"
    #include "Windows.h"
    
    int _tmain(int argc, _TCHAR* argv[])
    {
        POINT pt;
        pt.x = 300;
        pt.y = 300;
    
        HWND hwndWindowTarget;
        HWND hwndWindowNotepad = FindWindow(NULL, L"Untitled - Notepad");
        if (hwndWindowNotepad)
        {
            // Find the target Edit window within Notepad.
            hwndWindowTarget = FindWindowEx(hwndWindowNotepad, NULL, L"Edit", NULL);
            if (hwndWindowTarget) {
                PostMessage ( hwndWindowTarget, WM_RBUTTONDOWN, 0, (pt.x) & (( pt.y) << 16) );
                PostMessage ( hwndWindowTarget, WM_RBUTTONUP, 0, (pt.x ) & (( pt.y) << 16) );
            }
        }
    
        return 0;
    }
    

    Sorry this took so long, here’s the C# version:

    using System;
    using System.Runtime.InteropServices;
    
    namespace Sandbox
    {
        class Program
        {
            [DllImport("user32.dll")]
            static extern bool PostMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
    
            [DllImport("user32.dll")]
            static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
    
            [DllImport("user32.dll")]
            static extern IntPtr FindWindowEx(IntPtr hWnd, string lpClassName, string lpWindowName, string lParam);
    
            public const Int32 WM_CHAR = 0x0102;
            public const Int32 WM_KEYDOWN = 0x0100;
            public const Int32 WM_KEYUP = 0x0101;
            public const Int32 VK_RETURN = 0x0D;
    
            public const string windowName = "Untitled - Notepad";
    
            static void Main(string[] args)
            {
                Console.WriteLine($"Finding {windowName}");
                var hwndWindowNotepad = FindWindow(null, "Untitled - Notepad");
    
                if (hwndWindowNotepad != 0)
                {
                    // Find the target Edit window within Notepad.
                    var hwndWindowTarget = FindWindowEx(hwndWindowNotepad, null, "Edit", null);
                    if (hwndWindowTarget != 0)
                    {
                        Console.WriteLine($"Sending Char to {windowName}");
                        PostMessage(hwndWindowTarget, WM_CHAR, 'G', 0);
                    }
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to count the length of a string with PHP. The string
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from

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.