Earlier quoted context omitted.
No, the company didn't make the right decision. They hired a programmer to do the work of a data-entry person. If they hired that programmer to do the work of a programmer, the automation software would be work-for-hire, and would belong to the company. Since they hired the programmer to do different work, in the absence of an explicit agreement saying otherwise, the automation software belongs to OP, to use (and lic…
Most of the time, employers are savvy enough to write employment contracts which cover this eventuality and lay broad claim to all work products and require the employee to do any sort of work. My guess is that most programmers are employed under contracts that give them no additional recourse if, for an extreme example, their employer decided that they should now spend their time on janitorial duties.
That's a textbook case of constructive dismissal.