Hello, my goal is to simulate keyboard presses in JavaScript and send them at regular intervals in the text input of messaging application.
However, not being a professional of JavaScript, I face several problems in my program below :
1) Being sure that the keystroke simulation is triggered.
2) Apply the right input format for the application, in my program I have "windows" but it triggers an error in the execution of the program because it does not run in an HTML page.
3) Finally, send the function of the simulated keys after "send".
Here is the end of my program in question :
If you have some solutions, thanks in advance for your help
However, not being a professional of JavaScript, I face several problems in my program below :
1) Being sure that the keystroke simulation is triggered.
2) Apply the right input format for the application, in my program I have "windows" but it triggers an error in the execution of the program because it does not run in an HTML page.
3) Finally, send the function of the simulated keys after "send".
Here is the end of my program in question :
JavaScript:
var keys = {};
window.addEventListener('keydown', (e) => {
keys[e.key] = true;
if(keys['a'] && keys['v'])
console.log('A + V');
});
window.addEventListener('keyup', (e) => {
keys[e.key] = false;
});
document.dispatchEvent(
new KeyboardEvent("keydown", {
key: "v",
bubbles: true
})
);
document.dispatchEvent(
new KeyboardEvent("keydown", {
key: "a",
bubbles: true
})
);
setInterval(() => {
client.channels.cache.get('identifier_channel').send();
}, 50);
});
If you have some solutions, thanks in advance for your help