-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
Labels
Comments
i want to ask if this function is work please send message or write doc |
it is from Raymond chen example to get altTab window it's worth to reference |
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); |
@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
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 forisWindow
, however only 1 window is actually openThe text was updated successfully, but these errors were encountered: