AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

keyboard malfunctioning when using HotStrings
Goto page 1, 2, 3, 4  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
/Torben



Joined: 19 Jul 2004
Posts: 14
Location: Denmark

PostPosted: Tue Jul 20, 2004 8:40 pm    Post subject: keyboard malfunctioning when using HotStrings Reply with quote

When I use a script with a hotstring the keyboard behaves faulty:

The accents - acute (´), circumflex (^), grave (`), and (¨) – are all shown twice before the letter instead of over the letter:
So I get:
´´e instead of é
``e instead of è
^^e instead of ê
¨¨a instead of ä
The ~ is not shown at all.

As soon as I exit the script, the keyboard returns to normal functioning.

The problem does not occur when I use scripts without hotstrings.

I use a Danish keyboard

/Torben
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Wed Jul 21, 2004 12:50 pm    Post subject: Reply with quote

Thanks for reporting this. I think I know the problem and will try to get it fixed soon.
Back to top
View user's profile Send private message Send e-mail
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Fri Jul 23, 2004 5:38 pm    Post subject: Reply with quote

I have updated the installer with a change that I hope will fix this. When you get a chance, please let me know if it's any better or worse. Thanks again.

http://www.autohotkey.com/download/
Back to top
View user's profile Send private message Send e-mail
/Torben



Joined: 19 Jul 2004
Posts: 14
Location: Denmark

PostPosted: Fri Jul 23, 2004 7:31 pm    Post subject: Reply with quote

Hello, Chris
I appreciate your efforts, so I hate so say that it’s all the same.
I downloaded the new version, but nothing has changed.
/Torben
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Fri Jul 23, 2004 11:39 pm    Post subject: Reply with quote

Thanks for testing it. I've scoured the 'net and found some other possibilities that I will research.

Background: To support hotstrings, the keyboard hook calls a standard Windows function ToAscii(), which translates a virtual key code into its ASCII equivalent. However, it seems that this function has some nasty side-effects that are completely undocumented by MS. These side-effects interfere with keyboard layouts that use dead keys (diacritics).
Back to top
View user's profile Send private message Send e-mail
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Sat Jul 24, 2004 12:59 am    Post subject: Reply with quote

Quick question: When you have a hotstring script running and you press a dead key, does the dead key appear immediately, or must you wait until you press the base/finishing key? If it appears immediately, does it appear twice immediately, or does its second appearance occur only when the base key is pressed?

Also, could you test this short script without any other scripts running:
sleep, 3000 ; give time to switch to an editor
Send ``e ; Use double-accent to mean a single literal accent.

Does it produce è?
Thanks.
Back to top
View user's profile Send private message Send e-mail
/Torben



Joined: 19 Jul 2004
Posts: 14
Location: Denmark

PostPosted: Sat Jul 24, 2004 7:30 am    Post subject: Reply with quote

1. it appears twice immediately

2. Yes, it does produce an è

/Torben
Back to top
View user's profile Send private message
jordi
Guest





PostPosted: Sat Jul 24, 2004 8:28 pm    Post subject: Reply with quote

Hi,
I have the same problem.
I'm using a Spanish keyboard.
I'm new to AutoHotkey, but it's weird no one was reporting this earlier...

Btw, no need to use hotstrings to for this bug to appear...
I have the same problem in the following sample script sent to me by Chris, which replaces btw -> by the way / mst -> Microsoft

Code:

#SingleInstance
#Persistent
SetTimer, AutoReplace, 10  ; Creates a new thread that's always running. return

AutoReplace:
SetTimer, AutoReplace, off
SetKeyDelay 0  ; Most editors can handle the faster speed.
Loop ; Infinite loop
{
   Input, UserInput, *V, `,.?!;{Enter}{Space}{Tab}
   EndChar = %ErrorLevel%
   StringGetPos, ColonPos, EndChar, :
   if ErrorLevel <> 0
      continue
   ColonPos += 2
   StringMid, EndChar, EndChar, %ColonPos%, 99
   if EndChar = 1
      EndChar = !
   else if EndChar = /
      EndChar = ?
   IfInString UserInput, btw
      Send, {backspace 4}by the way{%EndChar%}
   IfInString UserInput, mst
      Send, {backspace 4}Microsoft{%EndChar%}
}


