how to make a code run automatically+manually?

Is my logic correct ?

No.

By declaring the variable currentMillis at the start of every loop you reset it. Therefore you will never see it time out.