As far as I know, Gmail accounts may expire if they aren't used in 9 months. Beyond that, it is up to Google's discretion whether they choose to delete accounts or not. There is no guarantee of that.
As for the script, you should check the 'Last account activity' in Gmail. It shows you information about recent activity in your mail. Recent activity includes any time that your mail was accessed using a regular web browser, a POP1 client, a mobile device, etc. They will list the IP address that accessed your mail, the associated location, as well as the time and date.
To see your account activity, click the Details link next to the Last account activity line at the bottom of any Gmail page. Using this information, you can confirm if your script is counted as an activity.