QB64 Phoenix Edition
Screen Saver Function Call - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10)
+---- Thread: Screen Saver Function Call (/showthread.php?tid=1285)

Pages: 1 2


Screen Saver Function Call - eoredson - 12-16-2022

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&)



RE: Screen Saver Function Call - SMcNeill - 12-16-2022

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.


RE: Screen Saver Function Call - SMcNeill - 12-16-2022

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/windows/win32/api/winuser/nf-winuser-getdesktopwindow


RE: Screen Saver Function Call - SMcNeill - 12-16-2022

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.


RE: Screen Saver Function Call - eoredson - 12-16-2022

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.


RE: Screen Saver Function Call - eoredson - 12-17-2022

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



RE: Screen Saver Function Call - SMcNeill - 12-17-2022

Do you have a screensaver enabled?  If you're set to "None", it can't start one at random.


RE: Screen Saver Function Call - Pete - 12-17-2022

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


RE: Screen Saver Function Call - eoredson - 12-17-2022

(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)..


RE: Screen Saver Function Call - Pete - 12-17-2022

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