if condition and a loop changing a variable problem

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

if condition and a loop changing a variable problem

19 Oct 2017, 07:25

Hello,
this is my first post, i am stucking in programming.
english is not my native language, dont be so strict with me :)
An if condition dont realize an variable value.. i dont know why

i tried to programmed a automatisation for a rpg online game,
by right clicking you get a free camera mode -> simulated by permanently pressing the rightmousebutton (1)
(Toggle=1/0)
if its not a free camera simulated the leftmousebutton should be leftmousebutton (0)

if its simulated i want the leftmousebutton the possibility to active all 12 sec via "2" the skill y
and in the 12 sec waiting time the leftmousebutton should activate via "1" skill x as a standard attack
(wait=1/0)

the rbutton toggles...
the "wait" depends on a loop to reactivate it

if conditions for the lbutton
its like toggle 1 and wait 1 standard attack
toggle 1 and wait 0 special attack after 12 sec time
toggle 0 normal mouse use

The variable values like above are ok i can ask them with a msgbox, but the if conditions for LButton::
dont react. Only the first if variant runs , the second if condtion dont proced the standart attack if it is "wait=1"
or in detail "else if(Toggle=1 && wait=1)" dont working, but the variable values exist correctly



#NoEnv
SendMode Input

global Toggle = 0 ;toggle value 1/0 for free/close Camera
global wait=0 ;wait value 1/0 for wait/no wait for skill 2


$RButton:: ;RButton permanent press for free Camera in RPG
If (Toggle := !Toggle) ;Toggle Option for Free/Nonfree Camera mode
Send {RButton Down}
Else
Send {RButton up}
Return

LButton:: ;LButton action main
If (Toggle=1 && wait=0) ;LButton action by free camera and no wait modifier
{
global wait=1 ;blocked this leftmousebutton action till the wait variable is resetted

SendInput,2 ;specific action of skill2 which has a 12 sec pause

time := A_Now ;time now
time += 12, Seconds ;time in 12 sec (skill can only activate all 12 sec)
loop ;loop waiting for 12sec
{
;sleep,1000
if (A_Now = time) ;reaching 12 sec
{
global wait=0 ;unblockvariable or resett/reactivate the possibility to solve the "12sec skill"
break
}
}
}
else if(Toggle=1 && wait=1) ;LButton action by free camera and between the 12s wait sequences
{
SendInput,1 ;skillplace 1 - solve a standart attack
}
else ;LButton action in Closedcamera mode
{
SendInput, {lbutton} ;standart mouseclick to handle the interface
}
return

Delete:: ;exitbutton
ExitApp
return
Kobold
Posts: 5
Joined: 19 Oct 2017, 06:17

Re: if condition and a loop changing a variable problem

19 Oct 2017, 07:32

code without comments

#NoEnv
SendMode Input

global Toggle = 0
global wait=0


$RButton::
If (Toggle := !Toggle)
Send {RButton Down}
Else
Send {RButton up}
Return

LButton::
If (Toggle=1 && wait=0)
{
global wait=1

SendInput,2

time := A_Now
time += 12, Seconds
loop
{
;sleep,1000
if (A_Now = time)
{
global wait=0
break
}
}
}
else if(Toggle=1 && wait=1)
{
SendInput,1
}
else
{
SendInput, {lbutton}
}
return

Delete::
ExitApp
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: arrondark, mikeyww and 267 guests