caldurza / autokey

Automatically exported from code.google.com/p/autokey
GNU General Public License v3.0
0 stars 0 forks source link

Is there anyway to escape special keys, so the string is printed instead? #130

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.phrase contents:
<code></code><left><left><left><left><left><left><left>
2.Abbreviation: :cde
3.Type ":cde"

What is the expected output? What do you see instead?
"<code>|</code>" (where cursor position = |), instead keyboard input hangs. 

What version of the product are you using? On what operating system?
AutoKey (GTK UI) 0.71.2 on Ubuntu 11.04

Please provide any additional information below.
autokey-gtk -l shows the following error message:

DEBUG - interface - Send special key: [u'<code>']
Exception in thread KeypressHandler-thread:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/dist-packages/autokey/iomediator.py", line 203, in run
    target.handle_keypress(rawKey, modifiers, key, windowName)
  File "/usr/lib/python2.7/dist-packages/autokey/service.py", line 175, in handle_keypress
    self.__processItem(item, currentInput)
  File "/usr/lib/python2.7/dist-packages/autokey/service.py", line 288, in __processItem
    self.phraseRunner.execute(item, buffer)
  File "/usr/lib/python2.7/dist-packages/autokey/service.py", line 52, in new_function
    return f(*args, **kw)
  File "/usr/lib/python2.7/dist-packages/autokey/service.py", line 338, in execute
    mediator.send_string(expansion.string)
  File "/usr/lib/python2.7/dist-packages/autokey/iomediator.py", line 248, in send_string
    self.interface.send_key(section)
  File "/usr/lib/python2.7/dist-packages/autokey/interface.py", line 488, in send_key
    self.__sendKeyCode(self.__lookupKeyCode(keyName))
  File "/usr/lib/python2.7/dist-packages/autokey/interface.py", line 657, in __lookupKeyCode
    return int(char[5:-1])
ValueError: invalid literal for int() with base 10: ''

I assume the problem is caused because Autokey is assuming the <code> html tag 
is actually a <code> special key. Is there any way to escape the special keys, 
so Autokey will print the special key string? 

Original issue reported on code.google.com by deferred...@gmail.com on 11 Jul 2011 at 3:42

GoogleCodeExporter commented 8 years ago
There is no escape method for this, but you could do it with a script instead:
keyboard.send_keys("<code></code>")
keyboard.send_key("<left>", 7)

Original comment by cdekter on 11 Jul 2011 at 11:26

GoogleCodeExporter commented 8 years ago
Sorry, that didn't work for me, the keyboard.send_keys("<code></code>") throws 
the same error as the phrase. 

I did come up with a solution though, I'm assuming (without having looked at 
the source) that any "<word>" combination is treated as a special key, so using 
"<<space><backspace>word>" seems to escapes that. 

e.g.:

< <backspace>code></code><left><left><left><left><left><left><left>

It's not very elegant though! 

Original comment by deferred...@gmail.com on 13 Jul 2011 at 9:46