go under your options window interface tab and configure number lock to /foward, then make the macro as so
top name forage pick a picture the type following like it is the forward number being between 1 and 500 depending on how many meters u want it to walk normal for foraging would be 25 meters i believe this will allow you to forage while afk
/forage;/pause 5;/forward 1-500;/macro forage