Is it possible? Yes you can probably create a macro that does so. Is it practical? Not unless you carry a USB cable or a battery pack with you at all times. CoC requires an active internet connection to play or manage, and you'll also need to install something like Background Manager to keep it running even after the app is closed or the phone is placed in sleep mode, which will significantly drain your battery by demanding resources as well as data/wifi. If you were to run the macro every time by first opening CoC, then applying the maco, you may as well just tap on your resources manually.
Sent from my iPhone via Tapatalk Pro