1
votes

I am trying to make (Holding down the left button for 1s) to make it do a right click. Here's what i got:

 LButton::
    MouseClick, right, , , 1, 0, D
    Sleep 0
    MouseClick, right, , , 1, 0, U
return

How to change the "LButton" input into "Hold LButton for 1 second"?

2
I guess you have to measure the time between mouse down and mouse up. - John Dvorak
hmmm... tbh i don't know how to do it :( ,and actually that script i got it from somewhere... - Christopher Goldwin
Once I find out how to perform basic inter-thread communication, this should be easy. Will investigate.. - John Dvorak

2 Answers

1
votes

How about this...

LButton::
StartTime := A_TickCount ; Set the timer
KeyWait, LButton ; Wait for release of mousebutton
ElapsedTime := A_TickCount - StartTime ; Calculate elapsed time
if (ElapsedTime > 1000)
    Click, Right ; when longer than 1000 ms
    Click, Left  ; when shorter than 1000 ms
return

The disadvantage is that you can't use the mouse for e.g. highlighting text anymore...

0
votes

Here you go:

#Persistent 
#SingleInstance Force
#NoEnv
SetBatchLines, -1

global timeDown = 0

SetTimer, checkLeftClick,25

checkLeftClick:
    if(  GetKeyState("LButton" , "P") )
    {
        timeDown += 25
    }
    else
    {
        timeDown = 0
    }

    if(timeDown > 1000)
    {
        MouseClick , left , , , , ,U
        Click,Right
        timeDown = 0
    }

return