Closed YMC-GitHub closed 4 months ago
why close:(it works) active window before sending ctr,alt key with hardware
code sample:
function activeWindow(handle: number, hardware: boolean = false) {
const obj = hardware ? new Hardware(handle) : new Virtual(handle); // or Virtual
let cango = !obj.workwindow.isOpen() || !obj.workwindow.isForeground()
if (cango) {
obj.workwindow.setForeground();
}
}
async function sendKeys(handle: number, keys: any[], hardware: boolean = false) {
//keys :KeyboardButton | KeyboardButton[]
const obj = hardware ? new Hardware(handle) : new Virtual(handle); // or Virtual
await obj.keyboard.sendKey(keys);
}
activeWindow(wi.handle, true) //open window(active window) with hardware (with Virtual? you can try).
await sendKeys(wi.handle, ["alt", "y"], true)//works with hardware
await sendKeys(wi.handle, ["alt", "y"], false)//not works with Virtual
hey man, i would like to send modifier + key in virtual mode like ctrl + f
.
it could work with this code in virtual mode ?
PostMessageA(hWnd, isKeyDown ? WM_KEYDOWN : WM_KEYUP, key, 0 | (key << 16) | (0 << 24) | (0 << 29) | ((UINT)!isKeyDown << 30) | ((UINT)!isKeyDown << 31))
and i am rewrite(refator) some features like this repo in rust. could you give me some help?
i am reading docs like :
but i am newer in cpp.
like ctrl + v: sending ctrl with global mode with Hardware .eg :
await (new Hardware(0)).obj.keyboard.sendKey(["ctrl"])
await (new Virtual(handle)).obj.keyboard.sendKey(["v"]);
i am rewrite/refact some feature like this repo in rust based on deeean/sophia, see more in @yors/sophia!
Thanks for sharing, contributing.Your work has helped me a lot.Sorry to disturb you in your busy schedule!It is an honor and look forward to receiving your help! env:
code:
act: in some game window : it input
y
char to its input box!(they
key fired!) in vscode window: ( to debug if sendKey,toggleKey works in other window) it did not do nothing.expect: in some game window : enter some state. in vscode window: open finding view