Recent

Author Topic: How to Prevent Screen Saver and Power Monitor on Windows?  (Read 387 times)

carlosnatal

  • Newbie
  • Posts: 3
How to Prevent Screen Saver and Power Monitor on Windows?
« on: February 25, 2025, 12:38:41 pm »
For a program presentation i need a rotiine that block power monitor and screen saver program. Do can you help me?

Zvoni

  • Hero Member
  • *****
  • Posts: 2961
Re: How to Prevent Screen Saver and Power Monitor on Windows?
« Reply #1 on: February 25, 2025, 12:54:23 pm »
For a program presentation i need a rotiine that block power monitor and screen saver program. Do can you help me?
For your program presentation, switch it off in Windows Settings......
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Fibonacci

  • Hero Member
  • *****
  • Posts: 669
  • Internal Error Hunter
Re: How to Prevent Screen Saver and Power Monitor on Windows?
« Reply #2 on: February 25, 2025, 12:56:21 pm »
Try this: https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setthreadexecutionstate

Code: Pascal  [Select][+][-]
  1. SetThreadExecutionState(ES_CONTINUOUS or ES_SYSTEM_REQUIRED or ES_DISPLAY_REQUIRED);

Zvoni

  • Hero Member
  • *****
  • Posts: 2961
Re: How to Prevent Screen Saver and Power Monitor on Windows?
« Reply #3 on: February 25, 2025, 01:12:41 pm »
Try this: https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setthreadexecutionstate

Code: Pascal  [Select][+][-]
  1. SetThreadExecutionState(ES_CONTINUOUS or ES_SYSTEM_REQUIRED or ES_DISPLAY_REQUIRED);
From the link above:
Quote
This function does not stop the screen saver from executing.
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1501
    • Lebeau Software
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

RayoGlauco

  • Full Member
  • ***
  • Posts: 196
  • Beers: 1567
Re: How to Prevent Screen Saver and Power Monitor on Windows?
« Reply #5 on: February 25, 2025, 11:26:50 pm »
I use this procedure, which I call periodically with a TTimer:

Code: Pascal  [Select][+][-]
  1. procedure AvoidIdle;
  2. // Creates a null mouse move
  3. // uses JwaWinUser
  4.  var
  5.   Input: TInput;
  6. begin
  7.   Input.mi.dx := 0; // remove a warning
  8.   FillChar(Input, SizeOf(Input), 0);
  9.   Input.mi.mouseData := 0;
  10.   Input.mi.dx := 0;
  11.   Input.mi.dy := 0;
  12.   Input.type_ := INPUT_MOUSE;
  13.   Input.mi.dwFlags := MOUSEEVENTF_MOVE;
  14.   SendInput(1, @Input, SizeOf(Input));
  15. end;
« Last Edit: February 25, 2025, 11:32:52 pm by RayoGlauco »
To err is human, but to really mess things up, you need a computer.

 

TinyPortal © 2005-2018