I discovered Autohotkey just a few days ago and I found it very useful.
I looked for something ejecting CD when my children leave game CD and shut down computer. I found some programs, but not free. So - I wrote it using AHK...:
#NoTrayIcon #Persistent OnExit, ExitSub return ExitSub: if A_ExitReason in Logoff,Shutdown ; Only if computer is shutted dow or user logs out. { DriveGet, lista, List, CDROM ;get all CD drives Stringlen, cd_len, lista ;how much of drives? Loop, %cd_len% ;for each drive { stringmid cd_letter, lista, %A_Index%, 1 ;get name of drive driveget isopen, StatusCD, %cd_letter% ;check if it is empty if (isopen != "open") ; if not - open it { Drive, Eject, %cd_letter% } } } ExitApp
I hope it will be useful for you.
--
koliberek