I tried putting in global but that doesn't work.
Function 1:
Code: Select all
RGB_Euclidian_Distance( c1, c2 ) ; find the distance between 2 colors
{ ; function by [VxE], return value range = [0, 441.67295593006372]
; that just means that any two colors will have a distance less than 442
global
r1 := c1 >> 16
g1 := c1 >> 8 & 255
b1 := c1 & 255
r2 := c2 >> 16
g2 := c2 >> 8 & 255
b2 := c2 & 255
result := Sqrt( (r1-r2)**2 + (g1-g2)**2 + (b1-b2)**2 )
return Sqrt( (r1-r2)**2 + (g1-g2)**2 + (b1-b2)**2 )
}
Function 2:
Code: Select all
SwitchDatabase(wintitle, fKey, BGR, BGR2, DB1, DB2, SEQ) ; window title, function key, color to match, other valid color, database 1, database 2, sequence
{
global
SetKeyDelay, 500
WinWait, %wintitle%, , 1
if errorlevel
{
MsGbox, SAP is niet gestart. Start SAP op !
WinWait, %wintitle%
}
else
{
Loop
{
WinActivate, %wintitle%
WinMaximize, %wintitle%
PixelGetColor, SearchColor, 431, 141
if RGB_Euclidian_Distance( %BGR%, %SearchColor% ) < 4.3
; ^ if the difference between BGR and SearchColor is smaller than 4.3, then activate the current database
{
WinActivate, %wintitle%
break
}
if RGB_Euclidian_Distance( %BGR2%, %SearchColor% ) < 4.3
{
MsgBox, 4096, FOUT, Dit is de %DB2% database !
Sleep, 2000
Send, %SEQ%
WinWait, %wintitle%
WinActivate, %wintitle%
Sleep, 100
continue
}
else
{
Send, {%fKey%}
Sleep, 2000
continue
}
}
}
}