Jump to content
Sign in to follow this  
MisterBates

Suspend/Resume Screensaver

Recommended Posts

MisterBates

Hi,

My first "industrial strength" script monitors windows/processes on a PC looking for specific window titles/classes and process names, and when one is found, suspends the screensaver until the found window/process stops.

I have it running at startup on my PC looking for MS powerpoint in presentation mode, for netmeeting connected to other people, or for active HP virtual rooms, so that I don't get interrupted by the screensaver. But it could also be used to monitor background processes (like backup, virus scan etc.) so that a CPU-intensive saver is disabled while those things run.

The script demonstrates:

  • Enhanced command-line processing
  • Custom taskbar menu
  • Read/write from registry
  • Multiple icons (compiled into .exe) - see this thread for details
Plans for this script include:
  • Add capability to set Live Messenger/Jabber to "busy" to also avoid being interrupted by IMs (set back to online/avail after)
  • Rewrite to adopt a more logical naming convention (like for example $iXX for integers)
  • Redo the help to show an about window with additional buttons for detailed help (detailed help would be next/prev dialogs) - I want to stick to a single .exe file for distribution!
I've included the compiled .exe as an attachment. If you want to use this on your PC, save to your hard drive, execute the program, then click OK when it asks if you want to install it - after which point, it'll run at startup. There's also a taskbar menu to uninstall.

Would appreciate any/all comments!

MisterBates

EDIT: REQUIRES Auto3Lib (apologies - didn't say that in the original post)

Suspend_Screen_Saver.au3

Suspend_Screen_Saver.exe

Edited by MisterBates

Share this post


Link to post
Share on other sites
Proph

Here is what AU3Check tells me:

C:\PROJECTS\APlus-Maint\APlusMaint 7.04\Files\Suspend_Screen_Saver.au3(22,10) : ERROR: can't open include file <A3LConstants.au3>
#include <A3LConstants.au3>
~~~~~~~~~^
C:\PROJECTS\APlus-Maint\APlusMaint 7.04\Files\Suspend_Screen_Saver.au3(23,10) : ERROR: can't open include file <A3LWinAPI.au3>
#include <A3LWinAPI.au3>
~~~~~~~~~^
C:\PROJECTS\APlus-Maint\APlusMaint 7.04\Files\Suspend_Screen_Saver.au3(101,70) : ERROR: $IconActive previously declared as a 'Const'
    Const $IconActive = @ScriptDir & "\" & $ScriptName & " - Active.ico"
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\PROJECTS\APlus-Maint\APlusMaint 7.04\Files\Suspend_Screen_Saver.au3(102,76) : ERROR: $IconSuspended previously declared as a 'Const'
    Const $IconSuspended = @ScriptDir & "\" & $ScriptName & " - Suspended.ico"
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\PROJECTS\APlus-Maint\APlusMaint 7.04\Files\Suspend_Screen_Saver.au3(121,120) : WARNING: $Response possibly not declared/created yet
                                            "Install/Re-Install in startup folder - with suspends for Powerpoint, NetMeeting and HP Virtual Rooms?", 60)
                                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~^
C:\PROJECTS\APlus-Maint\APlusMaint 7.04\Files\Suspend_Screen_Saver.au3(172,21) : WARNING: $begin possibly not declared/created yet
$begin = TimerInit()
~~~~~~~~~~~~~~~~~~~~^
C:\PROJECTS\APlus-Maint\APlusMaint 7.04\Files\Suspend_Screen_Saver.au3(174,21) : WARNING: $msg possibly not declared/created yet
    $msg = TrayGetMsg()
    ~~~~~~~~~~~~~~~~~~~^
C:\PROJECTS\APlus-Maint\APlusMaint 7.04\Files\Suspend_Screen_Saver.au3(232,84) : WARNING: $matched possibly not declared/created yet
                            $matched = StringRegExp($windows[$j][0], StringMid($SearchFor[$i][1], 2), 0)
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\PROJECTS\APlus-Maint\APlusMaint 7.04\Files\Suspend_Screen_Saver.au3(317,55) : WARNING: $SPIF_UPDATEINIFILE: possibly used before declaration.
  If $Permanent Then $PermFlags = $SPIF_UPDATEINIFILE +
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~^
C:\PROJECTS\APlus-Maint\APlusMaint 7.04\Files\Suspend_Screen_Saver.au3(317,73) : WARNING: $SPIF_SENDCHANGE: possibly used before declaration.
  If $Permanent Then $PermFlags = $SPIF_UPDATEINIFILE + $SPIF_SENDCHANGE
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\PROJECTS\APlus-Maint\APlusMaint 7.04\Files\Suspend_Screen_Saver.au3(319,53) : WARNING: $SPI_SETSCREENSAVEACTIVE: possibly used before declaration.
        _API_SystemParametersInfo($SPI_SETSCREENSAVEACTIVE,
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\PROJECTS\APlus-Maint\APlusMaint 7.04\Files\Suspend_Screen_Saver.au3(346,53) : WARNING: $SPI_GETSCREENSAVEACTIVE: possibly used before declaration.
  _API_SystemParametersInfo($SPI_GETSCREENSAVEACTIVE,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\PROJECTS\APlus-Maint\APlusMaint 7.04\Files\Suspend_Screen_Saver.au3(317,55) : ERROR: $SPIF_UPDATEINIFILE: undeclared global variable.
  If $Permanent Then $PermFlags = $SPIF_UPDATEINIFILE +
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~^
C:\PROJECTS\APlus-Maint\APlusMaint 7.04\Files\Suspend_Screen_Saver.au3(319,75) : ERROR: _API_SystemParametersInfo(): undefined function.
        _API_SystemParametersInfo($SPI_SETSCREENSAVEACTIVE, False, 0, $PermFlags)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\PROJECTS\APlus-Maint\APlusMaint 7.04\Files\Suspend_Screen_Saver.au3 - 6 error(s), 8 warning(s)

I think some files are missing.

BTW... can this only be used for presentation apps? Or would it be possible for me to specify my own process for it to look for?

Share this post


Link to post
Share on other sites
MisterBates

I think some files are missing.

BTW... can this only be used for presentation apps? Or would it be possible for me to specify my own process for it to look for?

Apologies - forgot to specify that the app requires Auto3Lib

This can be used for any app where you know the window title or process name.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×