Assuming you are max AA, the following macro will forage for you and then automatically deposit the items you forage in inventory. Set your Forage ability on one of the six your buttons of your Abilities Page [Ctrl + A]; I chose Button 6 for this example.
Social Name: Forage
Line 1: /timer 400
Line 2: /pause 6,/doability 6
:Line 3: /pause 6,/autoinventory
Line 4: /autoinventory
That's it! Happy foraging!