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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:06:15+00:00 2026-05-13T07:06:15+00:00

I’m interested in working on a plugin for Keepass , the open-source password manager.

  • 0

I’m interested in working on a plugin for Keepass, the open-source password manager. Right now, Keepass currently detects what password to copy/paste for you based off of the window title. This prevents Keepass from detecting the current password you need for apps that don’t actively update their window title based on the current site (Chrome for instance).

How can I walk through another processes window elements (buttons, labels, textbox) similar to how Spy++ works? When you run Spy++ you can hover over other programs windows and get all kinds of information about various properties concerning various controls (labels, textboxes, etc). Ideally, I’d like my Keepass plugin to enhance the current window detection by walking through the active window’s elements in an effort to find a matching account to copy/paste the password.

How can I walk other processes window elements and be able to retrieve label and textbox values using C#?

  • 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-13T07:06:15+00:00Added an answer on May 13, 2026 at 7:06 am

    I’ve being answering similar questions like this here: How can I detect if a thread has windows handles?. Like it states, the main idea is to enumerate through process windows and their child windows using EnumWindows and EnumChildWindows API calls to get window handles and then call GetWindowText or SendDlgItemMessage with WM_GETTEXT to get window text. I’ve modified code to make an example which should be doing what you need (sorry it’s a bit long :). It iterates through processes and their windows and dumps window text into console.

    static void Main(string[] args)
    {
        foreach (Process procesInfo in Process.GetProcesses())
        {
            Console.WriteLine("process {0} {1:x}", procesInfo.ProcessName, procesInfo.Id);
            foreach (ProcessThread threadInfo in procesInfo.Threads)
            {
                // uncomment to dump thread handles
                //Console.WriteLine("\tthread {0:x}", threadInfo.Id);
                IntPtr[] windows = GetWindowHandlesForThread(threadInfo.Id);
                if (windows != null && windows.Length > 0)
                    foreach (IntPtr hWnd in windows)
                        Console.WriteLine("\twindow {0:x} text:{1} caption:{2}",
                            hWnd.ToInt32(), GetText(hWnd), GetEditText(hWnd));
            }
        }
        Console.ReadLine();
    }
    
    private static IntPtr[] GetWindowHandlesForThread(int threadHandle)
    {
        _results.Clear();
        EnumWindows(WindowEnum, threadHandle);
        return _results.ToArray();
    }
    
    // enum windows
    
    private delegate int EnumWindowsProc(IntPtr hwnd, int lParam);
    
    [DllImport("user32.Dll")]
    private static extern int EnumWindows(EnumWindowsProc x, int y);
    [DllImport("user32")]
    private static extern bool EnumChildWindows(IntPtr window, EnumWindowsProc callback, int lParam);
    [DllImport("user32.dll")]
    public static extern int GetWindowThreadProcessId(IntPtr handle, out int processId);
    
    private static List<IntPtr> _results = new List<IntPtr>();
    
    private static int WindowEnum(IntPtr hWnd, int lParam)
    {
        int processID = 0;
        int threadID = GetWindowThreadProcessId(hWnd, out processID);
        if (threadID == lParam)
        {
            _results.Add(hWnd);
            EnumChildWindows(hWnd, WindowEnum, threadID);
        }
        return 1;
    }
    
    // get window text
    
    [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
    static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
    [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
    static extern int GetWindowTextLength(IntPtr hWnd);
    
    private static string GetText(IntPtr hWnd)
    {
        int length = GetWindowTextLength(hWnd);
        StringBuilder sb = new StringBuilder(length + 1);
        GetWindowText(hWnd, sb, sb.Capacity);
        return sb.ToString();
    }
    
    // get richedit text 
    
    public const int GWL_ID = -12;
    public const int WM_GETTEXT = 0x000D;
    
    [DllImport("User32.dll")]
    public static extern int GetWindowLong(IntPtr hWnd, int index);
    [DllImport("User32.dll")]
    public static extern IntPtr SendDlgItemMessage(IntPtr hWnd, int IDDlgItem, int uMsg, int nMaxCount, StringBuilder lpString);
    [DllImport("User32.dll")]
    public static extern IntPtr GetParent(IntPtr hWnd);
    
    private static StringBuilder GetEditText(IntPtr hWnd)
    {
        Int32 dwID = GetWindowLong(hWnd, GWL_ID);
        IntPtr hWndParent = GetParent(hWnd);
        StringBuilder title = new StringBuilder(128);
        SendDlgItemMessage(hWndParent, dwID, WM_GETTEXT, 128, title);
        return title;
    }
    

    hope this helps, regards

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

Sidebar

Ask A Question

Stats

  • Questions 394k
  • Answers 394k
  • 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
  • Editorial Team
    Editorial Team added an answer It's not exactly what you asked, but Solaris has a… May 15, 2026 at 2:28 am
  • Editorial Team
    Editorial Team added an answer The connection strings in the library project are never used,… May 15, 2026 at 2:28 am
  • Editorial Team
    Editorial Team added an answer For speed and ease of use, I would generally leave… May 15, 2026 at 2:28 am

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.