Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distinguish between actual window and menubar app #34

Open
nahtnam opened this issue Dec 15, 2019 · 5 comments
Open

Distinguish between actual window and menubar app #34

nahtnam opened this issue Dec 15, 2019 · 5 comments
Labels
enhancement New feature or request platform/macos

Comments

@nahtnam
Copy link

nahtnam commented Dec 15, 2019

Hey,

I was wondering if there is any way to distinguish between a menu bar app and also the space? I am trying to capture and modify all of the open windows on a specific workspace/desktop. Right now when I call getWindows, I get about 15 and they all return true for isWindow, however only 1 window is actually open

@sentialx sentialx added the enhancement New feature or request label Dec 15, 2019
@WingDust
Copy link

i want to ask if this function is work please send message or write doc

@WingDust
Copy link

it is from Raymond chen example to get altTab window it's worth to reference
https://devblogs.microsoft.com/oldnewthing/20071008-00/?p=24863

@WingDust
Copy link

@nodgear
Copy link

nodgear commented Mar 16, 2021

This is the best i could do using FFI to interact with win32 api:

let voidPtr = ref.refType(ref.types.void);
let stringPtr = ref.refType(ref.types.CString);


const winapi = ffi.Library('User32', {
  GetDesktopWindow: [  'uint32',  [] ],
  ShowWindow: [  'bool',  ['uint32', 'int'] ],
  FindWindowA: [  'uint32',  ['string', 'uint32'] ],
  FindWindowExW: [  'uint32',  ['uint32', 'uint32', 'uint32', 'uint32'] ],
  GetWindowTextW: [ 'int32', ['uint32','string','int32'] ],
  IsWindowVisible: [ 'bool', ['uint32'] ],
  GetParent: [ 'uint32', ['uint32'] ],
  GetWindowLongPtrA: [ 'uint32', ['uint32', 'int'] ],
  EnumWindows: ['bool', [voidPtr, 'int32']],
  GetWindowTextA : ['long', ['long', stringPtr, 'long']],
  GetWindow: [ 'uint32', ['uint32', 'uint'] ],
  GetClassNameA: [ 'int', ['uint32', 'string', 'int'] ],
  IsHungAppWindow: [ 'bool', ['uint32'] ]
});

// WS_EX_NOREDIRECTIONBITMAP style
// GWL_EXSTYLE = 0x00200000

windowProc = ffi.Callback('bool', ['long', 'int32'], function(hwnd, lParam) {
  let buf, name, ret, visible, hasowner, haslong, test;
  buf = new Buffer.alloc(255);
  ret = winapi.GetWindowTextA(hwnd, buf, 255);
  name = ref.readCString(buf, 0);
  visible = winapi.IsWindowVisible(hwnd);
  hasowner = winapi.GetWindow(hwnd, 4); // GW_OWNER

  let ptr = winapi.GetWindowLongPtrA(hwnd, -20)
  // if (ptr == 0x00200000){
  //   console.log(`Window ${name} PTRA = 0x00200000`)
  // }

  if (name.length > 0 && visible && hasowner == 0) {
    if (ptr == 0x00200000) {
      // console.log("\nUWP:")
    }
    else{
        console.log(`N: ${name}`)
    }
    
}
  }

winapi.EnumWindows(windowProc, 0);

@showonne
Copy link

@nahtnam I'm facing the same problem, is there any better solution ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request platform/macos
Projects
None yet
Development

No branches or pull requests

5 participants