Domanda

I've become a fan of Autokey for a number of automation tasks and understand how to import & execute python from inside the program

what I haven't been able to figure out is how / whether it's possible to import the autokey libraries (python scripts) to be executed from outside the program

is this even possible? I get a variety of dependency errors based on a number of attempts, will posting pastebin of failed attempts if no-one has a quick answer with the elusive obvious I've been missing

UPDATE

Went through the process again, mainly I'm trying to access the Keyboard class

from autokey.scripting import Keyboard

produces error

In [1]: from autokey.scripting import Keyboard
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-9721ccad71fb> in <module>()
----> 1 from autokey.scripting import Keyboard

/usr/local/lib/python2.7/dist-packages/autokey/scripting.py in <module>()
     17 
     18 import subprocess, threading, time, re
---> 19 import common, model, iomediator
     20 if common.USING_QT:
     21     from PyQt4.QtGui import QClipboard, QApplication

/usr/local/lib/python2.7/dist-packages/autokey/model.py in <module>()
     17 
     18 import re, os, os.path, glob, logging
---> 19 from configmanager import *
     20 from iomediator import Key, NAVIGATION_KEYS, KEY_SPLIT_RE
     21 from scripting import Store

/usr/local/lib/python2.7/dist-packages/autokey/configmanager.py in <module>()
    712 from model import *
    713 
--> 714 class GlobalHotkey(AbstractHotkey):
    715     """
    716     A global application hotkey, configured from the advanced settings dialog.

NameError: name 'AbstractHotkey' is not defined

trying to import AbstractHotkey directly

from autokey.model import AbstractHotkey

gives the error

In [4]: from autokey.model import AbstractHotkey
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-4-fddf923ec053> in <module>()
----> 1 from autokey.model import AbstractHotkey

/usr/local/lib/python2.7/dist-packages/autokey/model.py in <module>()
     17 
     18 import re, os, os.path, glob, logging
---> 19 from configmanager import *
     20 from iomediator import Key, NAVIGATION_KEYS, KEY_SPLIT_RE
     21 from scripting import Store

/usr/local/lib/python2.7/dist-packages/autokey/configmanager.py in <module>()
    712 from model import *
    713 
--> 714 class GlobalHotkey(AbstractHotkey):
    715     """
    716     A global application hotkey, configured from the advanced settings dialog.

NameError: name 'AbstractHotkey' is not defined

trick is that model.py has

from configmanager import *

at line 19, creating a circular dependency

suppose I could create a patch but still curious if anyone has a method that doesn't require editing core files?

È stato utile?

Soluzione

Autokey does not provide a library that is usable outside the context of a Script triggered from inside the Autokey application.

So, no. Patches welcome, but the functionality you desire does not yet exist.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top