Page 1 of 1

little if problem

Posted: 20 Oct 2017, 03:06
by Kobold
wait=0

LButton::
if(wait=0)
{
wait=1
SendInput,x
sleep,12000
wait=0
}
else
{
SendInput,y
}
return

why gives the mousebutton only a x and not a y by state "if wait=1" or else...

plse help

Re: little if problem

Posted: 20 Oct 2017, 03:18
by BoBo
Bc it will never become 1?

Code: Select all

.
.
.
wait=1   ; OK lets wait ...
SendInput,x
sleep,12000
wait=0  ; OK, let's act like an American president and reverse the decision a few moments later!
}
.
.
.
BTW, use -tags to prevent your request is getting ignored by your supporters. :thumbup:

Re: little if problem

Posted: 20 Oct 2017, 09:44
by Kobold
thx for you answear
hmm...

wait=0

between that the mouse should have an alternative clickoption
after 12 sec it switched back :

wait=1 (first clicloption)

in the time room between wait0-1 is the mousebutton input blocked ? till this script part ended ?
for example i can make several clicks or pressed and every moment it solves the definition of lbutton::... again ?
So the second click have to reconigzes the state wait=0 because the click before changed it for allready 12sec ???

Re: little if problem

Posted: 20 Oct 2017, 10:56
by Xtra
Try this:

Code: Select all

#NoEnv
#SingleInstance Force

wait := 0

LButton::
    if (wait = 0)
    {
        wait := 1
        SendInput, x
        SetTimer, waitreset, -12000
    }
    else
    {
        SendInput, y
    }
return


waitreset:
    wait := 0
return

Re: little if problem

Posted: 20 Oct 2017, 11:12
by Kobold
it works fine

and its written really simple and system friendly

greatness many thx :))))

Re: little if problem

Posted: 20 Oct 2017, 11:48
by A_AhkUser
Alternatively:

Code: Select all

LButton::SendInput % (((var - A_Now < -12) and (var:=A_Now)) ? false : true) ? "x" : "y"
references:
Expressions
Short-circuit Boolean Evaluation
Ternary operator
A_Now

Re: little if problem

Posted: 20 Oct 2017, 12:42
by Barney
Kobold wrote:
in the time room between wait0-1 is the mousebutton input blocked ? till this script part ended ?
for example i can make several clicks or pressed and every moment it solves the definition of lbutton::... again ?
So the second click have to reconigzes the state wait=0 because the click before changed it for allready 12sec ???
By default, a given hotkey or hotstring subroutine cannot be run a second time if it is already running. Use #MaxThreadsPerHotkey to change this behavior.