code for switch then push button to run a code with a limited time

i am trying to find a code that will let me close a switch once the switch is closed it will wait for a pushbutton to be pressed and will run something else for an amount of time after that it will finish and go back to wait for the switch

Why look for it. Why not write it yourself.
Then you also know how to change/fix it when it's not doing what you want.

Start with the basic examples that come with the IDE.
They have all the 'ingredients' to make this easy task happen.
Leo..