0

I am searching for a free software to create macros for games on Linux, that could work on any keyboard with a GUI.

I want it to do successive keystrokes and tweak the delay between each key.

Danyl Bekhoucha
  • 191
  • 1
  • 2
  • 8
  • It's not the same program and my scripts are dedicated for games with multiple inputs and delay. And i am not sure xbindkey would works in video games or is easier to use. – Danyl Bekhoucha May 02 '17 at 18:54
  • Yes, it's not exactly the same question, but it is essentially the same. You may want to give your question more detail to set it apart from the question I linked, then I would remove the duplicate flag. – wjandrea May 02 '17 at 20:32

1 Answers1

4

You must install the software Autokey, you can type this in the terminal:

sudo apt-get install autokey-gtk

Open it and click on New then Script and name it (you can also create a folder with the name of your game).

Keyboard

There is two important lines, here is the code for pressing the key "x":

keyboard.send_keys("x")

And here is how to add a delay, 1/10 of a second (try lower values until the game doesn't allow it, also keep in mind than an high ping can make some keys doesn't input if the delay is too low):

time.sleep(0.1)

Then repeat the code by adding a delay between each keys, for the last key you don't need to add a delay after it.

To hold a key type that, for example to hold then release Shift and typing x in between:

keyboard.press_key("<shift>")
keyboard.send_keys("x")
keyboard.release_key("<shift>")

Mouse

To click use this two commands:

mouse.click_relative_self(x, y, button)

mouse.click_absolute(x, y, button)

The first command is relative (to click near the mouse's current location) the second is absolute (from the entire screen). The button takes 3 arguments:

1: left click

2: middle click

3: right click

This script work best if you add a minimum of 0.1 second of sleep. Here an example to click at the center of the screen:

time.sleep(0.1)
mouse.click_absolute(1920/2, 1080/2, 1)

Comment

You can add a comment with "#":

keyboard.send_keys("x") # use a potion

Once your script is finished you can bind it to a key, bellow your script you will see script settings, at the line Hotkey click on Set and define a key. I recommend you to use the key F# to attach it or the key. You can test if your macro is working by opening a text editor like gedit.

For Dota it is better to use the in game queue feature, for example to use 3 items and one spell:

keyboard.send_keys("s") time.sleep(0.01) keyboard.press_key("") keyboard.send_keys("zxcq") # edit this line keyboard.release_key("")

Danyl Bekhoucha
  • 191
  • 1
  • 2
  • 8