AutoHotkey Community

It is currently May 26th, 2012, 6:58 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: Alt key sticking
PostPosted: March 12th, 2008, 9:21 pm 
Offline

Joined: November 25th, 2004, 10:08 am
Posts: 57
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 12th, 2008, 10:19 pm 
Offline

Joined: May 24th, 2007, 3:45 am
Posts: 1121
It's a known issue. It's a little complicated, but read this.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 13th, 2008, 6:31 am 
Offline

Joined: November 25th, 2004, 10:08 am
Posts: 57
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 14th, 2008, 10:20 pm 
Offline

Joined: January 13th, 2008, 6:00 pm
Posts: 115
I've noticed the same thing. Have you found a SetKeyDelay value that works reliably on Vista and avoids the stuck Alt problem?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 14th, 2008, 11:36 pm 
Offline

Joined: November 25th, 2004, 10:08 am
Posts: 57
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 15th, 2008, 1:30 pm 
Offline

Joined: November 5th, 2007, 7:25 pm
Posts: 454
Location: canada
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=-


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 15th, 2008, 4:02 pm 
Offline

Joined: November 25th, 2004, 10:08 am
Posts: 57
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}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 16th, 2008, 7:03 pm 
Offline

Joined: January 13th, 2008, 6:00 pm
Posts: 115
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 17th, 2008, 10:33 pm 
Offline

Joined: January 13th, 2008, 6:00 pm
Posts: 115
A possible explanation: http://www.autohotkey.com/forum/viewtop ... 7771#87771


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 18th, 2008, 3:14 am 
Offline

Joined: November 25th, 2004, 10:08 am
Posts: 57
instantrunoff wrote:


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...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 18th, 2008, 4:07 am 
Offline

Joined: January 13th, 2008, 6:00 pm
Posts: 115
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 18th, 2008, 10:59 am 
Offline

Joined: November 25th, 2004, 10:08 am
Posts: 57
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.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Tipsy3000 and 65 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group