Not sure but I think you need to add this line.
Start()
Func Start()
Also change this
$Search = _ImageSearch('pic1.bmp',0,$X,$Y,10)
$Search1 = _ImageSearch('pic2.bmp',0,$X,$Y,10)
MouseMove($X, $Y,5)
MouseClick("Left")
To this.
$Search = _ImageSearch("pic1.BMP",0,$X,$Y,50)
$Search1 = _ImageSearch("pic2.BMP",0,$X1,$Y1,50)
MouseClick("Left", $X, $Y, 1, 5)
MouseClick("Left", $X1, $Y1, 1, 5)