AutoHotkey Community

It is currently May 26th, 2012, 8:24 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 15 posts ] 
Author Message
PostPosted: August 8th, 2009, 8:48 pm 
Offline

Joined: March 10th, 2009, 10:13 am
Posts: 27
Hi.

i've been trying to write a script that "activates" when holding the middle mouse button for 5+ seconds.

in theory, i think this should have worked :
Code:
; init section
#InstallMouseHook
return


MButton::
   ErrorLevel := 0 ;dont know what was there before me
   pressTime := 0
   keyDownTime := A_TickCount
   KeyWait, MButton, T5
   ; MsgBox, key released
   ; we only care about the duration if there's no errorlevel (else its over 5 seconds)
   if (ErrorLevel != 1) {
      keyUpTime := A_TickCount
      pressTime := keyUpTime - keyDownTime
      
      if (pressTime < 5000) {
         Suspend, On
         ; Send, {Click Middle} disabled for now
         Suspend, Off
         return
      }
   }
   
   MsgBox, triggered


in practice, the KeyWait call returns immediately, even when holding down the middle button. same with GetKeyState: the middle button registers as "up" after the KeyWait call.

this appears to be an artifact caused by me using logitech setPoint to alter the middle button behavior (by default the middle button on an MX revolution is useless) - actually im using setpoint uberoptions (a "hacked" version of setpoint with more options).

if i close setPoint the above script works, but im trying to understand whats preventing it from working even with setpoint active.

here's a snippet from the key history window with setpoint active:

Code:
04  000   h   d   0.88   MButton           
04  000   a   u   7.95   MButton           


the MButton keyup event appears as "Artificial"

this is a key history snippet with setpoint closed:

Code:
04  000   h   d   0.86   MButton           
04  000   s   u   5.39   MButton           


this time its swallowed because the script triggered (like it was supposed to).

how can i make it work with the "artificial" event ?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 9th, 2009, 1:38 am 
Online
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3330
Location: Simi Valley, CA
Perhaps using the "L" option for keywait... :?:

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 9th, 2009, 8:08 am 
Offline

Joined: March 10th, 2009, 10:13 am
Posts: 27
[VxE] wrote:
Perhaps using the "L" option for keywait... :?:

thanks, but this doesnt change the behavior - the KeyWait call returns immediately.

im starting to think this might be a AHK bug ?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 12th, 2009, 5:41 pm 
Offline

Joined: March 10th, 2009, 10:13 am
Posts: 27
bump
:cry:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 12th, 2009, 5:45 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
maybe also install the keyboard hook?

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 12th, 2009, 7:01 pm 
Offline

Joined: March 10th, 2009, 10:13 am
Posts: 27
engunneer wrote:
maybe also install the keyboard hook?

doubtful, but at this point ill try anything (within reason).
how do i do that ?

EDIT : ok, tried this: (still no go)
Code:
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
return

#InstallMouseHook
#InstallKeybdHook
#UseHook


MButton::
   ErrorLevel := 0 ;dont know what was there before me
   pressTime := 0
   keyDownTime := A_TickCount
   KeyWait, MButton, L
   MsgBox, key released
   ; we only care about the duration if there's no errorlevel (else its over 5 seconds)
   if (ErrorLevel != 1) {
      keyUpTime := A_TickCount
      pressTime := keyUpTime - keyDownTime
     
      if (pressTime < 5000) {
         Suspend, On
         ; Send, {Click Middle} disabled for now
         Suspend, Off
         return
      }
   }
   
   MsgBox, triggered


:cry:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 13th, 2009, 8:36 am 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
hatchetman82 wrote:
doubtful, but at this point ill try anything (within reason).


Wave a dead chicken over it?

Maybe you can find a way to make the middle button do what you want with setpoint disabled? (recreate the other things in setpoint that you want with the AHK script that will apparently be running anyway.)

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 13th, 2009, 5:44 pm 
Offline

Joined: March 10th, 2009, 10:13 am
Posts: 27
engunneer wrote:
Wave a dead chicken over it?


too bad i read this after lunch, now im out of dead chicken :-)
with setpoint disabled everything works like a charm (because the middle up event is no longer "artificial" - trouble is without setpoint my mouse is nearly useless (never buy an MX revolution - no middle click by default).

on the other hand, setpoint is a shoddy joke compared to what you can achieve in AHK (and no, i cant replace setpoint entirely with AHK because AHK doesnt have enough low-level control over the mouse)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 13th, 2009, 9:07 pm 
Online
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3330
Location: Simi Valley, CA
Maybe "Uberoptions" will help. Just google the term.

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 14th, 2009, 3:16 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
he's already running überoptions.

How can it not have a middle click by default? with the basic MS HID driver, what happens when you middle click?

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 17th, 2009, 12:59 pm 
Offline

Joined: March 10th, 2009, 10:13 am
Posts: 27
engunneer wrote:
How can it not have a middle click by default?


the same thought crossed my mind plenty of times. usually followed by elaborate hypotheses on the occupation of some of Logitech's engineers' mothers ....

but the sad cruel fact is that by default without uberoptions installed the default middle click behavior is simply to toggle the mouse scroll wheel between click-to-click mode (in which the scroolwheel "clicks" and does not spin freely) and free-spin mode (in which there's no spin resistance and you can set it spinning for a long time with a simple push - presumably to scroll long documents for retards who dont know where the page down key is).

when i bought this mouse, a little over a year ago, i had to get uberoptions to use the middle button os a middle button

EDIT : actually, i've never tried it without any sort of logitech drivers, but i suspect i'd get the wheel-mode toggle functionality by default


Last edited by hatchetman82 on August 17th, 2009, 1:14 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 17th, 2009, 1:05 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
craigslist it.

Surely you can find a mouse that comes with a native MButton in this day and age.

It actually changes the resistance of the middle mouse wheel?

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 17th, 2009, 1:12 pm 
Offline

Joined: August 14th, 2009, 4:33 am
Posts: 6
The G9 has that mouse release button underneath (a much better spot)!

If the keystroke releases immediately, and there's no workaround, have you considered 2 or 3 quick clicks of the middle button? Or perhaps a click of the middle button followed by another keypress? It's a pain that setpoint releases the button immediately though.

_________________
There are only 10 types of people in the world —
those who understand binary, and those who don't.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 17th, 2009, 1:15 pm 
Offline

Joined: March 10th, 2009, 10:13 am
Posts: 27
engunneer wrote:
It actually changes the resistance of the middle mouse wheel?


yes.
which is kind of neat, had it not been the default function ....


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 20th, 2009, 6:24 am 
Offline

Joined: March 10th, 2009, 10:13 am
Posts: 27
BigAHKFan wrote:
If the keystroke releases immediately, and there's no workaround, have you considered 2 or 3 quick clicks of the middle button? Or perhaps a click of the middle button followed by another keypress?


thats not exactly what happens. the button up event isnt fired immediately - its fired at the right time (--when i actually release the button). for some reason AHK's KeyWait function returns immediately (as if i've released the button).
my current workaround involved hooking both the middle down and middle up events separately - which works (but is a lot uglier).
thats why i think its an AHK bug


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, Pulover, SKAN, StepO, Yahoo [Bot] and 60 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