Skip to content

Instantly share code, notes, and snippets.

@fronterior
Last active April 22, 2022 11:41
Show Gist options
  • Save fronterior/7c7e5d9b041bf0b76f876767242de249 to your computer and use it in GitHub Desktop.
Save fronterior/7c7e5d9b041bf0b76f876767242de249 to your computer and use it in GitHub Desktop.
const ffi = require('ffi-napi');
const user32 = new ffi.Library('user32', {
FindWindowA: ['ulong', ['string', 'string']],
FindWindowExA: ['ulong', ['ulong', 'ulong', 'string', 'ulong']],
GetDesktopWindow: ['ulong', []],
SetWindowLongPtrA: ['ulong', ['int', 'int', 'int']],
SetWindowPos: [
'bool',
['ulong', 'ulong', 'int', 'int', 'int', 'int', 'uint'],
],
SetParent: ['ulong', ['ulong', 'ulong']],
MoveWindow: ['bool', ['ulong', 'int', 'int', 'int', 'int', 'bool']],
GetWindowTextA: ['ulong', ['ulong', 'string', 'int']],
});
const hwnd = user32.FindWindowA(null, 'Electron Fiddle - 16.0.2 Unsaved');
user32.SetWindowPos(hwnd, null, 0, 0, 300, 300, 0x0001);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment