QiangF / autokey

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

"<" is dropped in output when <ctrl><right> or <ctrl><left> is used with html tags. #95

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Hotkey this phrase: 

    <tt><ctrl>+<right></tt> 

in a text editor with the cursor located at the begining of a word.

2. I ran test on several variations of this and give more details and the 
Autokey log output at the end.

3. Summary: When using <ctrl>+<right> or <ctrl>+<left> in the above situations 
Autokey drops the leading < on one of the tags.  In other test using  <end> and 
<home> instead -- everything was perfect.

What is the expected output? What do you see instead?

   Expected: <tt>A_word</tt> or <tt>A_word </tt>

   What I got: <tt>A_word/tt>

   The < in </tt> is missing

What version of the product are you using? On what operating system?

    AutoKey (GTK UI) 0.71.1 on Ubuntu 10.10

Please provide any additional information below.

I thought this might be a bug, if so... I thought you would be interested in 
it.  I found a workaround so it is not an immediate problem for me.

I tested this in both gedit and kate and the results were the same.

The purpose of the phrase/script was for you to put the cursor at the begining 
of a word and on activating the Hotkey, insert <tt> then go to begining of next 
word (Ctrl+right in most editors) and insert </tt>

Problem is that when the following was executed, the < in </tt> was not 
inserted in the output.

TEST #1

Hotkey is: Ctrl+Shift+t
Phrase is: <tt><ctrl>+<right></tt>
Output is: <tt>A_word/tt>
Cursor is at the begining of "A_word"

Debug log:
DEBUG - iomediator - <ctrl> pressed
DEBUG - iomediator - <shift> pressed
DEBUG - service - Raw key: u't', modifiers: ['<ctrl>', '<shift>'], Key: u'T'
INFO - service - Matched hotkey phrase/script with prompt=False
DEBUG - iomediator - Send via event interface
DEBUG - interface - Sending string: u'<tt>'
DEBUG - interface - Send modified key: modifiers: [u'<ctrl>'] key: <right>
DEBUG - interface - Send modified key: modifiers: [u'<ctrl>'] key: <
DEBUG - interface - Sending string: u'/tt>'
DEBUG - interface - Send special key: [u'<end>']
DEBUG - iomediator - <shift> released
DEBUG - iomediator - <ctrl> released

TEST #2

The following was created to see if Ctrl+left had the same problem.  The reason 
for the multiple <ctrl>+<left> is that most editors consider "<" "/" and ">" 
and it took four <ctrl>+<left>s to get back to the front of the word starting 
at the end of </tt>.

Same type of problem, when the following was executed, the < in <tt> was not 
inserted in the output.

Hotkey is: Ctrl+Shift+t
Phrase is: </tt><ctrl>+<left><ctrl>+<left><ctrl>+<left><ctrl>+<left><tt><end>
Output is: tt>A_word<\tt>
Cursor is at the end of "A_word"

Debug log:
DEBUG - iomediator - <ctrl> pressed
DEBUG - iomediator - <shift> pressed
DEBUG - service - Raw key: u't', modifiers: ['<ctrl>', '<shift>'], Key: u'T'
INFO - service - Matched hotkey phrase/script with prompt=False
DEBUG - iomediator - Send via event interface
DEBUG - interface - Sending string: u'<\\tt>'
DEBUG - interface - Send modified key: modifiers: [u'<ctrl>'] key: <left>
DEBUG - interface - Send modified key: modifiers: [u'<ctrl>', u'<ctrl>'] key: 
<left>
DEBUG - interface - Send modified key: modifiers: [u'<ctrl>', u'<ctrl>', 
u'<ctrl>'] key: <left>
DEBUG - interface - Send modified key: modifiers: [u'<ctrl>', u'<ctrl>', 
u'<ctrl>', u'<ctrl>'] key: <left>
DEBUG - interface - Send modified key: modifiers: [u'<ctrl>', u'<ctrl>', 
u'<ctrl>', u'<ctrl>'] key: <
DEBUG - interface - Sending string: u'tt>'
DEBUG - interface - Send special key: [u'<end>']
DEBUG - iomediator - <ctrl> released
DEBUG - iomediator - <shift> released

I tried the same scripts above using <end> and <home> instead of <ctrl>+<left> 
and <ctrl><right> and the script worked perfectly.  The problem only seems to 
appear when you use <ctrl>+<left> or <ctrl><right>

TEST #3

The workaround I found was to use <</tt> instead of </tt>.  That produced the 
correct output.  Example of the workaround and its log output is below:

Hotkey is: Ctrl+Shift+t
Phrase is: <tt><ctrl>+<right><</tt><end>
Output is: <tt>A_word</tt>
Cursor is at the begining of "A_word"

Debug log:
DEBUG - iomediator - <ctrl> pressed
DEBUG - iomediator - <shift> pressed
DEBUG - service - Raw key: u't', modifiers: ['<ctrl>', '<shift>'], Key: u'T'
INFO - service - Matched hotkey phrase/script with prompt=False
DEBUG - iomediator - Send via event interface
DEBUG - interface - Sending string: u'<tt>'
DEBUG - interface - Send modified key: modifiers: [u'<ctrl>'] key: <right>
DEBUG - interface - Send modified key: modifiers: [u'<ctrl>'] key: <
DEBUG - interface - Sending string: u'</tt>'
DEBUG - interface - Send special key: [u'<end>']
DEBUG - iomediator - <ctrl> released
DEBUG - iomediator - <shift> released

I hope this is helpful and saves you some time if you have to fix it.

Keith
keithwdaniels@gmail.com

Original issue reported on code.google.com by keithwda...@gmail.com on 7 Nov 2010 at 4:40

GoogleCodeExporter commented 9 years ago
Two other problems that might be related to my post above.

1 --  <right> does not work correctly when used in activating main menu 
choices.  Example:

In Kate you want to activate the File menu, go to an entry that has sub-menus, 
go into the sub-menu, then down to the menu item you want to activate.

2 -- I got an error when "Initializing Autokey" and I included the log of that 
at the bottom of this post.

I tested these problems in both Kate and Gedit but could not do an apples to 
apples comparison because the menu choices are different for the two programs.  
But when I tested Gedit on a menu with sub-menus, neither <down> nor <right> 
worked the same as using the keyboard to activate the sub-menu did.  In 
Autokey, using multiple <down>s with Gedit in the View drop down menu, it would 
only go so far down (it never would reach the last choice) then revert to the 
top choice.  When you added a <right> to the phrase (after a <down>) it moved 
to the next choice in the main menu (ie. Search). This indicates Gedit also has 
problems similar to those I report for Kate below.

Results of testing with Kate:

Re: Issue one above:

In Autokey:

Using <alt>+f activates the File menu correctly,
Using T then shows the Templates sub-menu.....

At this point when activating the menus by hand, using either "H" or "right 
down enter" will activate the HTML sub-menu, but....

When using Autokey:

Using <right>, any number of times, does nothing.
Using H causes the drop down menu to disappear.

This is the log output when using <right> to activate the sub-menu:

Hotkey is: Ctrl+Shift+`
Phrase is: <alt>+FT<right><right><right>
Output   : The drop down menu shows the Template sub-menu but does not activate 
it (does not highlight it).

Debug log:
DEBUG - iomediator - <ctrl> pressed
DEBUG - iomediator - <shift> pressed
DEBUG - service - Raw key: u'`', modifiers: ['<ctrl>', '<shift>'], Key: u'~'
INFO - service - Matched hotkey phrase/script with prompt=False
DEBUG - iomediator - Send via event interface
DEBUG - interface - Send modified key: modifiers: [u'<alt>'] key: F
DEBUG - interface - Sending string: u'T'
DEBUG - interface - Send special key: [u'<right>']
DEBUG - interface - Send special key: [u'<right>']
DEBUG - interface - Send special key: [u'<right>']
DEBUG - iomediator - <shift> released
DEBUG - iomediator - <ctrl> released

This is the log output when using H

Hotkey is: Ctrl+Shift+`
Phrase is: <alt>+FTH
Output is: The entire File drop down menu pops up (flashes) then instantly 
disappears.

Debug log:
DEBUG - iomediator - <ctrl> pressed
DEBUG - iomediator - <shift> pressed
DEBUG - service - Raw key: u'`', modifiers: ['<ctrl>', '<shift>'], Key: u'~'
INFO - service - Matched hotkey phrase/script with prompt=False
DEBUG - iomediator - Send via event interface
DEBUG - interface - Send modified key: modifiers: [u'<alt>'] key: F
DEBUG - interface - Sending string: u'TH'
DEBUG - iomediator - <shift> released
DEBUG - iomediator - <ctrl> released

I just noticed that I got this Autokey error when starting Autokey.  I am sure 
I got it before when I was working on the problems described in the first post, 
but I did not notice it.

DEBUG - interface - Grabbing hotkey: [u'<ctrl>', u'<shift>'] u'`'
DEBUG - interface - Grabbing hotkey: [u'<ctrl>'] u'<f7>'
X protocol error:
<class 'Xlib.error.BadAccess'>: code = 10, resource_id = 346, sequence_number = 
14, major_opcode = 33, minor_opcode = 0
DEBUG - interface - Alt-Grid: XK_Alt_R, 65514
DEBUG - interface - [(92, 0), (92, 2)]
DEBUG - interface - X Server Keymap
DEBUG - interface - [\] : [(51, 0), (51, 2)]

Again I hope this helps and saves you time if you have to fix it.

Keith

Original comment by keithwda...@gmail.com on 7 Nov 2010 at 4:50

GoogleCodeExporter commented 9 years ago
Seems to be a small bug in the hotkey parsing code - thanks for reporting.

Original comment by cdekter on 8 Jan 2011 at 3:52

GoogleCodeExporter commented 9 years ago
Fixed for v0.71.2

Original comment by cdekter on 25 Jan 2011 at 7:14