some problem with if

Ask gaming related questions (AHK v1.1 and older)
SkyLife
Posts: 19
Joined: 18 May 2017, 20:53

some problem with if

13 Jul 2017, 22:16

Code: Select all

SetDefaultMouseSpeed, 0
CoordMode, Pixel, window
*MButton::
SoundBeep, 2000, 500
PixelGetColor, OutputVar1, 836, 521, slow
PixelGetColor, OutputVar2, 836, 529, slow
PixelGetColor, OutputVar3, 844, 521, slow
PixelGetColor, OutputVar4, 844, 529, slow
Loop
{
if not GetKeyState("MButton","P")
    break
PixelGetColor, OutputVar1_, 836, 521, slow
PixelGetColor, OutputVar2_, 836, 529, slow
PixelGetColor, OutputVar3_, 844, 521, slow
PixelGetColor, OutputVar4_, 844, 529, slow
if not (OutputVar1_ = %OutputVar1%) and (OutputVar2_ = %OutputVar2%) and (OutputVar3_ = %OutputVar3%) and (OutputVar4_ = %OutputVar4%)
{
   SendInput {Lbutton Down}
   SendInput {Lbutton Up}
}
}
return
!z::ExitApp
All code can work except the following.I have used msgbox to check out the eight value(pixel).
But, when the last four pixel change , the code including If couldn`t work.

Code: Select all

if not (OutputVar1_ = %OutputVar1%) and (OutputVar2_ = %OutputVar2%) and (OutputVar3_ = %OutputVar3%) and (OutputVar4_ = %OutputVar4%)
{
   SendInput {Lbutton Down}
   SendInput {Lbutton Up}
}
Rohwedder
Posts: 7768
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: some problem with if

14 Jul 2017, 00:06

Hallo,
Within parenthes you must use the expression style (not %Var%).
Try

Code: Select all

if not (OutputVar1_ = OutputVar1) and (OutputVar2_ = OutputVar2) and (OutputVar3_ = OutputVar3) and (OutputVar4_ = OutputVar4)
{
   SendInput {Lbutton Down}
   SendInput {Lbutton Up}
}
SkyLife
Posts: 19
Joined: 18 May 2017, 20:53

Re: some problem with if

14 Jul 2017, 00:15

Before I use % %, (OutputVar1_ = OutputVar1) is not work.
Rohwedder
Posts: 7768
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: some problem with if

14 Jul 2017, 03:29

Hallo,
try it yourself, what is right and what is wrong:

Code: Select all

A = 10
B = 10

If not (A = B)
	MsgBox, not (A = B)
Else
	MsgBox, (A = B)
If not (A = %B%)
	MsgBox, not (A = `%B`%)
Else
	MsgBox,  (A = `%B`%)

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 74 guests