A possibility that does not rely on any other resource is to have a timer running in the background that simply increments a global variable and fires something at a certain value.
The real pain is to intercept all events that identify user activity and reset that global in this case.
Otherway you should look into the SDK to see if some signal can be obtained by the screen saver mechanism handled by the OS.