Page 1 of 1

Else command does not work properly in if expression

Posted: 05 Apr 2020, 10:22
by fellowsets
I'm trying to make a simple scrip which first waits for the panels color to show (that means panel is loaded) and than if a checbox is unchecked checks it and if it is checked moves mouse to the other box and checks it.

The problem with my script is that it always executes same command: if box is unchecked checks it but if it is checked it unchecks checked box instead of moving and checking other one.(I hope it makes sence).

Here is my script:

Code: Select all

#Singleinstance force
ifWinNotActive ahk_exe Adobe Premiere Pro.exe
	goto monoEnding
juoda = 0xE8E8E8 
pilnas = 0xB9B9B9 ;checked box color
tuscias = 0x1D1D1D ;uncheked box color
#IfWinActive ahk_exe Adobe Premiere Pro.exe 
^F13::
BlockInput, MouseMove
BlockInput, On
CoordMode, Mouse, screen
CoordMode, Pixel, screen
MouseGetPos, xpos, ypos
send, +g
sleep 500
MouseMove, 1700, 1075, 0
sleep 100
PixelGetColor colorrr, 1705, 1080 RGB
bandomdar:
if (%colorrr% = juoda)
{
	goto tesiam
}
else
{
goto bandomdar
}
tesiam:

MouseMove, 1365, 507
PixelGetColor, kolor, 1363, 510
if (%kolor% = pilnas)
{
	sleep 100
	MouseMove, 1340, 508
	sleep 100
	click
	sleep 100
	sendinput, {enter}
}
else if (%kolor% = tuscias)
{
	click
	sleep 100
	sendinput, {enter}
	sleep 100
}
pabaiga:
CoordMode, Mouse, Screen
MouseMove, %xpos%, %ypos%
blockinput, MouseMoveOff
BlockInput, off
monoEnding:
return

Re: Else command does not work properly in if expression

Posted: 05 Apr 2020, 10:55
by boiler
You don’t use % symbols around a variable in an expression (except in special circumstances). So lines like this:

Code: Select all

 if (%colorrr% = juoda)
should be:

Code: Select all

if (colorrr = juoda)

Re: Else command does not work properly in if expression

Posted: 06 Apr 2020, 09:22
by fellowsets
Thank you! :bravo: