Skip to content

Instantly share code, notes, and snippets.

@eioo
Created April 9, 2018 18:58
Show Gist options
  • Save eioo/8121b6587bd6fb3d8de2bc3675ff963a to your computer and use it in GitHub Desktop.
Save eioo/8121b6587bd6fb3d8de2bc3675ff963a to your computer and use it in GitHub Desktop.
import * as robot from 'robotjs';
import * as winctl from 'winctl';
import * as _ from 'lodash';
const typingSpeed = 350; // Chars in minute
const solutions = [
['play', 'pull door', 'remove pants', 'enter toilet', 'shit'],
['play', 'remove pants', 'shit'],
['play', 'shit'],
['play', 'pull door', 'enter toilet', 'shit'],
['play', 'die'],
['play', 'take pills', 'fart gently', () => sleep(1000 * 30)],
['shit'],
['play']
];
function sleep(ms) {
return new Promise(res => setTimeout(res, ms));
}
async function focusGameInput() {
winctl.FindByTitle("Adobe Flash").then(window => {
window.setForegroundWindow();
const dim = window.dimensions();
const inputX = dim.left + 150;
const inputY = dim.bottom - 35;
robot.moveMouse(inputX, inputY);
robot.mouseClick();
});
}
async function main() {
await focusGameInput();
for (let solution of solutions) {
for (let phase of solution) {
console.log(phase);
if (_.isFunction(phase)) {
await phase();
continue;
}
robot.typeStringDelayed(phase, typingSpeed);
await sleep(300);
robot.keyTap('enter');
await sleep(300);
}
await sleep(700);
await robot.keyTap('enter');
await sleep(400);
await robot.keyTap('enter');
await sleep(400);
console.log('');
}
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment