Closed BobbyShoe closed 2 months ago
pls try this:
import { K, U } from 'win32-api'
const knl32 = K.load()
const user32 = U.load()
export class WinAutomationService {
private knl32: typeof knl32;
private user32: typeof user32;
constructor() {
this.knl32 = knl32;
this.user32 = user32;
}
// ....
}
AND this:
const hWnd: HANDLE = this.user32.FindWindowExW(0, 0, null, lpszWindow); // wrong parameter order
const hWnd: HANDLE = this.user32.FindWindowExW(0, 0, lpszWindow, null); // correct
I have the same problem. @BobbyShoe, did you find a solution?
Types updated
Hello,
I am getting this error when trying to use the win32-api in a typescript file and then compiling it with tsc.
"node_modules/win32-def/dist/lib/ffi.model.d.ts:26:18 - error TS2430: Interface 'FFIBuffer' incorrectly extends interface 'Buffer'. The types of 'ref(...).readObject' are incompatible between these types. Type '(offset?: number | undefined) => string' is not assignable to type '(buffer: Buffer, offset?: number | undefined) => Object'. Types of parameters 'offset' and 'buffer' are incompatible. Type 'Buffer' is not assignable to type 'number'.
26 export interface FFIBuffer extends Buffer {"
Below is my typescript class. I was basically just trying to run the sample to rename the calculator app. Any suggestions?
Thanks, Bobby
import { FModel, K, U } from 'win32-api' import { HANDLE } from 'win32-def/dist/lib/win.model';
export class WinAutomationService { private knl32: FModel.ExpandFnModel<K.Win32Fns>; private user32: FModel.ExpandFnModel<U.Win32Fns>;
}
Also here are all the node modules in my project if there happens to be a conflict here
+-- @electron-forge/cli@6.0.0-beta.54 +-- @electron-forge/maker-deb@6.0.0-beta.54 +-- @electron-forge/maker-rpm@6.0.0-beta.54 +-- @electron-forge/maker-squirrel@6.0.0-beta.54 +-- @electron-forge/maker-zip@6.0.0-beta.54 +-- @types/ffi@0.2.3 +-- @types/node-static@0.7.5 +-- asar@3.0.3 +-- electron@11.0.3 +-- electron-builder@22.9.1 +-- electron-squirrel-startup@1.0.0 +-- node@15.4.0 +-- node-static@0.7.11 +-- webpack@5.10.3 +-- webpack-cli@4.2.0 +-- win32-api@9.6.0 `-- win32-def@9.4.0