Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

29
LINES

< > BotCompany Repo | #1030296 - List Windows on Windows

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Uses 3917K of libraries. Click here for Pure Java version (2561L/16K).

!7

!include once #1030303 // JNA Win32

p {
  User32.INSTANCE.EnumWindows(new WNDENUMPROC {
     int count = 0;
     @Override
     public boolean callback(HWND hWnd, Pointer arg1) {
        char[] windowText = new[512];
        User32.INSTANCE.GetWindowText(hWnd, windowText, windowText.length);
        new RECT rect;
        User32.INSTANCE.GetWindowRect(hWnd, rect);
        S wText = Native.toString(windowText);

        // get rid of this if block if you want all windows regardless of whether
        // or not they have text
        if (wText.isEmpty()) {
           return true;
        }

        print("Found window with text " + hWnd + ", total " + ++count
              + " Text: " + wText + ", rect: " + rect);
        return true;
     }
  }, null);
  
  print("done");
}

download  show line numbers  debug dex   

Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx

No comments. add comment

Snippet ID: #1030296
Snippet name: List Windows on Windows
Eternal ID of this version: #1030296/10
Text MD5: 0e52bb681fe0ebffb83f95b666587558
Transpilation MD5: 722bb402fa08f625eb3cb9ff53f8cb33
Author: stefan
Category: javax / windows
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-11-30 13:41:52
Source code size: 816 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 30 / 79
Version history: 9 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1030296 & http://1030296.tinybrain.de