You can write the macro. Most of it would be via the 'intent' actions/triggers, but I don't know enough about coding up nfc as a developer to know if it would even look for anything more than tags without the screen on/unlocked. Quick search though, you could probably find the answer (as well as the knowledge to write all that) here: Android Dev Guide to NFC
NFC will only work when the screen is unlocked I'm afraid. I believe if you root your phone then this can be changed (sorry I don't know any more details).