Click here to Skip to main content
12,693,601 members (28,365 online)
Click here to Skip to main content
Articles » Languages » C# » Applications » Downloads

Stats

180.2K views
6.3K downloads
96 bookmarked
Posted

Controlling The Screen Saver With C#

, 8 Jan 2007 CPOL
A C# class for monitoring, activating, deactivating, closing, and changing the timeout of the screen saver.
namespace ScreenSaver_Control
{
	partial class ScreenSaverTest
	{
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.IContainer components = null;

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
		protected override void Dispose( bool disposing )
		{
			if( disposing && ( components != null ) )
			{
				components.Dispose( );
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code

		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent( )
		{
			this.labelScreenSaverActive = new System.Windows.Forms.Label( );
			this.labelScreensaverTimeout = new System.Windows.Forms.Label( );
			this.valueScreensaverActive = new System.Windows.Forms.Label( );
			this.valueScreensaverTimeout = new System.Windows.Forms.Label( );
			this.buttonRefresh = new System.Windows.Forms.Button( );
			this.buttonStartStopTimer = new System.Windows.Forms.Button( );
			this.valueKillState = new System.Windows.Forms.Label( );
			this.entryScreensaverTimeout = new System.Windows.Forms.NumericUpDown( );
			this.entryKillPeriod = new System.Windows.Forms.NumericUpDown( );
			this.labelPeriod = new System.Windows.Forms.Label( );
			this.groupBoxSettings = new System.Windows.Forms.GroupBox( );
			this.buttonRestore = new System.Windows.Forms.Button( );
			this.buttonActivate = new System.Windows.Forms.Button( );
			this.buttonUpdateTimeout = new System.Windows.Forms.Button( );
			this.groupBoxTimers = new System.Windows.Forms.GroupBox( );
			this.labelSeconds = new System.Windows.Forms.Label( );
			( ( System.ComponentModel.ISupportInitialize ) ( this.entryScreensaverTimeout ) ).BeginInit( );
			( ( System.ComponentModel.ISupportInitialize ) ( this.entryKillPeriod ) ).BeginInit( );
			this.groupBoxSettings.SuspendLayout( );
			this.groupBoxTimers.SuspendLayout( );
			this.SuspendLayout( );
			// 
			// labelScreenSaverActive
			// 
			this.labelScreenSaverActive.AutoSize = true;
			this.labelScreenSaverActive.Location = new System.Drawing.Point( 31, 34 );
			this.labelScreenSaverActive.Name = "labelScreenSaverActive";
			this.labelScreenSaverActive.Size = new System.Drawing.Size( 108, 13 );
			this.labelScreenSaverActive.TabIndex = 0;
			this.labelScreenSaverActive.Text = "Screen Saver Active:";
			// 
			// labelScreensaverTimeout
			// 
			this.labelScreensaverTimeout.AutoSize = true;
			this.labelScreensaverTimeout.Location = new System.Drawing.Point( 10, 50 );
			this.labelScreensaverTimeout.Name = "labelScreensaverTimeout";
			this.labelScreensaverTimeout.Size = new System.Drawing.Size( 116, 13 );
			this.labelScreensaverTimeout.TabIndex = 1;
			this.labelScreensaverTimeout.Text = "Screen Saver Timeout:";
			// 
			// valueScreensaverActive
			// 
			this.valueScreensaverActive.AutoSize = true;
			this.valueScreensaverActive.Location = new System.Drawing.Point( 141, 34 );
			this.valueScreensaverActive.Name = "valueScreensaverActive";
			this.valueScreensaverActive.Size = new System.Drawing.Size( 35, 13 );
			this.valueScreensaverActive.TabIndex = 2;
			this.valueScreensaverActive.Text = "<null>";
			// 
			// valueScreensaverTimeout
			// 
			this.valueScreensaverTimeout.AutoSize = true;
			this.valueScreensaverTimeout.Location = new System.Drawing.Point( 128, 50 );
			this.valueScreensaverTimeout.Name = "valueScreensaverTimeout";
			this.valueScreensaverTimeout.Size = new System.Drawing.Size( 35, 13 );
			this.valueScreensaverTimeout.TabIndex = 3;
			this.valueScreensaverTimeout.Text = "<null>";
			// 
			// buttonRefresh
			// 
			this.buttonRefresh.Location = new System.Drawing.Point( 33, 79 );
			this.buttonRefresh.Name = "buttonRefresh";
			this.buttonRefresh.Size = new System.Drawing.Size( 75, 23 );
			this.buttonRefresh.TabIndex = 4;
			this.buttonRefresh.Text = "Refresh";
			this.buttonRefresh.UseVisualStyleBackColor = true;
			this.buttonRefresh.Click += new System.EventHandler( this.buttonRefresh_Click );
			// 
			// buttonStartStopTimer
			// 
			this.buttonStartStopTimer.Location = new System.Drawing.Point( 169, 34 );
			this.buttonStartStopTimer.Name = "buttonStartStopTimer";
			this.buttonStartStopTimer.Size = new System.Drawing.Size( 75, 23 );
			this.buttonStartStopTimer.TabIndex = 7;
			this.buttonStartStopTimer.Text = "Start Timer";
			this.buttonStartStopTimer.UseVisualStyleBackColor = true;
			this.buttonStartStopTimer.Click += new System.EventHandler( this.buttonStartStopTimer_Click );
			// 
			// valueKillState
			// 
			this.valueKillState.AutoSize = true;
			this.valueKillState.Location = new System.Drawing.Point( 198, 16 );
			this.valueKillState.Name = "valueKillState";
			this.valueKillState.Size = new System.Drawing.Size( 13, 13 );
			this.valueKillState.TabIndex = 8;
			this.valueKillState.Text = "0";
			// 
			// entryScreensaverTimeout
			// 
			this.entryScreensaverTimeout.Location = new System.Drawing.Point( 253, 48 );
			this.entryScreensaverTimeout.Maximum = new decimal( new int[ ] {
            9999,
            0,
            0,
            0} );
			this.entryScreensaverTimeout.Name = "entryScreensaverTimeout";
			this.entryScreensaverTimeout.Size = new System.Drawing.Size( 47, 20 );
			this.entryScreensaverTimeout.TabIndex = 9;
			this.entryScreensaverTimeout.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
			this.entryScreensaverTimeout.Value = new decimal( new int[ ] {
            5,
            0,
            0,
            0} );
			this.entryScreensaverTimeout.ValueChanged += new System.EventHandler( this.entryScreensaverTimeout_ValueChanged );
			// 
			// entryKillPeriod
			// 
			this.entryKillPeriod.Location = new System.Drawing.Point( 52, 37 );
			this.entryKillPeriod.Name = "entryKillPeriod";
			this.entryKillPeriod.Size = new System.Drawing.Size( 47, 20 );
			this.entryKillPeriod.TabIndex = 10;
			this.entryKillPeriod.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
			this.entryKillPeriod.Value = new decimal( new int[ ] {
            8,
            0,
            0,
            0} );
			this.entryKillPeriod.ValueChanged += new System.EventHandler( this.entryKillPeriod_ValueChanged );
			// 
			// labelPeriod
			// 
			this.labelPeriod.AutoSize = true;
			this.labelPeriod.Location = new System.Drawing.Point( 10, 39 );
			this.labelPeriod.Name = "labelPeriod";
			this.labelPeriod.Size = new System.Drawing.Size( 40, 13 );
			this.labelPeriod.TabIndex = 12;
			this.labelPeriod.Text = "Period:";
			// 
			// groupBoxSettings
			// 
			this.groupBoxSettings.Controls.Add( this.buttonRestore );
			this.groupBoxSettings.Controls.Add( this.buttonRefresh );
			this.groupBoxSettings.Controls.Add( this.buttonActivate );
			this.groupBoxSettings.Controls.Add( this.buttonUpdateTimeout );
			this.groupBoxSettings.Controls.Add( this.entryScreensaverTimeout );
			this.groupBoxSettings.Controls.Add( this.valueScreensaverTimeout );
			this.groupBoxSettings.Controls.Add( this.labelScreensaverTimeout );
			this.groupBoxSettings.Location = new System.Drawing.Point( 13, 13 );
			this.groupBoxSettings.Name = "groupBoxSettings";
			this.groupBoxSettings.Size = new System.Drawing.Size( 306, 118 );
			this.groupBoxSettings.TabIndex = 13;
			this.groupBoxSettings.TabStop = false;
			this.groupBoxSettings.Text = "Settings";
			// 
			// buttonRestore
			// 
			this.buttonRestore.Location = new System.Drawing.Point( 169, 79 );
			this.buttonRestore.Name = "buttonRestore";
			this.buttonRestore.Size = new System.Drawing.Size( 75, 23 );
			this.buttonRestore.TabIndex = 12;
			this.buttonRestore.Text = "Restore";
			this.buttonRestore.UseVisualStyleBackColor = true;
			this.buttonRestore.Click += new System.EventHandler( this.buttonRestore_Click );
			// 
			// buttonActivate
			// 
			this.buttonActivate.Location = new System.Drawing.Point( 169, 16 );
			this.buttonActivate.Name = "buttonActivate";
			this.buttonActivate.Size = new System.Drawing.Size( 75, 23 );
			this.buttonActivate.TabIndex = 11;
			this.buttonActivate.Text = "Activate";
			this.buttonActivate.UseVisualStyleBackColor = true;
			this.buttonActivate.Click += new System.EventHandler( this.buttonActivate_Click );
			// 
			// buttonUpdateTimeout
			// 
			this.buttonUpdateTimeout.Location = new System.Drawing.Point( 169, 45 );
			this.buttonUpdateTimeout.Name = "buttonUpdateTimeout";
			this.buttonUpdateTimeout.Size = new System.Drawing.Size( 75, 23 );
			this.buttonUpdateTimeout.TabIndex = 10;
			this.buttonUpdateTimeout.Text = "<<   Write";
			this.buttonUpdateTimeout.UseVisualStyleBackColor = true;
			this.buttonUpdateTimeout.Click += new System.EventHandler( this.buttonUpdateTimeout_Click );
			// 
			// groupBoxTimers
			// 
			this.groupBoxTimers.Controls.Add( this.labelSeconds );
			this.groupBoxTimers.Controls.Add( this.valueKillState );
			this.groupBoxTimers.Controls.Add( this.entryKillPeriod );
			this.groupBoxTimers.Controls.Add( this.buttonStartStopTimer );
			this.groupBoxTimers.Controls.Add( this.labelPeriod );
			this.groupBoxTimers.Location = new System.Drawing.Point( 13, 137 );
			this.groupBoxTimers.Name = "groupBoxTimers";
			this.groupBoxTimers.Size = new System.Drawing.Size( 306, 73 );
			this.groupBoxTimers.TabIndex = 14;
			this.groupBoxTimers.TabStop = false;
			this.groupBoxTimers.Text = "Periodic Kill Timer";
			// 
			// labelSeconds
			// 
			this.labelSeconds.AutoSize = true;
			this.labelSeconds.Location = new System.Drawing.Point( 105, 39 );
			this.labelSeconds.Name = "labelSeconds";
			this.labelSeconds.Size = new System.Drawing.Size( 47, 13 );
			this.labelSeconds.TabIndex = 13;
			this.labelSeconds.Text = "seconds";
			// 
			// ScreenSaverTest
			// 
			this.AutoScaleDimensions = new System.Drawing.SizeF( 6F, 13F );
			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			this.ClientSize = new System.Drawing.Size( 333, 221 );
			this.Controls.Add( this.valueScreensaverActive );
			this.Controls.Add( this.labelScreenSaverActive );
			this.Controls.Add( this.groupBoxSettings );
			this.Controls.Add( this.groupBoxTimers );
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.Name = "ScreenSaverTest";
			this.Text = "Screen Saver Test";
			this.TopMost = true;
			this.FormClosing += new System.Windows.Forms.FormClosingEventHandler( this.ScreenSaverTest_FormClosing );
			( ( System.ComponentModel.ISupportInitialize ) ( this.entryScreensaverTimeout ) ).EndInit( );
			( ( System.ComponentModel.ISupportInitialize ) ( this.entryKillPeriod ) ).EndInit( );
			this.groupBoxSettings.ResumeLayout( false );
			this.groupBoxSettings.PerformLayout( );
			this.groupBoxTimers.ResumeLayout( false );
			this.groupBoxTimers.PerformLayout( );
			this.ResumeLayout( false );
			this.PerformLayout( );

		}

		#endregion

		private System.Windows.Forms.Label labelScreenSaverActive;
		private System.Windows.Forms.Label labelScreensaverTimeout;
		private System.Windows.Forms.Label valueScreensaverActive;
		private System.Windows.Forms.Label valueScreensaverTimeout;
		private System.Windows.Forms.Button buttonRefresh;
		private System.Windows.Forms.Button buttonStartStopTimer;
		private System.Windows.Forms.Label valueKillState;
		private System.Windows.Forms.NumericUpDown entryScreensaverTimeout;
		private System.Windows.Forms.NumericUpDown entryKillPeriod;
		private System.Windows.Forms.Label labelPeriod;
		private System.Windows.Forms.GroupBox groupBoxSettings;
		private System.Windows.Forms.GroupBox groupBoxTimers;
		private System.Windows.Forms.Button buttonUpdateTimeout;
		private System.Windows.Forms.Button buttonActivate;
		private System.Windows.Forms.Label labelSeconds;
		private System.Windows.Forms.Button buttonRestore;
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

kschulz
Web Developer
United States United States
Kurt's programming career began in 1978, developing firmware for the Zilog Z80-A microprocessor on a Mostek development workstation. For 23 years, Kurt led the development of Human Machine Interface (HMI) programs used in factory automation, marketed and sold worldwide by CTC and Parker Hannifin as ScreenWare, Interact and InteractX. For the last 4 years, Kurt has been consulting on agile development practices and working as an independent software contractor focusing on graphical and user interface development.

Other passions include spending time with his wife Janice, daughters Erica and Laura, scuba diving, target shooting, guitar, travel, and digital photo imaging and restoration. Currently residing in southwestern Ohio.

You may also be interested in...

Pro
Pro
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170118.1 | Last Updated 8 Jan 2007
Article Copyright 2007 by kschulz
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid