The customer is always right [Updated free tool and source code to prevent a machine from going to sleep!]


This blog has moved to a new location and comments have been disabled.

All old posts, new posts, and comments can be found on The blog of dlaa.me.

See you there!

Comments (11)
  1. wekempf says:

    I always liked the way Toaster behaved here. One of the corners of the screen was configured as a hot spot, and if the mouse was in that corner, the screen saver would not run. A background task spawned at boot time that both suppressed the screen saver as well as turned off sleeping when the mouse was moved to a corner would rock! 🙂

  2. David Anson says:

    wekempf,

    Thanks for the suggestion (and blast from the past)! As you can imagine, that would probably increase the complexity of my 20-line sample by at least an order of magnitude… But I’ll keep it in mind for a future commute. 🙂

  3. rbirkby says:

    Why not just change the "Run: Normal window" drop down in that last screenshot to "Run: Minimized"?

    Or is the KISS approach not OK for some reason?

  4. David Anson says:

    rbirkby,

    That’s a great idea – and it works just fine. 🙂 However, because not everybody uses shortcuts to run programs, I think there’s still value in having support for starting minimized built into Insomnia. For example, one might start Insomnia minimized as part of a script that encodes their music, as part of an automated build system, or something like that. Typically, scenarios such as those utilize command-line scripting and aren’t as well suited to customized shortcuts. Because it ends up being so simple to support this feature in Insomnia itself, it seems reasonable to me to do so considering the additional scenarios it enables.

    Thanks for your feedback!

  5. anonymuos says:

    What about the other request to hide the tray icon by default when run once as an option and make it appear in the tray if run the second time?

  6. David Anson says:

    anonymuos,

    For a sample like this one, I don't think I like the idea of running the executable and having it hide itself completely away by default. The idea that running it a second time would show the notification icon is a nice way of handling the possible user confusion, but (as I said in a reply to a different request above) would increase the complexity of the sample. Given that I'm not sure this new behavior would be something most people would want, I've opted not to implement it so far.

  7. Anonymous says:

    Looks great now that it's minimizable! I like the idea of this method of sleep-prevention more than the methods used by some other programs, which trigger a key-press or a mouse-movement (even if they're just for a fraction of a second, I'd worry about it interfering with something I might be doing at just the wrong moment).

    But I am wondering, could you please try to clarify which OSes this program should work on?

    Windows 2000?

    Windows XP 32 / 64?

    Windows Vista 32 / 64?

    Windows 7 32 / 64?

    Server 2000?

    Server 2003 32 / 64?

    Server 2008 32 / 64?

    I'm surmizing it should be 'all of the above' hopefully, but confirmation would be nice. 🙂

  8. David Anson says:

    Anonymous,

    The underlying SetThreadExecutionState API is documented to work on Windows 2000 Professional/Server and later (independent of 32-/64-bittedness). Insomnia is a .NET 3.5 WPF application; .NET 3.5 is documented to work on  Windows Server 2003, Windows Server 2008, Windows Vista, Windows XP, and Windows 7 (regardless of 32-/64-bit). Therefore, I'd expect Insomnia to work on any machine that satisfies both requirements. 🙂

  9. LB says:

    David…

    Thank you for this program!!!

    The 32 & 64 bit versions of the file won't start minimized using: -minimize

    However, the file in the .NET folder works as described.

  10. David Anson says:

    LB,

    Glad you like it! 🙂

    The lack of support for /minimize in the 32/64-bit versions is deliberate. I discuss why and explain how to do what you want in the 4th and 5th bullet points here: blogs.msdn.com/…/no-rest-for-the-weary-free-tool-and-source-code-to-temporarily-prevent-a-computer-from-entering-sleep-mode-now-available-for-net-32-bit-and-64-bit.aspx

    Hope this helps!

  11. LB says:

    Yes, it does!  Thank you.  I needed the command line ability to have it auto run minimized right before starting a virtual machine.  Thanks for adding the 'how to' for doing so in the bullet point.

Comments are closed.