0

I try to get a list of active windows currently running in Windows 10. The same list as the alt+tab window shows. this is working find, but I also need the icons of these windows. Unfortunately this is not working. The following code returns a pointer which should be an hicon. But I have no idea how to interpret the hicon. How can I translate this to an image?

const user32 = new ffi.Library('user32', {
    'SendMessageA': ['pointer', ['long', 'int32', 'long', 'int32']]
});

let WMessages = {WM_GETICON: 0x007F}
let hicon = user32.SendMessageA(hwnd, WMessages.WM_GETICON , 2, 0)
// how to translate hicon to an nodejs icon?

this logic is inside an EnumWindows loop but I cut it, since it is not of relevence for my issue. I am using ffi-napi and ref-napi to make native library call.

Any help is appreciated, thanks

  • How will you use it after translate? Maybe you can directly use hicon. Or refer to [this example](https://stackoverflow.com/a/4338491/10611792) to convert hicon to .ico file. – Drake Wu Feb 17 '21 at 02:16
  • @DrakeWu-MSFT Yes somehow I need to convert it, but there is no HICON representation in JavaScript. The issue I have is that I don't know how to convert this HICON to an image. – El Berro Feb 17 '21 at 10:22
  • Maybe you can directly use the example in the above comment to convert hicon into an icon file, and then use node.js to quote. Or directly convert the buffer read from hicon into an image: https://github.com/egy186/icojs#example – Drake Wu Feb 19 '21 at 03:38

0 Answers0