regards
jordi
Back to top
/Torben



Joined: 19 Jul 2004
Posts: 14
Location: Denmark

PostPosted: Sat Jul 24, 2004 9:26 pm    Post subject: Reply with quote

You are right jordi. With that particular script I get the same error. But as mentioned earlier: I have tried several other scripts without problems.
/Torben
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Sat Jul 24, 2004 10:49 pm    Post subject: Reply with quote

Quote:
1. it appears twice immediately
2. Yes, it does produce an è

Thanks, that should help me.

Quote:
Btw, no need to use hotstrings to for this bug to appear...

The Input command also uses the troublesome ToAscii() which I mentioned earlier. So any time there is an input in progress, the same problem with dead keys will occur. I'm looking into ways to fix this.
Back to top
View user's profile Send private message Send e-mail
/Torben



Joined: 19 Jul 2004
Posts: 14
Location: Denmark

PostPosted: Sun Jul 25, 2004 12:16 pm    Post subject: Reply with quote

Well, this is a little odd
When using jordi’s script I get the same error as he.
But I have used the input-command in some other scripts without problems.

Again, today I tried this little script and had no problems.
Code:
#z::
Input, UserInput, T5 L1,
   MsgBox, You entered "%UserInput%",

I could even input the é, è, ê, and ä (each with two keystrokes), and they were shown correctly in the message box.

But when I add this line
Code:
::.t::This is a test

I get the problem back but NOT in the output from the message box!?

/torben
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Sun Jul 25, 2004 12:41 pm    Post subject: Reply with quote

I believe the reason this happens is that hotstrings and the Input command both "steal" the dead keys from the foreground app. Thus, while hotstrings and Input will capture and properly handle dead keys, they destroy the buffered dead keys for use with the foreground app that the user is typing in! Thanks for doing that interesting test.
Back to top
View user's profile Send private message Send e-mail
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Tue Jul 27, 2004 7:55 pm    Post subject: Reply with quote

I've updated the installer at http://www.autohotkey.com/download/ with another attempt to fix the above issue.

Partly to help me understand it myself, here is a description of what the workaround does:

When a script containing hotstrings or that has a visible Input in progress is running and the hook receives a dead key (diacritic), it "damages" that dead key event as an unintended side-effect of the Windows ToAscii() function. Since there aren't many (any?) alternatives to ToAscii(), and since I know of no other way to determine whether a key is a dead key, the following workaround is done:

The hook suppresses (hides) the damaged dead key to prevent it from appearing as two literal dead keys in the active window. Then it simulates a new dead key event to take its place. Since that event is artificial, the hook will know not to call ToAscii() on it, and thus the dead key should wind up being "re-buffered" for use by the foreground app.

If this fix fails to work, I still have some other ideas to try. Thanks for your patience.
Back to top
View user's profile Send private message Send e-mail
jordi
Guest





PostPosted: Tue Jul 27, 2004 9:39 pm    Post subject: :( Reply with quote

Hi Chris
I'm sorry to say that I tried the updated installer from the location you specified and the problem still remains...
It behaves exactly the same way: duplicate diacritics. (I'm always trying it out with the script I posted some posts up)

If you want to try it out yourself, I would suggest you switch to a Spanish keyboard configuration in Windows Control Panel's Keyboard applet. In that layout, the key inmediately right to the letter "P" is the diacritic `, so if you press that key followed by a vowel, you should get à è ì ò ù. The key inmediately below is the ´, (áéíóú).
I'm telling you so that you can test whether your fixes work instead of having to wait for me or /Torben to check it out...
Don't get me wrong: I don't imply that I do not want to keep trying your fixes, on the contrary, I'm very interested in getting this issue fixed as well Smile But I thought that you being able to check it out would be more convenient for you...
Good luck! I'll keep checking the thread.
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Tue Jul 27, 2004 9:43 pm    Post subject: Reply with quote

Thanks for the tip. I will try out some more changes by using Danish and/or Spanish layouts.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports All times are GMT
Goto page 1, 2, 3, 4  Next
Page 1 of 4

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group