Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: Deactivate Screensaver/Power States while game is running

  1. #11

    Deactivate Screensaver/Power States while game is running

    Client Requires: Windows Vista, Windows XP, or Windows 2000 Professional.
    Server Requires: Windows Server "Longhorn", Windows Server 2003, or Windows 2000 Server.

    from http://msdn2.microsoft.com/en-us/library/aa373208.aspx

  2. #12

    Deactivate Screensaver/Power States while game is running

    The SetThreadExecutionState function cannot be used to prevent the user from putting the computer in standby mode. Applications should respect that the user expects a certain behavior when they close the lid on their laptop or press the power button.

    This function does not stop the screen saver from executing either.
    Uh, I tried the above code, but it seems it indeed doesn't prevent the screensaver from popping in.

  3. #13

    Deactivate Screensaver/Power States while game is running

    Did u try my code?

    I have never had any problems with it.
    The views expressed on this programme are bloody good ones. - Fred Dagg

  4. #14

    Deactivate Screensaver/Power States while game is running

    Quote Originally Posted by Grendelus
    The SetThreadExecutionState function cannot be used to prevent the user from putting the computer in standby mode. Applications should respect that the user expects a certain behavior when they close the lid on their laptop or press the power button.

    This function does not stop the screen saver from executing either.
    Uh, I tried the above code, but it seems it indeed doesn't prevent the screensaver from popping in.
    Are you sure that you are not misinterpretting documentation?
    Multimedia applications, such as video players and presentation applications, must use ES_DISPLAY_REQUIRED when they display video for long periods of time without user input.
    There are only 10 types of people in this world; those who understand binary and those who don't.

  5. #15

    Deactivate Screensaver/Power States while game is running

    [pascal]library setthread;

    uses
    Windows,
    Messages;

    type
    EXECUTION_STATE = DWORD;

    const
    ES_SYSTEM_REQUIRED = DWORD($00000001);
    ES_DISPLAY_REQUIRED = DWORD($00000002);
    ES_USER_PRESENT = DWORD($00000004);
    ES_CONTINUOUS = DWORD($80000000);

    function SetThreadExecutionState(esFlags: EXECUTION_STATE): EXECUTION_STATE; stdcall; external kernel32;

    function Xclusive : pchar; stdcall;
    begin
    SetThreadExecutionState(ES_DISPLAY_REQUIRED or ES_CONTINUOUS);
    end;

    exports Xclusive;
    begin end.[/pascal]

    When I tried to implement into a dll it does not work.
    I MUST be doing something wrong here.

  6. #16

    Deactivate Screensaver/Power States while game is running

    Has anyone got any workarounds to this?

  7. #17

    Deactivate Screensaver/Power States while game is running

    Did you try czar's code? Every application that is currently running gets notified when the screen saver is about to become active, or power save is about to be enabled, and the application has a chance to stop it.

    Use czar's code along with Clootie's code and you should be covered from all angles.

  8. #18

    Deactivate Screensaver/Power States while game is running

    Problem is that I want it implemented in a dll, and don't know what are equivalents for TForm1, Msg etc...

    EDIT: I found this while googling, looks a lot like czar's code.

    Disabling screen saver temporarily
    If you want to turn off the screen saver while your program is running, you don't have to disable the Windows screen saver at all. Just define the following method to handle the appropriate Windows message:

    Code:
    procedure TForm1.AppMessage (var Msg: TMsg; var Handled: boolean);
    begin
      if (Msg.Message = WM_SYSCOMMAND) and (Msg.wParam = SC_SCREENSAVE) then
        Handled := true;
    end;
    
    {On the form's OnCreate event, assign}
    
    Application.OnMessage := AppMessage;
    Problem again is that I don't know how I am supposed to substitute Application.OnMessage and the like in the dll...

    *is it me or the pascal tags do not work?[/code]

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •