Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Screen Saver Function Call
#1
I have been using this code to call the screen saver and blank the windows screen:

But for some reason it stopped working!?

Does anyone know of a screen saver function call that actually works?

Thanks, Erik.

Code: (Select All)
' declare external libraries.
Declare Dynamic Library "user32"
  Function SendMessageA%& (ByVal hWnd%&, Byval Msg~&, Byval wParam~%&, Byval lParam%&)
End Declare

' declare screen saver call constants
Const wm_syscommand = &H112&
Const sc_screensave = &HF140&
Sleep 2
s%& = SendMessageA(&HFFFF&, wm_syscommand, sc_screensave, 0&)
Reply
#2
Aren't most (if not all) screensavers nothing more than EXE files that have been changed to have a SCR extension?  Seems to me that you should be able to just SHELL to that SCR file to start it.
Reply
#3
s%& = SendMessageA(&HFFFF&, wm_syscommand, sc_screensave, 0&)

Question:  Where does the &HFFFF come from?  Shouldn't you be calling GetDesktopWindow for that value?

https://learn.microsoft.com/en-us/window...ktopwindow
Reply
#4
The GetDesktopWindow works flawlessly for me in Win11.

Code: (Select All)
' declare external libraries.
Declare Dynamic Library "user32"
    Function SendMessageA%& (ByVal hWnd%&, Byval Msg~&, Byval wParam~%&, Byval lParam%&)
    Function GetDesktopWindow%& ()
End Declare

' declare screen saver call constants
Const wm_syscommand = &H112&
Const sc_screensave = &HF140&
Sleep 2

Print GetDesktopWindow
Print &HFFFF&
Sleep

s%& = SendMessageA(GetDesktopWindow, wm_syscommand, sc_screensave, 0&)



[Image: image.png]

As you can see from the tiny little screenshot above, the value I get from GetDesktopWindow isn't the same as the &HFFFF which you were using.  That could be the whole issue in a nutshell.
Reply
#5
This line didn't do anything:

Code: (Select All)
[code]SendMessageA(GetDesktopWindow, wm_syscommand, sc_screensave, 0&)

[/code]

I am going to shell to scrnsave.scr instead..

Erik.
Reply
#6
This code didn't work either:

Code: (Select All)
f$ = "scrnsave.scr"
g$ = _CWD$
h$ = g$ + "\" + f$
If _FileExists(h$) Then
  Print h$
  Shell _Hide h$
End If
End
Reply
#7
Do you have a screensaver enabled?  If you're set to "None", it can't start one at random.
Reply
#8
Try...

Code: (Select All)
Shell _Hide "cmd /c" + h$


Code: (Select All)
Shell _Hide "cmd /c START " + h$ ' If you don't want it to wait. or...

Code: (Select All)
Shell _Hide _Dontwait "cmd /c " + h$


Pete
Reply
#9
(12-17-2022, 12:46 AM)SMcNeill Wrote: Do you have a screensaver enabled?  If you're set to "None", it can't start one at random.

Ya know, Steve..

You are absolutely correct! I had not checked blank screen saver. DUH Huh

(because i was relying on power setting to put the monitor in sleep mode every 15 minutes)..
Reply
#10
I hate Power....



...Settings!



Shows you guys how slow I type. Actually,  I was considering disabling that little password today. Apparently, along with auto-correct.

Pete
Reply




Users browsing this thread: 3 Guest(s)