3

I have a class of static methods that I wrote as a supplement to the AutoKey API. I would like to include these in my scripts that I write in the autokey editor, but I've not been able to quite figure it out yet as my experience with python is still limited.

Where do I put my class-name.py file to be able to import it into autokey?

Clare Macrae
  • 3,473
  • 2
  • 26
  • 42
Ken
  • 1,110
  • 1
  • 10
  • 26
  • Can you alter the import path of autokey? – satoru Jan 16 '12 at 03:22
  • I can use the import directive in the scripts if that's what you mean. – Ken Jan 16 '12 at 03:30
  • If it's plain python, we should be able to append some path - where you place class-name.py - to `sys.path`, then we can import modules found in that path. – satoru Jan 16 '12 at 03:37
  • It's plain python. How do I go about doing that? – Ken Jan 16 '12 at 04:03
  • You may alter the `PYTHONPATH` environment variable. This is the related document: http://docs.python.org/library/sys.html#sys.path – satoru Jan 16 '12 at 04:10

1 Answers1

4

You just need to store all the python modules you're going to use with autokey under the same folder and select that folder as the User Module Folder in Preferences -> Script Engine.

For example, in the image below I've set ~/autokey as the directory where my helper modules are available:

User Module Folder

Note: The advice in the comments regarding changing PYTHONPATH/sys.path are also correct. The User Module Folder configuration basically appends the folder you select to sys.path to make the user modules available to your autokey scripts.

jcollado
  • 35,754
  • 6
  • 94
  • 129
  • of some reasons this solution did not work for me at home. as a workaround i using [rewrite-all.py](https://github.com/sl5net/Lintalist4Linux/blob/master/run-run-lintalistAHK-rewrite-all.py) – SL5net Sep 01 '20 at 09:53