Adapted the script to support controller for Windows and Mac OS (need to be tested).