Here you go, took 20 minutes including testing.
program New;
{.include SRL/SRL.scar}
function MakeCompass1(Side: string): Boolean;
var
Fx, Fy, dx, dy, StartPos, EndPos, Vline: Integer;
ComMark: Integer;
Left_Right: Boolean;
begin
StartPos := FindCompassAngle;
MarkTime(ComMark);
case LowerCase(Side) of
'n': if StartPos > 180 then EndPos := 360 else EndPos := 0;
'e': if StartPos < 270 then EndPos := 90 else EndPos := 450;
's': EndPos := 180;
'w': if StartPos < 90 then EndPos := -90 else EndPos := 270;
end;
if StartPos > EndPos then Left_Right := True
else if StartPos < EndPos then Left_Right := False
else exit;
VLine := DTMFromString('78DA636C656260286340011FDF3D673002D28' +
'C40FC1F0818416AB270AB0101B09A2622D414E056C3045353835F' +
'0D005A9217D4');
repeat
if Left_Right then KeyDown(VK_RIGHT)
else KeyDown(VK_Left);
Wait((10) + Random(10));
if Left_Right then KeyUp(VK_Right)
else KeyUp(VK_Left);
if (FindDTM(VLine,dx, dy, MMX1, MMY1, MMX2, MMY2)) then
begin
Result := True;
Writeln('Found VLine');
break;
end;
until (TimeFromMark(ComMark) > 7000);
FreeDTM(VLine);
end;
begin
SetupSRL;
ActivateClient;
MakeCompass1('n');
end.
By the way, if you don't need it 100% accurate, then you can move the KeyUp and KeyDown statements outside the loop. If you do this, it will consistently over-shoot by a small amount, but it will be close.