Mouse / Keyboard Automation for Linux
Suppose your favourite videogame/MiMORPG decides to take almost two minutes per manufactured Leaky Treebark Flask, just as you had bought 80 Wooly Mushrooms which need 80 flasks made to then be turned into Improbable Oil via the world renowned Improbable Oil Schenectady. So that's like six hours or some shit right there, not to mention the Pointy Clumps of Slag and all that jazz. You're looking at two days to digest those sweet, sweet, delicious Wooly Mushrooms! And suppose further you can't just get pissed off at the devs and leave, for... congenital reasons, so to speak.
What the fuck do you do then ?!
Well, here's what I did :
- apt-get install xmacro, which is a few C++ scripts that make use of the horribly insecure construction that is the X window system.
- xmacrorec2 > herp.txt, after which you proceed to switch back to game, click "Collect All", then shift-clickii the Disgusting Goop into the craft table, then click the Treebark Shavings pileiii and type a 2 so it now reads 12 then drag it over, then click on the Coarse Frangible Thread pile, delete the 12, put in a 3 and move it over.
- sed /\n/\nDelay 0.2\n/ to introduce delays everywhere because somehow xmacro hasn't thought of this.
- nano herp.txt, which should look at this point something like
MotionNotify 1055 522
Delay 0.6
ButtonPress 1
Delay 0.6
ButtonRelease 1
Delay 0.6
MotionNotify 920 520
Delay 0.6
KeyStrPress Shift_L
Delay 0.6
ButtonPress 1
Delay 0.6
ButtonRelease 1
Delay 0.6
MotionNotify 1135 535
Delay 0.6
KeyStrRelease Shift_L
Delay 0.6
MotionNotify 1145 530
Delay 0.6
ButtonPress 1
Delay 0.6
ButtonRelease 1
Delay 0.6
MotionNotify 914 570
Delay 0.6
ButtonPress 1
Delay 0.6
ButtonRelease 1
Delay 0.6
KeyStrPress 2
Delay 0.1
KeyStrRelease 2
Delay 0.6
MotionNotify 870 618
Delay 0.6
ButtonPress 1
Delay 0.6
ButtonRelease 1
Delay 0.6
MotionNotify 1129 563
Delay 0.6
ButtonPress 1
Delay 0.6
ButtonRelease 1
Delay 0.6
MotionNotify 921 618
Delay 0.6
ButtonPress 1
Delay 0.6
ButtonRelease 1
Delay 0.6
KeyStrPress BackSpace
Delay 0.2
KeyStrRelease BackSpace
Delay 0.6
KeyStrPress BackSpace
Delay 0.2
KeyStrRelease BackSpace
Delay 0.6
MotionNotify 920 618
Delay 0.6
KeyStrPress 3
Delay 0.1
KeyStrRelease 3
Delay 0.6
MotionNotify 884 661
Delay 0.6
ButtonPress 1
Delay 0.6
MotionNotify 889 662
Delay 0.6
ButtonRelease 1
Delay 0.6
MotionNotify 1179 571
Delay 0.6
ButtonPress 1
Delay 0.6
ButtonRelease 1
Delay 0.6
MotionNotify 1060 482
Delay 0.6
ButtonPress 1
Delay 0.6
ButtonRelease 1to add a Delay 108 right up top (this number works for me, ymmv).
- while :; do xmacroplay "$DISPLAY" < herp.txt; done; and you can now step safely away. The thing will wake up and do a succession of clicks resulting in the desired craft process being started every almost two minutes. You can chat in game or anything you wish - it's not liable to be bothered or care about you at all.
Nifty, huh ?
———- Totally Massive. Like... I think earlier today there were five people on! At the same time and everything! [↩]
- Shift-click takes one out of a stack, ctrl-click takes the whole stack, plain click pops up a number selection dialogue. [↩]
- 1300 items! From a previous lucky hit that yielded 1600 of the things in one go! 160`000% returns on that click! [↩]
Friday, 10 July 2015
Hmm, what if the time between actions is somewhat variable? Manually editing times in the macro (and guessing them right) is a pain.
On Windows one could use Advanced Key and Mouse Recorder. It remembers even cursor movement and key presses, although the latter functionality is unreliable. At any rate it beats any tools I've found for Linux so far ;/
Friday, 10 July 2015
Since the tool simply reads the file on each iteration, you can add a sed to rnd the values in between runs, providing you don't run it VERY often.
If you're manical you can also get the exact nanosecond time of your clicks by overloading with something like a watcher that writes out the exact timestamp of the file changes.
Linux wins because Linux is Lego for adults.