Else command does not work properly in if expression

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
fellowsets
Posts: 4
Joined: 05 Apr 2020, 10:09

Else command does not work properly in if expression

05 Apr 2020, 10:22

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
User avatar
boiler
Posts: 17056
Joined: 21 Dec 2014, 02:44

Re: Else command does not work properly in if expression

05 Apr 2020, 10:55

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)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, jollyjoe and 138 guests