Jump to content
Sign in to follow this  
Swimming_Bird

Detecting a mouse "rock"

Recommended Posts

Swimming_Bird

"rocking" the mouse is when you hold down one key then click the other one.

I'm looking to make a script that would detect when someone rocks their mouse in either direction and will perform an action depending on the direction (right<-left , right->left)

I've found the (relatively) new function _IsPressed but the issue i was wondering if there was any sort of mouse detection that would act more like a hotkey. I'm not a fan of using such loops when i don't have to. i'm always paranoid they'll miss the action or delay the action too much.

When testing it using the given example it missed my just tapping the end key, i had to hold it down instead

#include <Misc.au3>

$dll = DllOpen("user32.dll")

While 1
    Sleep ( 250 )
    If _IsPressed("23", $dll) Then
        MsgBox(0,"_IsPressed", "End Key Pressed")
        ExitLoop
    EndIf
WEnd
DllClose($dll)

I'd love some suggestions.

This script was inspired by the Lifehacker rocker app found here source, it was written in something called Autohotkey.

Thanks

Share this post


Link to post
Share on other sites
Davo

Hi, you don't necessarily have to sleep for 250ms. It would be fine for most processors these days to sleep for 100 or even 50ms without putting too much stress on the cpu :) Try only sleeping for 50ms and see how it goes.

Dave


---------------------------------------------------------------------------------------------------------------------------------------------------------------------------"I don't need to know everything, I just need to know where to find it when I need it"....EinsteinAnd in our case... That's the AutoIT helpfile ;) Please read before posting!!!

Share this post


Link to post
Share on other sites
Achilles

"rocking" the mouse is when you hold down one key then click the other one.

I'm looking to make a script that would detect when someone rocks their mouse in either direction and will perform an action depending on the direction (right<-left , right->left)

I've found the (relatively) new function _IsPressed but the issue i was wondering if there was any sort of mouse detection that would act more like a hotkey. I'm not a fan of using such loops when i don't have to. i'm always paranoid they'll miss the action or delay the action too much.

When testing it using the given example it missed my just tapping the end key, i had to hold it down instead

#include <Misc.au3>

$dll = DllOpen("user32.dll")

While 1
    Sleep ( 250 )
    If _IsPressed("23", $dll) Then
        MsgBox(0,"_IsPressed", "End Key Pressed")
        ExitLoop
    EndIf
WEnd
DllClose($dll)
Is this what you meant?

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites
Swimming_Bird

#Include <Misc.au3>

While 1 
    While _IsPressed('01') 
        If _IsPressed('02') then 
            ConsoleWrite('Congratulation! You pressed both mouse keys at the same time!' & @CRLF) 
            Sleep(100) 
        EndIf
    Wend 
    Sleep(40) 
WEnd
Is this what you meant?
i'm not sure if that would be sufficient, but ill give it a shot, because it would have to work both ways.

I may try learning the original language, it seems better for capturing things.

Share this post


Link to post
Share on other sites
Achilles

i'm not sure if that would be sufficient, but ill give it a shot, because it would have to work both ways.

I may try learning the original language, it seems better for capturing things.

When I tested this (very briefly) it worked for both... that's because your computer has sufficient time to enter both loops no matter which button you click first... I suppose you could event make a line like this if you wanted to:

While _IsPressed('01') and _IsPressed('02')
Edited by Piano_Man

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×