| View previous topic :: View next topic |
| Author |
Message |
tinaa
Joined: 25 Nov 2004 Posts: 41
|
Posted: Wed Mar 12, 2008 9:21 pm Post subject: Alt key sticking |
|
|
I recently upgraded my system and installed Vista. I'm not sure if the problem is Vista related as I believe it happened in XP as well, but I could be mistaken...
I have a few hotkeys that involve the "Alt" key. For instance, if I press the back & forward keys on my mouse it triggers an Alt-Tab. If I press the forward mouse button & wheelup or wheeldown it sends an Alt-Wheelup or Alt-Wheeldown (this zooms in or out in CorelDraw).
The problem is sometimes it seems the Alt key gets stuck. I've seen it happen with both these hotkeys. Generally pressing one or both of the alt keys on my keyboard will clear it (but sometimes it takes some effort and may require pressing other keys as well). Originally, I thought this might be a defective keyboard or bad keyboard driver, but now I've noticed it seems to be related to the Alt hotkeys.
Is there a way to avoid this problem?
Thanks! |
|
| Back to top |
|
 |
ManaUser
Joined: 24 May 2007 Posts: 901
|
Posted: Wed Mar 12, 2008 10:19 pm Post subject: |
|
|
| It's a known issue. It's a little complicated, but read this. |
|
| Back to top |
|
 |
tinaa
Joined: 25 Nov 2004 Posts: 41
|
Posted: Thu Mar 13, 2008 6:31 am Post subject: |
|
|
It seems like that topic has to do with hotkeys that use the modifier key (like Alt) for the trigger.
In my case, the Alt key isn't used as part of the trigger. The triggers are mouse keys or combinations of mouse keys with the mouse scrollwheel. The Alt key is sent as part of the Hotkey's script.
Playing a bit, I've found that SendInput (which is what I used originally) tends to result in the Alt key sticking intermittentaly. For instance:
SendInput, !{tab}
will sometimes send an Alt+Tab and release the Alt, but sometimes the Alt will get stuck and the physical key needs to be pressed and released.
I've found:
SendEvent, !{tab}
seems to work more reliably, although I don't really understand why.
Thanks! |
|
| Back to top |
|
 |
instantrunoff
Joined: 13 Jan 2008 Posts: 81
|
Posted: Wed May 14, 2008 10:20 pm Post subject: |
|
|
| I've noticed the same thing. Have you found a SetKeyDelay value that works reliably on Vista and avoids the stuck Alt problem? |
|
| Back to top |
|
 |
tinaa
Joined: 25 Nov 2004 Posts: 41
|
Posted: Wed May 14, 2008 11:36 pm Post subject: |
|
|
| instantrunoff wrote: | | I've noticed the same thing. Have you found a SetKeyDelay value that works reliably on Vista and avoids the stuck Alt problem? |
I don't recall ever playing with the SetKeyDelay value. I think it's just using the default. I found using SendEvent seemed to work fine for what I was doing and stopped there...
I have had a similar (not sure if it's related) problem trying to send the equivalent of scrolling the mouse while holding down the Alt key. In photoshop that will zoom about the cursor position and I wanted to map it to holding the forward mouse button while scrolling the mouse. The resulted in the send event being intermittent. Sometimes it would act like Alt+scroll, other times like just scroll or Alt, followed by scroll. I tried various methods of sending the alt+scroll event but couldn't get it to work so just ended up resigning myself to pressing alt on the keyboard.
I don't recall seeing these issues with Ctrl or Shift, so I think there's something odd happening with Autohotkey in Vista with respect to sending Alt or Alt combinations. |
|
| Back to top |
|
 |
Razlin
Joined: 05 Nov 2007 Posts: 370 Location: canada
|
Posted: Thu May 15, 2008 1:30 pm Post subject: |
|
|
I have found that on some of my scripts as well and my workaround is
at bottom of your hotkeys. just before return, add
It fixed my problems. _________________ -=Raz=- |
|
| Back to top |
|
 |
tinaa
Joined: 25 Nov 2004 Posts: 41
|
Posted: Thu May 15, 2008 4:02 pm Post subject: |
|
|
| Razlin wrote: | I have found that on some of my scripts as well and my workaround is
at bottom of your hotkeys. just before return, add
It fixed my problems. |
Interesting... I've tried:
| Code: | send {alt down}
send {whatever key you want}
send {alt up}
|
and that didn't work any better than:
| Code: | | send !{whatever key you want} |
maybe you need a second
|
|
| Back to top |
|
 |
instantrunoff
Joined: 13 Jan 2008 Posts: 81
|
Posted: Fri May 16, 2008 7:03 pm Post subject: |
|
|
| I've had better luck with SendPlay than with SendInput, but I have UAC off so that might make a difference (global keyboard hook). I also wasn't being careful enough to use {Raw} when necessary. |
|
| Back to top |
|
 |
instantrunoff
Joined: 13 Jan 2008 Posts: 81
|
|
| Back to top |
|
 |
tinaa
Joined: 25 Nov 2004 Posts: 41
|
Posted: Sun May 18, 2008 3:14 am Post subject: |
|
|
Not sure that's the explanation... Unless I totally misunderstood that thread it relates more to what happens when you launch a hotkey with alt already held down. In my case that would not be an issue. Alt is sent within the script but not used as part of the initiating hotkey.
But I'll concede I may not have understood what they were talking about...
In any case, have you tried using {blind} and did it help in any way? The documentation for {blind} suggests you can't use it with alt and sendplay so you'd have to use it with sendinput or sendevent. Now since sendevent provides a partial fix already... |
|
| Back to top |
|
 |
instantrunoff
Joined: 13 Jan 2008 Posts: 81
|
Posted: Sun May 18, 2008 4:07 am Post subject: |
|
|
What I got from it was that with Alt-triggered hotkeys, AHK tries to suppress Alt by sending a bunch of Control and Alt sequences among other stuff. For other hotkey modifiers, this kind of suppression tactic isn't necessary. I remapped my right Alt key to the Email key using KeyTweak and I use Launch_Email & combos. I had Alt sticking problems with Alt-triggered hotkeys; not as much with Sending keystrokes containing Alt.
However, if you have Alt sticking with Send: If you're sending a variable with a string that has exclamation points, you might have to prefix it with {Raw}, eg:
Additionally, this bit from the documentation for ControlSend may be relevant: | Quote: | in some cases these modifier events may interfere with the active window, especially if the user is actively typing during a ControlSend or if the Alt key is being sent (since Alt activates the active window's menu bar). This can be avoided by explicitly sending modifier up and down events as in this example:
ControlSend, Edit1, {Alt down}f{Alt up}, Untitled - Notepad |
Finally, I have found better reliability using SetKeyDelay 1, 1. I use SendMode Play, but the key delay works for ControlSend. |
|
| Back to top |
|
 |
tinaa
Joined: 25 Nov 2004 Posts: 41
|
Posted: Sun May 18, 2008 10:59 am Post subject: |
|
|
I'd have to look at some of my scripts. I can't recall at this point exactly what the issue was just that switching to sendevent seemed to fix the problem. The one exception I've had is trying to map mousebutton X2 & scroll to alt+scroll where it works unreliably. I believe it may be triggering the window menu in this case. Maybe playing with the setkeydelay may help. I'll have to play with it when I get a chance.
Thanks for the info. |
|
| Back to top |
|
 |
|