Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inserting Phrase/ Script Output on QT doesn't work via "KEYBOARD" #274

Closed
bantinho opened this issue Apr 24, 2019 · 4 comments
Closed

Inserting Phrase/ Script Output on QT doesn't work via "KEYBOARD" #274

bantinho opened this issue Apr 24, 2019 · 4 comments
Labels
bug phrase expansion Issues related to Phrases

Comments

@bantinho
Copy link

Classification:

Bug

Reproducibility:

Always

Version

AutoKey version: 0.95.6

Used GUI (Gtk, Qt, or both): Qt

If the problem is known to be present in more than one version, please list all of those.

Installed via: yay (AUR https://aur.archlinux.org/packages/autokey/)

Linux Distribution: Manjaro with Kernel 4.19.34-1 and Python 3.7.3

Summary

I can assign abbreviations to scripts or phrases and when using "Paste using keyboard" the abbreviations gets deleted but the actual phrase or output is not there.

Steps to Reproduce (if applicable)

  • enter abbreviation in any text editor/ text field

Expected Results

  • Delete triggering abbreviation and paste output from script

Actual Results

  • triggering abbreviation is being deleted but nothing is pasted
Input stack at end of handle_keypress: deque([' ', '#', 'D'], maxlen=150)
Key.SHIFT released
Raw key: ' ', modifiers: [], Key:  
Window visible title: 'AutoKey', Window class: 'autokey-qt.autokey-qt'
No phrase/script matched hotkey
Script runner executing: Script('Insert Date')
Send special key: [<Key.BACKSPACE: '<backspace>'>]
Input stack at end of handle_keypress: deque([], maxlen=150)
Ignored locking error in handle_keypress
Traceback (most recent call last):
  File "/home/me/.local/lib/python3.7/site-packages/autokey/service.py", line 206, in __tryReleaseLock
    self.configManager.lock.release()
RuntimeError: release unlocked lock
Send special key: [<Key.BACKSPACE: '<backspace>'>]
Send via event interface
Send via event interface
Send special key: [<Key.BACKSPACE: '<backspace>'>]
Sending string: 'April, 24 2019'
Error in X event loop thread
Traceback (most recent call last):
  File "/home/me/.local/lib/python3.7/site-packages/autokey/interface.py", line 242, in __eventLoop
    method(*args)
  File "/home/me/.local/lib/python3.7/site-packages/autokey/interface.py", line 705, in __sendString
    self.__checkWorkaroundNeeded()
  File "/home/me/.local/lib/python3.7/site-packages/autokey/interface.py", line 1005, in __checkWorkaroundNeeded
    w = self.app.configManager.workAroundApps
AttributeError: 'ConfigManager' object has no attribute 'workAroundApps'

Notes

Pasting phrases using SHIFT + INSERT or CTRL + V works fine

@luziferius
Copy link
Collaborator

luziferius commented Apr 24, 2019

Thank you for reporting this.

This traceback in the log snipped puzzles me a bit.

Traceback (most recent call last):
  File "/home/me/.local/lib/python3.7/site-packages/autokey/interface.py", line 242, in __eventLoop
    method(*args)
  File "/home/me/.local/lib/python3.7/site-packages/autokey/interface.py", line 705, in __sendString
    self.__checkWorkaroundNeeded()
  File "/home/me/.local/lib/python3.7/site-packages/autokey/interface.py", line 1005, in __checkWorkaroundNeeded
    w = self.app.configManager.workAroundApps
AttributeError: 'ConfigManager' object has no attribute 'workAroundApps'

This workAroundApps attribute is added during the application startup, while AutoKey loads the global configuration from it’s configuration file. Here (at the bottom of the quoted section):

def load_global_config(self):
if os.path.exists(CONFIG_FILE):
_logger.info("Loading config from existing file: " + CONFIG_FILE)
with open(CONFIG_FILE, 'r') as pFile:
data = json.load(pFile)
version = data["version"]
if version < "0.80.0":
try:
convert_v07_to_v08(data)
self.config_altered(True)
except Exception as e:
_logger.exception("Problem occurred during conversion.")
_logger.error("Existing config file has been saved as %s%s",
CONFIG_FILE, version)
raise
if version < "0.95.3":
convert_rename_autostart_entries_for_v0_95_3()
self.VERSION = data["version"]
self.userCodeDir = data["userCodeDir"]
apply_settings(data["settings"])
self.workAroundApps = re.compile(self.SETTINGS[WORKAROUND_APP_REGEX])

The only possibility that this is missing, is if the condition checked by the if at the top is False, thus there is no global configuration file at present at application startup.
This in turn means, that AK is either not allowed to write it’s configuration file or is started for the first time.

AutoKey says that it is Sending string: 'April, 24 2019'. And then breaks. The mentioned workaround is for certain Qt4 applications that behave badly under AutoKey, where the original author found a workaround for. It is checked before the phrase is expanded. That’s why the abbreviation is deleted, but then nothing happens.

What happens, if you just restart AutoKey?

(If the restart fixes it, report it back, but don’t just close this issue as solved. Then it is a bug during the first start, which should get fixed, too.)

@luziferius luziferius added bug phrase expansion Issues related to Phrases labels Apr 24, 2019
@bantinho
Copy link
Author

Hi @luziferius, rebooting the system did help. The issue is now gone.

thanks!

PS: the team did a great job! autokey is exactly the program that I needed when I switched from Windows and Autohotkey to Manjaro and it is so much more comprehensible then autohotkey since it's based on python. 💯

@luziferius
Copy link
Collaborator

I think this issue, which only manifests on the first start, was there for about 8 years or so, yet no-one complained as far as I know.

I wonder how many first time users went like "install" -> "try out a basic test phrase" -> "doesn't work" -> "uninstall"…

The fix is quite simple and will be in the next version.

@luziferius luziferius added this to the Bugfix release 0.95.7 milestone Apr 27, 2019
@luziferius
Copy link
Collaborator

I pushed a fix for this. This should prevent new users from running into this issue again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug phrase expansion Issues related to Phrases
Projects
None yet
Development

No branches or pull requests

2 participants