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 

WheelUp::Click down (then WheelUp, then Click up)

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



Joined: 27 Aug 2007
Posts: 179

PostPosted: Sun Apr 20, 2008 5:11 pm    Post subject: WheelUp::Click down (then WheelUp, then Click up) Reply with quote

Hi All,
I would like my code to do the following when I turn mouse wheel several clicks:
-Translate the first click to LbuttonDown
-Translate the following Clicks to MouseMoveDown
-Translate the last click to LbuttonUp

How can I get the last WheelDown event to trigger LbuttonUp?
Tried KeyWait, Loops etc but nothing worked.

Been stuck on this for 2 days now. Would love some help.

I've been using ESC as a temporary means to to reset everything for now.
Code:
clix = 0
WheelDown::
If clix = 0
{
Click down
clix = 1
}
Else
MouseMove, 0, 1, 0, R
return

Esc::
clix = 0
click up
return
Back to top
View user's profile Send private message
jaco0646



Joined: 07 Oct 2006
Posts: 666
Location: MN, USA

PostPosted: Sun Apr 20, 2008 5:45 pm    Post subject: Reply with quote

Here's what I came up with.
Code:
clix = 0
WheelDown::
If clix = 0
{
 Click DOWN   ;Press mouse button after first scroll
 clix = 1
}
Else Loop
{
 MouseMove, 0, 1, 0, R
 If A_TimeIdlePhysical > 1000   ;Wait 1 second for user to stop scrolling
 {
  Click UP   ;Release mouse button after last scroll
  clix = 0
  return
 }
}

_________________
http://autohotkey.net/~jaco0646/
Back to top
View user's profile Send private message Visit poster's website
Leon



Joined: 27 Aug 2007
Posts: 179

PostPosted: Sun Apr 20, 2008 7:40 pm    Post subject: Reply with quote

Doesn't really work.
I'm not using an actual mouse but a usb device to send WheelUp and WheelDown - as a result, the wheel events don't interupt A_TimeIdlePhysical.

I'm looking for a way that
1) doesn't take the mouse too long to stop moving after scrolling stops.
2) doesn't cause ClickUp or ClickDown between the first and last wheel event
Back to top
View user's profile Send private message
jaco0646



Joined: 07 Oct 2006
Posts: 666
Location: MN, USA

PostPosted: Sun Apr 20, 2008 7:50 pm    Post subject: Reply with quote

Leon wrote:
I'm not using an actual mouse but a usb device to send WheelUp and WheelDown
That's an important piece of information to note (would have been helpful in the original post).

Did you try using A_TimeIdle instead of A_TimeIdlePhysical?
_________________
http://autohotkey.net/~jaco0646/
Back to top
View user's profile Send private message Visit poster's website
Leon



Joined: 27 Aug 2007
Posts: 179

PostPosted: Sun Apr 20, 2008 8:47 pm    Post subject: Reply with quote

Sorry my bad.
I tried using TimeIdle but no luck.
Back to top
View user's profile Send private message
jaco0646



Joined: 07 Oct 2006
Posts: 666
Location: MN, USA

PostPosted: Sun Apr 20, 2008 9:18 pm    Post subject: Reply with quote

By "no luck" you mean that your USB device does not reset A_TimeIdle either? The manual states that any input should reset it. If that's the case I'm out of ideas because I think KeyWait only works with buttons, not wheel events.

My advice is to get a wheel mouse. Wink
_________________
http://autohotkey.net/~jaco0646/
Back to top
View user's profile Send private message Visit poster's website
Leon



Joined: 27 Aug 2007
Posts: 179

PostPosted: Sun Apr 20, 2008 9:44 pm    Post subject: Reply with quote

Just got a lend of a mousewheel to check the difference.
With your code, once scrolling starts the scrolling will not stop.
I have to kill AHK in Task Manager to get it to stop.
Behaves same with mousewheel or usb thing.
Back to top
View user's profile Send private message
Leon



Joined: 27 Aug 2007
Posts: 179

PostPosted: Sun Apr 20, 2008 10:06 pm    Post subject: Reply with quote

Trying a diffrent approach taken from detect mouse movement

As long as the mouse doesn't move physically, it makes no difference if Lbutton is down or up, right?

My wheel clicks are being sent no faster than 1 click per 15msec (even when using actual mousewheel)
So this code should detect physical mouse moves.
i used the code in the 2nd box to count the interval between Wheel clicks.

Code:
clix = 0
^r::reload
Esc::
clix = 0
click up
return

WheelDown::
If clix = 0
{
Click down
clix = 1
}
Else
{
mousegetpos, sx, sy
MouseMove, 0, 1, 0, R
SetTimer, Check, -150
}

return

Check:
mousegetpos, cx, cy
  if (cx > (sx+10) or cx < (sx-10) or cy > (sy+10) or cy < (sy-10))
  {
    msgbox, Physical Movement
    mousegetpos, sx, sy ; get new mouse position
  } 
     
return


Code:

;this code counts time between wheel clicks in msec
;Hit Escape after each spin of the mousewheel when measuring
Clix  = 0
WheelDown::
If Clix = 1
MsgBox, %A_TimeSincePriorHotkey%
else
Clix = 1
return

Esc::
clix = 0
return
Back to top
View user's profile Send private message
jaco0646



Joined: 07 Oct 2006
Posts: 666
Location: MN, USA

PostPosted: Sun Apr 20, 2008 10:29 pm    Post subject: Reply with quote

Leon wrote:
once scrolling starts the scrolling will not stop.
That's strange. I've tested my code several times on 2 different PCs (XP SP2) with 2 different wheel mice, and never had that happen. Both stopped scrolling after the 1 second delay every time. Note that A_TimeIdle is reset by any input, so you have to do nothing for a full second to stop the scrolling (i.e. you can't move the mouse or hit any keys or buttons). You can obviously adjust the wait period to be any amount of time.
_________________
http://autohotkey.net/~jaco0646/
Back to top
View user's profile Send private message Visit poster's website
[VxE]



Joined: 07 Oct 2006
Posts: 1494

PostPosted: Sun Apr 20, 2008 10:49 pm    Post subject: Reply with quote

You could try this:
Code:
WheelDown::
Click Left Down
Hotkey, WheelDown, Cruizer, on
return

Cruizer:
Click 0 1 Left 0 Rel
SetTimer, ResetWheel, -1000
return

ResetWheel:
Hotkey, WheelDown, WheelDown, on
Click Left Up
return

No guarantees though. (it takes a full second of non-wheeling to make it release the slick)
_________________
My Home Thread
More Common Answers: [1]. It's in the FAQ [2]. Ternary ( a ? b : c ) guide [3]. Post code inside [code][/code] tags !
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