scripting write help

Hello

i have one routerboard.
also 2 adsl that routed in microtik.
in firewall → mange i set action mark routing for each mac address.

i want to write script that change mark routing for each mac address , if any internet route was route.

how may?

thanks