Is it possible to write a script that would trigger from an email recieved in gmail with a certain subject line and then run a maccro to automate a task involving a few mouse clicks on a web page.

I know there are certain macro recorders out there but the idea is to be AFK and have a script check for a notifications such as emails and run the macro on it's own.

Something like this

CHECK/REFRESH (emails) every 10 seconds

IF (email subject) = X

THEN RUN MACRO

ELSE RETURN TO CHECK/REFRESH