mories
asked on
Terminating a screensaver..
Hello,
Is it possible to detect if a screensaver is running ?
and if it is running can i terminate it even if it has an password ?
Procedure TNoteBoxMain.BreakScreenSa ver;
Var
Point: TPoint;
WHandle: THandle;
Begin
With Point do Begin X:= 16; Y:= 16; end;
WHandle:= WindowFromPoint(Point);
SendMessage(WHandle,WM_M BUTTONDOWN ,0,255);
End;
this procedure terminates a screensaver with no password, but is has no detecting if a screensav is running
and when then screensav has a password it show the dialog box to enter the password.
Any help would be appreciated..
Is it possible to detect if a screensaver is running ?
and if it is running can i terminate it even if it has an password ?
Procedure TNoteBoxMain.BreakScreenSa
Var
Point: TPoint;
WHandle: THandle;
Begin
With Point do Begin X:= 16; Y:= 16; end;
WHandle:= WindowFromPoint(Point);
SendMessage(WHandle,WM_M
End;
this procedure terminates a screensaver with no password, but is has no detecting if a screensav is running
and when then screensav has a password it show the dialog box to enter the password.
Any help would be appreciated..
ASKER
But what if i don't know the handle of the screensaver i don't even know what and if a screensaver is installed...
Ups forgot that.. Here is what you can do..
--------
SystemParametersInfo(SPI_G
if dummy = 0 then begin
With Point do Begin X:= 16; Y:= 16; end;
WHandle:= WindowFromPoint(Point);
Debug.Text := 'Screensave destroyed';
SendMessage(WHandle,WM_DES
end else
Debug.Text := 'No screensaver';
-------
SystemParametersInfo(SPI_G
screen saver running..
You can use TerminateProcess(WHandle) too tho..
But of course you should try to close it nicely first..
SendMessage(WHandle, WM_CLOSE, 0, 0); will ask it to die, but
if a password is set it wont close. Then you should send
WM_DESTROY
But of course you should try to close it nicely first..
SendMessage(WHandle, WM_CLOSE, 0, 0); will ask it to die, but
if a password is set it wont close. Then you should send
WM_DESTROY
ASKER
I think this one is not very easy,
this SPI_GETSCREENSAVEACTIVE only looks if a screensaver is configured, it doesn't check if the screensaver is running.
you can test it if you put this in an OnClick event.
I hope this one can be solved.
this SPI_GETSCREENSAVEACTIVE only looks if a screensaver is configured, it doesn't check if the screensaver is running.
you can test it if you put this in an OnClick event.
I hope this one can be solved.
Hmm.. Well since the screensaver always is the highest window
I guess this should work if you don't want to use
the point hack.
----------------
if dummy = 0 then begin
WHandle := GetTopWindow(0);
Debug.Text := 'Screensave destroyed';
SendMessage(WHandle,WM_DES TROY,0,0);
end else
Debug.Text := 'No screensaver';
end;
--------------------------
I guess this should work if you don't want to use
the point hack.
----------------
if dummy = 0 then begin
WHandle := GetTopWindow(0);
Debug.Text := 'Screensave destroyed';
SendMessage(WHandle,WM_DES
end else
Debug.Text := 'No screensaver';
end;
--------------------------
Are you sure?
I actually tried that SPI_GETSCREENSAVEACTIVE and it did return 0 when a screensaver were running and 1 if no were.
Lemme test some more..
I actually tried that SPI_GETSCREENSAVEACTIVE and it did return 0 when a screensaver were running and 1 if no were.
Lemme test some more..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
a normal attempt to close the program..
However you can kill the program brutally (and therefor skip the
password part even if it is set)..
Use this SendMessage line instead:
SendMessage(WHandle,WM_DES
Hope this helps..