Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Fri Nov 15, 2019 8:38 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: WFS - Turn off screen saver
PostPosted: Fri Sep 14, 2012 12:43 pm 
Offline
User avatar

Joined: Sat May 27, 2006 3:27 pm
Posts: 480
Hello
I am building an alarm clock when the alarm clock fires opens the alarm window if a users screen saver is running i wanted to close the screen saver. I was messing around with the WFS SystemParameters methods to try to get this to work. Any ideas on how i can get this to work?

Sub ScreenSaverTimer
If Not SystemParameters.ScreenSaverActive Then
'The users screensaver settings are set to off so bail out
Exit
ElseIf SystemParameters.ScreenSaverRunning Then
' The screen saver is running turn it off
If SystemParameters.ScreenSaverActive Then
SystemParameters.ScreenSaverActive = False
End
ElseIf Not SystemParameters.ScreenSaverRunning Then
' The screen saver is not running turn it back on
If Not SystemParameters.ScreenSaverActive Then
SystemParameters.ScreenSaverActive = True
End
End
End Sub


Top
 Profile  
Reply with quote  
 Post subject: Re: [Resolved] - WFS - Turn off screen saver
PostPosted: Sun Sep 16, 2012 12:28 pm 
Offline
User avatar

Joined: Sat May 27, 2006 3:27 pm
Posts: 480
Nm i answered my own question a lil bit of searching an vb converting did the trick

Start: ScreenSaver
Sub StartScreenSaver( w As Window )
Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( hWnd As Integer, wMsg As Integer, wParam As Integer, lParam As Integer ) As Integer

Const SC_SCREENSAVE = &HF140
Const WM_SYSCOMMAND = &H112

Call SendMessage(w.handle, WM_SYSCOMMAND, SC_SCREENSAVE, 0)
End


Stop: ScreenSaver
Sub StopScreenSaver
Declare Function GetForegroundWindow Lib "user32" ( ) As Integer
Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( hWnd As Integer, wMsg As Integer, wParam As Integer, lParam As Integer ) As Integer

Const WM_CLOSE = &H10

'Users screensaver turned on
If SystemParameters.ScreenSaverActive Then
'Users screensaver running
If SystemParameters.ScreenSaverRunning Then
'Close the screensaver
Call SendMessage(GetForegroundWindow(), WM_CLOSE, 0, 0)
End
End
End Sub


call it like this below in a button's action event

Call StartScreenSaver( MyWindow ) 'Your Main Windows Name


Last edited by sinner on Wed Sep 19, 2012 1:24 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: WFS - Turn off screen saver
PostPosted: Tue Sep 18, 2012 3:14 pm 
Offline

Joined: Sat Oct 01, 2005 5:19 pm
Posts: 3216
http://forums.realsoftware.com/viewtopic.php?f=1&t=32907&hilit=Sleep+mode


Top
 Profile  
Reply with quote  
 Post subject: Re: WFS - Turn off screen saver
PostPosted: Wed Sep 19, 2012 6:43 am 
Offline
User avatar

Joined: Sat May 27, 2006 3:27 pm
Posts: 480
Nice thanks :D

Only thing is i have to test your code to see if it works on XP


Top
 Profile  
Reply with quote  
 Post subject: Re: WFS - Turn off screen saver
PostPosted: Wed Sep 19, 2012 9:24 am 
Offline
User avatar

Joined: Mon Jan 02, 2012 1:51 am
Posts: 382
Location: India
I test the code and got a compilr error "The method/property does not exists." in the line.....

If SystemParameters.ScreenSaverActive Then


When i commented those lines and run it, can't able to see any screen saver.

_________________
Amitava Karan
Real Studio 2012 Release 1
Windows 7 (32 bit)
Mac OS X Version 10.7


Top
 Profile  
Reply with quote  
 Post subject: Re: WFS - Turn off screen saver
PostPosted: Wed Sep 19, 2012 1:10 pm 
Offline
User avatar

Joined: Sat May 27, 2006 3:27 pm
Posts: 480
amitavak wrote:
I test the code and got a compilr error "The method/property does not exists." in the line.....

If SystemParameters.ScreenSaverActive Then


When i commented those lines and run it, can't able to see any screen saver.



the SystemParameters is a module from the

Windows Functionality Suite DownloadLink
http://www.arbpmembers.org/index2.php?o ... le&id=1139

My code above i converted from vb this is the source codes link
http://www.codeproject.com/Articles/120 ... creensaver

Also i am running WindowsXP so idk if those API work on other Windows platforms


Top
 Profile  
Reply with quote  
 Post subject: Re: WFS - Turn off screen saver
PostPosted: Thu Sep 20, 2012 8:52 am 
Offline
User avatar

Joined: Sat May 27, 2006 3:27 pm
Posts: 480
Jym wrote:


Your screensaver code did not work for windows XP

Here is another alternative i found to easily disable/enable t screen saver without all that coding

'http://www.ehow.com/how_6943238_disable-windows-screensaver-registry.html

Sub EnableScreenSaver(Enabled as Boolean)
Dim Reg As RegistryItem
Reg = New RegistryItem("HKEY_CURRENT_USER\Control Panel\Desktop")

Select Case Enabled

Case True
Reg.Value("ScreenSaveActive") = "1"

Case False
Reg.Value("ScreenSaveActive") = "0"
End Select
End Sub


App.Open
Call EnableScreenSaver(False)


App.Close
Call EnableScreenSaver(True)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group