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 

Alt key sticking

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
tinaa



Joined: 25 Nov 2004
Posts: 41

PostPosted: Wed Mar 12, 2008 9:21 pm    Post subject: Alt key sticking Reply with quote

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
View user's profile Send private message
ManaUser



Joined: 24 May 2007
Posts: 901

PostPosted: Wed Mar 12, 2008 10:19 pm    Post subject: Reply with quote

It's a known issue. It's a little complicated, but read this.
Back to top
View user's profile Send private message
tinaa



Joined: 25 Nov 2004
Posts: 41

PostPosted: Thu Mar 13, 2008 6:31 am    Post subject: Reply with quote

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
View user's profile Send private message
instantrunoff



Joined: 13 Jan 2008
Posts: 81

PostPosted: Wed May 14, 2008 10:20 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
tinaa



Joined: 25 Nov 2004
Posts: 41

PostPosted: Wed May 14, 2008 11:36 pm    Post subject: Reply with quote

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
View user's profile Send private message
Razlin



Joined: 05 Nov 2007
Posts: 370
Location: canada

PostPosted: Thu May 15, 2008 1:30 pm    Post subject: Reply with quote

I have found that on some of my scripts as well and my workaround is
at bottom of your hotkeys. just before return, add

Code:
send {alt up}


It fixed my problems.
_________________
-=Raz=-
Back to top
View user's profile Send private message
tinaa



Joined: 25 Nov 2004
Posts: 41

PostPosted: Thu May 15, 2008 4:02 pm    Post subject: Reply with quote

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

Code:
send {alt up}


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
Code:

send {alt up}
Back to top
View user's profile Send private message
instantrunoff



Joined: 13 Jan 2008
Posts: 81

PostPosted: Fri May 16, 2008 7:03 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
instantrunoff



Joined: 13 Jan 2008
Posts: 81

PostPosted: Sat May 17, 2008 10:33 pm    Post subject: Reply with quote

A possible explanation: http://www.autohotkey.com/forum/viewtopic.php?p=87771#87771
Back to top
View user's profile Send private message Visit poster's website
tinaa



Joined: 25 Nov 2004
Posts: 41

PostPosted: Sun May 18, 2008 3:14 am    Post subject: Reply with quote

instantrunoff wrote:
A possible explanation: http://www.autohotkey.com/forum/viewtopic.php?p=87771#87771


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
View user's profile Send private message
instantrunoff



Joined: 13 Jan 2008
Posts: 81

PostPosted: Sun May 18, 2008 4:07 am    Post subject: Reply with quote

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:
Code:
Send {Raw}%var%


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
View user's profile Send private message Visit poster's website
tinaa



Joined: 25 Nov 2004
Posts: 41

PostPosted: Sun May 18, 2008 10:59 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
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