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

clipboard.get_selection sometimes fails #40

Closed
GoogleCodeExporter opened this issue May 9, 2015 · 5 comments
Closed

clipboard.get_selection sometimes fails #40

GoogleCodeExporter opened this issue May 9, 2015 · 5 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1.  Assign a hotkey to a script using clipboard.get_selection.
2.  Save, and close the configuration window.
3.  Try using the script on selected text.
This problem typically does not occur when AutoKey is first started, but
later it happens consistently.

What is the expected output? What do you see instead?
The script should successfully get the selected text, but it gives an error
instead.

What version of the product are you using? On what operating system?
AutoKey 0.70.2 on Ubuntu Hardy.

Please provide any additional information below.
The strange thing is that having the AutoKey configuration window open
guarantees that the error will not happen, and the script will work just
fine.  The error is not entirely predictable when the window is closed, but
never happens when it is open.  If I have the problem and then open the
configuration window and try the hotkey again, the script will work fine,
and if I close it, the error behavior will immediately return.  If I keep
the configuration window open all day, the error never happens.

I think I have experienced this issue all along, but with the frequent
improvements to AutoKey's hotkey handling I had hoped it was just a glitch
that would get worked out in the course of things.

Here is the log from executing "Selection Test" from the "Sample Scripts"
folder.

DEBUG - iomediator - <alt> pressed
DEBUG - iomediator - <ctrl> pressed
DEBUG - service - Key: u't', modifiers: ['<alt>', '<ctrl>']
INFO - service - Matched hotkey phrase/script with prompt=False
DEBUG - service - Script runner executing: Script('Selection Test')
DEBUG - iomediator - <ctrl> released
DEBUG - iomediator - <alt> released
ERROR - service - Script error
Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/autokey/service.py", line 378, in
execute
    exec script.code in self.scope
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/autokey/scripting.py", line 679,
in get_selection
    return self.text.decode("utf-8")
AttributeError: 'NoneType' object has no attribute 'decode'

If this is just due to Hardy having an older Xorg, then I can just leave
the configuration window open until I upgrade.

Original issue reported on code.google.com by dv8box-...@yahoo.com on 19 Apr 2010 at 12:47

@GoogleCodeExporter
Copy link
Author

This error occurs when there is no text received from the X selection. There is
nothing that can be done about it, probably would be good to have a nicer error 
from
AutoKey though.

Original comment by cdekter on 19 Apr 2010 at 2:21

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

Any idea why it would only happen when the AutoKey configuration window is not 
open?

Original comment by dv8box-...@yahoo.com on 19 Apr 2010 at 3:29

@GoogleCodeExporter
Copy link
Author

No idea... there's a small test you could try though:

In the method __execAsync() at line 713 of 
/usr/share/pyshared/autokey/scripting.py,
replace the entire method body with the following code:
        self.sem = threading.Semaphore(0)
        gtk.gdk.threads_enter()
        callback(*args)
        gtk.gdk.threads_leave()
        self.sem.acquire()

See if that improves the reliability...

Original comment by cdekter on 19 Apr 2010 at 3:37

@GoogleCodeExporter
Copy link
Author

I think that may have fixed it.  I used it last night and this morning, and it 
has
not failed at all.  Thanks.

Original comment by dv8box-...@yahoo.com on 19 Apr 2010 at 12:44

@GoogleCodeExporter
Copy link
Author

Fix released in v0.70.3

Original comment by cdekter on 22 Apr 2010 at 6:16

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant