little if problem

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Kobold
Posts: 5
Joined: 19 Oct 2017, 06:17

little if problem

20 Oct 2017, 03:06

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
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: little if problem

20 Oct 2017, 03:18

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:
Kobold
Posts: 5
Joined: 19 Oct 2017, 06:17

Re: little if problem

20 Oct 2017, 09:44

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 ???
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: little if problem

20 Oct 2017, 10:56

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
Kobold
Posts: 5
Joined: 19 Oct 2017, 06:17

Re: little if problem

20 Oct 2017, 11:12

it works fine

and its written really simple and system friendly

greatness many thx :))))
A_AhkUser
Posts: 1147
Joined: 06 Mar 2017, 16:18
Location: France
Contact:

Re: little if problem

20 Oct 2017, 11:48

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
my scripts
User avatar
Barney
Posts: 55
Joined: 28 May 2014, 20:03
Location: Germany

Re: little if problem

20 Oct 2017, 12:42

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.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: doanmvu, Rohwedder, Thunderb and 124 guests