-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Pedro López Cabanillas
committed
Jan 23, 2020
1 parent
363f205
commit edafdeb
Showing
13 changed files
with
669 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,30 @@ | ||
# screensaver-disabler | ||
Windows ScreenSaver Disabler | ||
# Windows ScreenSaver Disabler | ||
|
||
Does your organization enforce a policy of password protected screensaver kicking-in | ||
every five minutes, and you can't change it? If so, this utility is for you. | ||
|
||
Some programs like the Windows Media Player, or PowerPoint in presentation mode | ||
prevent triggering the screensaver. With good reason. But you may be doing | ||
something else like reading documents on the screen while taking hand notes, or | ||
demoing something and you want to prevent the screen-saver-password disruptions. | ||
|
||
Look to the source code to integrate this functionality in your own applications. | ||
Please take a look to the win32 API function [SetThreadExecutionState](https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setthreadexecutionstate). | ||
|
||
|
||
[FlagsAttribute] | ||
public enum EXECUTION_STATE : uint | ||
{ | ||
ES_AWAYMODE_REQUIRED = 0x00000040, | ||
ES_CONTINUOUS = 0x80000000, | ||
ES_DISPLAY_REQUIRED = 0x00000002, | ||
ES_SYSTEM_REQUIRED = 0x00000001 | ||
// Legacy flag, should not be used. | ||
// ES_USER_PRESENT = 0x00000004 | ||
} | ||
|
||
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] | ||
static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE esFlags); | ||
|
||
This program is written in C# for NET Framework 7, and will run in 32 and 64 bit Windows 10 systems. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.28307.1000 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScreenSaverDisabler", "ScreenSaverDisabler\ScreenSaverDisabler.csproj", "{B2382AE5-8EBF-4C30-925E-F4534E292D3D}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{B2382AE5-8EBF-4C30-925E-F4534E292D3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{B2382AE5-8EBF-4C30-925E-F4534E292D3D}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{B2382AE5-8EBF-4C30-925E-F4534E292D3D}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{B2382AE5-8EBF-4C30-925E-F4534E292D3D}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {3C342EC7-A4EE-4858-9998-1042F2447E34} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7" /> | ||
</startup> | ||
</configuration> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using System.Windows.Forms; | ||
|
||
namespace Monon | ||
{ | ||
|
||
public partial class FormMain : Form | ||
{ | ||
|
||
[FlagsAttribute] | ||
public enum EXECUTION_STATE : uint | ||
{ | ||
ES_AWAYMODE_REQUIRED = 0x00000040, | ||
ES_CONTINUOUS = 0x80000000, | ||
ES_DISPLAY_REQUIRED = 0x00000002, | ||
ES_SYSTEM_REQUIRED = 0x00000001 | ||
// Legacy flag, should not be used. | ||
// ES_USER_PRESENT = 0x00000004 | ||
} | ||
|
||
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] | ||
static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE esFlags); | ||
|
||
public FormMain() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void keepOnSw_CheckedChanged(object sender, EventArgs e) | ||
{ | ||
prevent_screensaver(keepOnSw.Checked); | ||
} | ||
|
||
private void prevent_screensaver(bool sw) | ||
{ | ||
if (sw) | ||
{ | ||
SetThreadExecutionState(EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS); | ||
} | ||
else | ||
{ | ||
SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS); | ||
} | ||
} | ||
|
||
private void FormMain_Load(object sender, EventArgs e) | ||
{ | ||
keepOnSw.Checked = true; | ||
} | ||
|
||
private void FormMain_FormClosed(object sender, FormClosedEventArgs e) | ||
{ | ||
prevent_screensaver(false); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<root> | ||
<!-- | ||
Microsoft ResX Schema | ||
Version 2.0 | ||
The primary goals of this format is to allow a simple XML format | ||
that is mostly human readable. The generation and parsing of the | ||
various data types are done through the TypeConverter classes | ||
associated with the data types. | ||
Example: | ||
... ado.net/XML headers & schema ... | ||
<resheader name="resmimetype">text/microsoft-resx</resheader> | ||
<resheader name="version">2.0</resheader> | ||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> | ||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> | ||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> | ||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> | ||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> | ||
<value>[base64 mime encoded serialized .NET Framework object]</value> | ||
</data> | ||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> | ||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> | ||
<comment>This is a comment</comment> | ||
</data> | ||
There are any number of "resheader" rows that contain simple | ||
name/value pairs. | ||
Each data row contains a name, and value. The row also contains a | ||
type or mimetype. Type corresponds to a .NET class that support | ||
text/value conversion through the TypeConverter architecture. | ||
Classes that don't support this are serialized and stored with the | ||
mimetype set. | ||
The mimetype is used for serialized objects, and tells the | ||
ResXResourceReader how to depersist the object. This is currently not | ||
extensible. For a given mimetype the value must be set accordingly: | ||
Note - application/x-microsoft.net.object.binary.base64 is the format | ||
that the ResXResourceWriter will generate, however the reader can | ||
read any of the formats listed below. | ||
mimetype: application/x-microsoft.net.object.binary.base64 | ||
value : The object must be serialized with | ||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter | ||
: and then encoded with base64 encoding. | ||
mimetype: application/x-microsoft.net.object.soap.base64 | ||
value : The object must be serialized with | ||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter | ||
: and then encoded with base64 encoding. | ||
mimetype: application/x-microsoft.net.object.bytearray.base64 | ||
value : The object must be serialized into a byte array | ||
: using a System.ComponentModel.TypeConverter | ||
: and then encoded with base64 encoding. | ||
--> | ||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> | ||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> | ||
<xsd:element name="root" msdata:IsDataSet="true"> | ||
<xsd:complexType> | ||
<xsd:choice maxOccurs="unbounded"> | ||
<xsd:element name="metadata"> | ||
<xsd:complexType> | ||
<xsd:sequence> | ||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> | ||
</xsd:sequence> | ||
<xsd:attribute name="name" use="required" type="xsd:string" /> | ||
<xsd:attribute name="type" type="xsd:string" /> | ||
<xsd:attribute name="mimetype" type="xsd:string" /> | ||
<xsd:attribute ref="xml:space" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
<xsd:element name="assembly"> | ||
<xsd:complexType> | ||
<xsd:attribute name="alias" type="xsd:string" /> | ||
<xsd:attribute name="name" type="xsd:string" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
<xsd:element name="data"> | ||
<xsd:complexType> | ||
<xsd:sequence> | ||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | ||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> | ||
</xsd:sequence> | ||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> | ||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> | ||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> | ||
<xsd:attribute ref="xml:space" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
<xsd:element name="resheader"> | ||
<xsd:complexType> | ||
<xsd:sequence> | ||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | ||
</xsd:sequence> | ||
<xsd:attribute name="name" type="xsd:string" use="required" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
</xsd:choice> | ||
</xsd:complexType> | ||
</xsd:element> | ||
</xsd:schema> | ||
<resheader name="resmimetype"> | ||
<value>text/microsoft-resx</value> | ||
</resheader> | ||
<resheader name="version"> | ||
<value>2.0</value> | ||
</resheader> | ||
<resheader name="reader"> | ||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | ||
</resheader> | ||
<resheader name="writer"> | ||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | ||
</resheader> | ||
</root> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Windows.Forms; | ||
|
||
namespace Monon | ||
{ | ||
static class Program | ||
{ | ||
/// <summary> | ||
/// Application entry point | ||
/// </summary> | ||
[STAThread] | ||
static void Main() | ||
{ | ||
Application.EnableVisualStyles(); | ||
Application.SetCompatibleTextRenderingDefault(false); | ||
Application.Run(new FormMain()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// La información general de un ensamblado se controla mediante el siguiente | ||
// conjunto de atributos. Cambie estos valores de atributo para modificar la información | ||
// asociada con un ensamblado. | ||
[assembly: AssemblyTitle("ScreenSaverDisabler")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("ScreenSaverDisabler")] | ||
[assembly: AssemblyCopyright("Copyright © Pedro López-Cabanillas 2020")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Si establece ComVisible en false, los tipos de este ensamblado no estarán visibles | ||
// para los componentes COM. Si es necesario obtener acceso a un tipo en este ensamblado desde | ||
// COM, establezca el atributo ComVisible en true en este tipo. | ||
[assembly: ComVisible(false)] | ||
|
||
// El siguiente GUID sirve como id. de typelib si este proyecto se expone a COM. | ||
[assembly: Guid("b2382ae5-8ebf-4c30-925e-f4534e292d3d")] | ||
|
||
// La información de versión de un ensamblado consta de los cuatro valores siguientes: | ||
// | ||
// Versión principal | ||
// Versión secundaria | ||
// Número de compilación | ||
// Revisión | ||
// | ||
// Puede especificar todos los valores o utilizar los números de compilación y de revisión predeterminados | ||
// mediante el carácter '*', como se muestra a continuación: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
Oops, something went wrong.