AutoHotkey Community

It is currently May 26th, 2012, 3:30 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: April 20th, 2008, 6:11 pm 
Offline

Joined: August 27th, 2007, 8:00 pm
Posts: 179
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 20th, 2008, 6:45 pm 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
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
 }
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 20th, 2008, 8:40 pm 
Offline

Joined: August 27th, 2007, 8:00 pm
Posts: 179
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 20th, 2008, 8:50 pm 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 20th, 2008, 9:47 pm 
Offline

Joined: August 27th, 2007, 8:00 pm
Posts: 179
Sorry my bad.
I tried using TimeIdle but no luck.


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

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
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:


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

Joined: August 27th, 2007, 8:00 pm
Posts: 179
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 20th, 2008, 11:06 pm 
Offline

Joined: August 27th, 2007, 8:00 pm
Posts: 179
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 20th, 2008, 11:29 pm 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 20th, 2008, 11:49 pm 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3328
Location: Simi Valley, CA
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)

_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: 0x150||ISO, Exabot [Bot], LazyMan and 21 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