-
Notifications
You must be signed in to change notification settings - Fork 53
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
compatible with regular JavaScript? #38
Comments
Yes, it supports plan js.
simple example import ref from 'ref-napi'
import { DModel as M } from 'win32-api'
import { Kernel32, User32 } from 'win32-api/promise'
const knl32 = Kernel32.load()
const user32 = User32.load()
const lpszClass = Buffer.from('guard64\0', 'ucs2')
const hInstanceBuffer = ref.alloc(W.HANDLE_PVOID)
const hInstanceAddr = ref.address(hInstanceBuffer)
await knl32.GetModuleHandleExW(0, lpszClass, hInstanceAddr) to const ref = require('ref-napi')
const { DModel as M } = require('win32-api')
const { Kernel32, User32 } = require('win32-api/promise') // <--- not sure this syntax
const knl32 = Kernel32.load()
const user32 = User32.load()
const lpszClass = Buffer.from('guard64\0', 'ucs2')
const hInstanceBuffer = ref.alloc(W.HANDLE_PVOID)
const hInstanceAddr = ref.address(hInstanceBuffer)
await knl32.GetModuleHandleExW(0, lpszClass, hInstanceAddr) |
const point = StructFactory<M.POINT>(DS.POINT)
point.x = 100 to const point = StructFactory(DS.POINT)
point.x = 100 |
Thanks for the quick reply! I tried your code but I get the error: App threw an error during load const hInstanceBuffer = ref.alloc(W.HANDLE_PVOID) I don't know if makes a difference but I'm trying to use it to make an electron app, Also I downloaded your repo (to try typescript version) and tried to run "npm run bootstrap" but it could not find lerna command. And I'm not too familiar with Win32 API but would this module let me send text to Notepad? Can you show a SendMessage example? In regular javascript please |
try : import {
DModel as M,
DTypes as W,
DStruct as DS,
} from 'win32-api'
// to
const {
DModel as M,
DTypes as W,
DStruct as DS,
} = require('win32-api') |
You can install lerna as global pkg npm i -g lerna |
const { as syntax is not supported This works though :) const ref = require('ref-napi') const M=DModel; const { Kernel32, User32 } = require('win32-api/promise') const knl32 = Kernel32.load() const lpszClass = Buffer.from('guard64\0', 'ucs2') async function main() { Could you show me a send text to notepad example please?? that's all I really need to use this class for to hopefully replace AHK (autohotkey)I think it's the SendMessage (or PostMessage) API but not familiar with it. |
see demo |
Is this compatible with regular or plain JavaScript? or is there a plain JavaScript version? if so can you show an example because I'm not familiar with typescript, coffeescript, all the pointless JavaScript variations, etc. and I prefer normal / regular / original JavaScript.
The text was updated successfully, but these errors were encountered: