Why not change the sleep times to match what you want?

That is, why not set the screen to dim or off then push the sleep time to never or many hours?

While I do have another answer I found folk rarely write their own apps today so if you code in Visual Studio, post again.