AutoHotkey Community

It is currently May 27th, 2012, 6:57 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: February 13th, 2006, 12:17 am 
Offline

Joined: February 12th, 2006, 11:55 pm
Posts: 16
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?


Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 14th, 2006, 4:52 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 14th, 2006, 6:27 am 
Offline

Joined: February 12th, 2006, 11:55 pm
Posts: 16
Ah that's what I was looking for, thanks.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], migz99, sjc1000, Yahoo [Bot] and 70 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