Program to prevent timeout.

In using discord, every 15 min I lose a channel connection due to an inactivity timeout from lack of using mouse or keyboard. Any way I can write an app that would periodically perform a mouse or keyboard event that the OS would presume came from the user instead of just being the activity of a background program? What low-level calls would I make to accomplish this.

Thanks!

Platform?

MacOS X

See if the command-line tool caffeinate does what you want. You can start it via a Shell.

http://osxdaily.com/2014/06/16/caffeinate-prevent-sleep-while-command-active-mac-os-x/

I will give it a try, but I doubt it will work. I’ve tried the caffinate app already. This prevents the desktop from going to sleep, but discord is specifically looking for mouse or keyboard movement and is affected even when the entire machine and screen are up, alive, and performing other activities. What I’m hoping to find is any low level call I can make to essentially force an OS keyboard or mouse event. Presumably it would be intercepted by whatever program is then currently active, but I could ensure that my Xojo program was active at the time by bring it forward on my internal timer.

https://github.com/kwhat/libuiohook/blob/1.1/src/darwin/post_event.c