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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:33:19+00:00 2026-05-25T14:33:19+00:00

Using JNA, my ultimate goal is to read a message that was sent using

  • 0

Using JNA, my ultimate goal is to read a message that was sent using Windows NET SEND or MSG.EXE, which appears as a Windows pop-up message window on the receiving machine.

I am already able to search for this specific message window and get the hWnd handle using the code below. My problem now is how to I iterate through all the elements of this window to find the actual message text, read the message, and also click the OK button?

My research tells me I need to use FindWindowEx (to go through the elements) and PostMessage (to click the OK button) but I am struggling to make it work.

package democode;

import com.sun.jna.Pointer;
import com.sun.jna.Native;
import com.sun.jna.win32.StdCallLibrary;

public class JNA_Main {
    // Equivalent JNA mappings
    public interface User32 extends StdCallLibrary {
    User32 INSTANCE = (User32) Native.loadLibrary("user32", User32.class);

    interface WNDENUMPROC extends StdCallCallback {
        boolean callback(Pointer hWnd, Pointer arg);
    }

    boolean EnumWindows(WNDENUMPROC lpEnumFunc, Pointer arg);

    boolean PostMessage(Pointer hwndParent, String msg, String wParam, String lParam);
    Pointer FindWindowEx(Pointer hwndParent, String hwndChildAfter, String lpszClass, String lpszWindow);

    int GetWindowTextA(Pointer hWnd, byte[] lpString, int nMaxCount);

    }

    public static void main(String[] args) {
    final User32 user32 = User32.INSTANCE;

    user32.EnumWindows(new User32.WNDENUMPROC() {

        int count;

        public boolean callback(Pointer hWnd, Pointer userData) {
        byte[] windowText = new byte[512];
        user32.GetWindowTextA(hWnd, windowText, 512);
        String wText = Native.toString(windowText);
        wText = (wText.isEmpty()) ? "" : "; text: " + wText;

        if (wText.contains("My Window Name")){
            System.out.println("Found window " + hWnd + ", total " + ++count + wText);

            //**************************************************//
            //NEED CODE HERE TO ITERATE THROUGH ELEMENTS OF THIS PARTICULAR WINDOW, READ THE MESSAGE TEXT AND CLICK OK BUTTON.
            //**************************************************//

        }

        return true;
        }
    }, null);
    }
}
  • 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-25T14:33:19+00:00Added an answer on May 25, 2026 at 2:33 pm

    The logical choice via the MSDN is to call EnumChildWindows using the hWnd pointer that you’ve received from the callback method above.

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

Sidebar

Related Questions

Using ASP.NET MVC there are situations (such as form submission) that may require a
The first difficulty in using JNA with J9 is that the J9 JVM does
I'm using JNA to manipulate application windows on Linux by sending Xlib messages but
I'm using JNA to call Carbon APIs. The particular API call that I want
How to interact with the Windows API using Java and the JNA (Java Native
I am using JNA with Java to find some properties about open windows on
Using Browserlab, it appears that the background image is not centred in Firefox7 for
Using JNA, the documentation says: Make your target library available to your Java program.
I'm trying to bind the dhcpctl library to Java using JNA. This is mi
Using C# .NET 3.5 and WCF, I'm trying to write out some of the

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.