repeat〜loop間がそれだけなら、onkey命令で処理する方が安定すると思うよ

onkey gosub *on_key
stop

*on_key
getkey p1,121
if p1=1 { if a=0 {SetWindowPos hwndact,-1,0,0,0,0,1 or 2 or 16
a=1
} else {SetWindowPos hwndact,-2,0,0,0,0,1 or 2 or 16
SetWindowPos hwndact,1,0,0,0,0,1 or 2 or 16
a=0
}}
return