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 

disabling shift when shift is already held down

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



Joined: 12 Feb 2006
Posts: 16

PostPosted: Sun Feb 12, 2006 11:17 pm    Post subject: disabling shift when shift is already held down Reply with quote

Originally I wanted to make a hotkey like this

Code:
+MButton::
Keywait, Mbutton
MouseClick, Left
return


but I didn't want the left click to be a shift-left click if I was still holding down shift. When I tested some solutions I came across something puzzling. The following two scripts should work the same but they don't.

Code:
+MButton::
Keywait, MButton
BlockInput, On
Send, {Shift up}
GetKeyState, state, Shift
BlockInput, Off
Msgbox, %state%
return


Code:
+MButton::
Keywait, MButton
BlockInput, On
Send, {Shift up}
Send, {Shift up}
Send, {Shift up}
Send, {Shift up}
Send, {Shift up}
Send, {Shift up}
GetKeyState, state, Shift
BlockInput, Off
Msgbox, %state%
return



The first script is unreliable, *if* there are other hotkeys that use Shift (e.g. add a +1::a to the script to make it fail occasionally). Sometimes the script will say GetKeyState says Shift wasn't held down and sometimes it says it was. In fact, it would appear that how long you hold down Middle Mouse determines whether or not it returns U or D. The second script so far seems to consistenly work.

Any idea what is going on here, and is there a more elegant method to fix the original hotkey without using a bunch of Send, {Shift up}'s?
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10716

PostPosted: Tue Feb 14, 2006 3:52 am    Post subject: Re: disabling shift when shift is already held down Reply with quote

I'm not sure exactly what is causing this because BlockInput is known to have side-effects (such as sticking keys) if put into effect while a key is being held down. That happens because the release of a key is not noticed by the active window when BlockInput is on.

Rather than trying to analyze it further, let me try to answer the question that is probably most important to you:
Quote:
I didn't want the left click to be a shift-left click if I was still holding down shift
I think this should do it:
Code:
+MButton::
Keywait, Mbutton
Send {LButton}  ; In the absence of {Blind}, Send releases the Shift key for you.
return
Back to top
View user's profile Send private message Send e-mail
dosboot



Joined: 12 Feb 2006
Posts: 16

PostPosted: Tue Feb 14, 2006 5:27 am    Post subject: Reply with quote

Ah that's what I was looking for, thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
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