473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

To know when OS goes into screen saver

Rob
Is there a way that VB can know when the operating system
goes into screen save mode? I have continuous polling I
wish to pause while in screen save mode. And likewise to
wake back up when the screen saver is turned back off.

Any help on this will be greatly appreciated.

Rob
Nov 20 '05 #1
12 11542
Rob wrote:
Is there a way that VB can know when the operating system
goes into screen save mode? I have continuous polling I
wish to pause while in screen save mode. And likewise to
wake back up when the screen saver is turned back off.

Any help on this will be greatly appreciated.

Rob


You can use SystemParametersInfo with the SPI_GETSCREENSAVERRUNNING flag
to find out if the screen saver is running... In other words, you could
have a timer that fires every second or so and calls this function. If
it's running put your worker thread to sleep. If it's not, wake it up...

HTH,
Tom Shelton

Nov 20 '05 #2
Hi Rob,

Certain Windows events can be waited on, eg system shutdown, display
properties changes, etc.(see the SystemEvents class). Unfortunately there's no
mention of any Windows event occurring when the screen saver starts.

The following is a VB (classic) project which detects whether a
workstation is locked or not. It include some very straightforward code to
detect whether the screen saver is running, but you'll have to keep checking.

http://www.mvps.org/st-software/Code...orkstation.zip

Regards,
Fergus
Nov 20 '05 #3
"Rob" <ro**@stl.NO.hamptontilley.SPAM.com> schrieb
Is there a way that VB can know when the operating system
goes into screen save mode? I have continuous polling I
wish to pause while in screen save mode. And likewise to
wake back up when the screen saver is turned back off.

Any help on this will be greatly appreciated.


Protected Overrides Sub WndProc( _
ByRef m As System.Windows.Forms.Message)

Const WM_SYSCOMMAND As Integer = &H112
Const SC_SCREENSAVE As Integer = &HF140

MyBase.WndProc(m)

If m.Msg = WM_SYSCOMMAND _
AndAlso m.WParam.ToInt32 = SC_SCREENSAVE Then

Debug.WriteLine("Screensaver activated")
End If
End Sub
--
Armin

Nov 20 '05 #4
Armin Zingler wrote:
"Rob" <ro**@stl.NO.hamptontilley.SPAM.com> schrieb
Is there a way that VB can know when the operating system
goes into screen save mode? I have continuous polling I
wish to pause while in screen save mode. And likewise to
wake back up when the screen saver is turned back off.

Any help on this will be greatly appreciated.

Protected Overrides Sub WndProc( _
ByRef m As System.Windows.Forms.Message)

Const WM_SYSCOMMAND As Integer = &H112
Const SC_SCREENSAVE As Integer = &HF140

MyBase.WndProc(m)

If m.Msg = WM_SYSCOMMAND _
AndAlso m.WParam.ToInt32 = SC_SCREENSAVE Then

Debug.WriteLine("Screensaver activated")
End If
End Sub


Well, I'll be... You learn something new every day. That is going down
in my little book of knowledge...

Tom Shelton

Nov 20 '05 #5
Rob
Thank you Armin. That looks very straight forward. Is
there a listing anywhere of these great little Windows
Message constants?

Rob
-----Original Message-----
"Rob" <ro**@stl.NO.hamptontilley.SPAM.com> schrieb
Is there a way that VB can know when the operating system goes into screen save mode? I have continuous polling I wish to pause while in screen save mode. And likewise to wake back up when the screen saver is turned back off.

Any help on this will be greatly appreciated.


Protected Overrides Sub WndProc( _
ByRef m As System.Windows.Forms.Message)

Const WM_SYSCOMMAND As Integer = &H112
Const SC_SCREENSAVE As Integer = &HF140

MyBase.WndProc(m)

If m.Msg = WM_SYSCOMMAND _
AndAlso m.WParam.ToInt32 = SC_SCREENSAVE Then

Debug.WriteLine("Screensaver activated")
End If
End Sub
--
Armin

.

Nov 20 '05 #6
"Tom Shelton" <to*@mtogden.com> schrieb
Protected Overrides Sub WndProc( _
ByRef m As System.Windows.Forms.Message)

Const WM_SYSCOMMAND As Integer = &H112
Const SC_SCREENSAVE As Integer = &HF140

MyBase.WndProc(m)

If m.Msg = WM_SYSCOMMAND _
AndAlso m.WParam.ToInt32 = SC_SCREENSAVE Then

Debug.WriteLine("Screensaver activated")
End If
End Sub


Well, I'll be... You learn something new every day. That is going
down in my little book of knowledge...


:)

Unfortunately, I don't know how to detect when the screen saver is closed.
:-)
--
Armin

Nov 20 '05 #7
Armin Zingler wrote:
"Tom Shelton" <to*@mtogden.com> schrieb
Protected Overrides Sub WndProc( _
ByRef m As System.Windows.Forms.Message)

Const WM_SYSCOMMAND As Integer = &H112
Const SC_SCREENSAVE As Integer = &HF140

MyBase.WndProc(m)

If m.Msg = WM_SYSCOMMAND _
AndAlso m.WParam.ToInt32 = SC_SCREENSAVE Then

Debug.WriteLine("Screensaver activated")
End If
End Sub


Well, I'll be... You learn something new every day. That is going
down in my little book of knowledge...

:)

Unfortunately, I don't know how to detect when the screen saver is closed.
:-)


Well, then... I guess that does put a damper on things :) Using the
SystemParametersInfo - you can find out...

Tom Shelton

Nov 20 '05 #8
Write a DLL that injects itself into the CreateProcess API and detect which
process is created when the screensaver comes active... Then, wait until the
process has terminated and therefore the screen saver has closed.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Chaos, Panic, Disorder, my work here is done"
"Armin Zingler" <az*******@freenet.de> wrote in message
news:#7**************@TK2MSFTNGP11.phx.gbl...
: "Tom Shelton" <to*@mtogden.com> schrieb
: > > Protected Overrides Sub WndProc( _
: > > ByRef m As System.Windows.Forms.Message)
: > >
: > > Const WM_SYSCOMMAND As Integer = &H112
: > > Const SC_SCREENSAVE As Integer = &HF140
: > >
: > > MyBase.WndProc(m)
: > >
: > > If m.Msg = WM_SYSCOMMAND _
: > > AndAlso m.WParam.ToInt32 = SC_SCREENSAVE Then
: > >
: > > Debug.WriteLine("Screensaver activated")
: > > End If
: > > End Sub
: > >
: > >
: >
: > Well, I'll be... You learn something new every day. That is going
: > down in my little book of knowledge...
:
: :)
:
: Unfortunately, I don't know how to detect when the screen saver is closed.
: :-)
:
:
: --
: Armin
:
Nov 20 '05 #9
"Rob" <ro**@stl.NO.hamptontilley.SPAM.com> schrieb
Thank you Armin. That looks very straight forward. Is
there a listing anywhere of these great little Windows
Message constants?

Press <F1> and select "MSDN library". ;-)
In this case, I added
Debug.WriteLine(m)
to Sub WndProc, waited for the screen saver to be started and found out that
WM_SYSCOMMAND is sent. In the help index, after pasting "WM_SYSCOMMAND" you
get the message documentation.
--
Armin

Nov 20 '05 #10
Hello,

"Rob" <ro**@stl.NO.hamptontilley.SPAM.com> schrieb:
Is there a way that VB can know when the operating system
goes into screen save mode? I have continuous polling I
wish to pause while in screen save mode. And likewise to
wake back up when the screen saver is turned back off.


http://www.mvps.org/dotnet/dotnet/sa...tem/index.html
-> "ScreensaverStart"

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #11
"Armin Zingler" <az*******@freenet.de> wrote in
news:eU**************@TK2MSFTNGP10.phx.gbl:

Press <F1> and select "MSDN library". ;-)


In addition, I found the following link very useful...

http://www.codeproject.com/csharp/Win32.asp?df=100
Chris
Nov 20 '05 #12
Rob
Thank you Fergus, I look at the example.

Rob
-----Original Message-----
Hi Rob,

Certain Windows events can be waited on, eg system shutdown, displayproperties changes, etc.(see the SystemEvents class). Unfortunately there's nomention of any Windows event occurring when the screen saver starts.
The following is a VB (classic) project which detects whether aworkstation is locked or not. It include some very straightforward code todetect whether the screen saver is running, but you'll have to keep checking.
http://www.mvps.org/st- software/Code/DetectLockedWorkstation.zip
Regards,
Fergus
.

Nov 20 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Mr. x | last post by:
Hello, Can Html code be a screen saver ? How can I do that ? Thanks :)
2
by: Card.Starzinger | last post by:
Hi! I need help to simulate programmatically user interaction on WinNT 4.0, to avoid screen saver activation. I try with key injection event. SendInput API and keybd_event API work...
3
by: Thom Little | last post by:
How do I invoke the current screen saver with C#? Where did you find the information on how to do it? -- -- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd. --
2
by: Dwight Trumbower | last post by:
When doing a SaveAS on workbook, within a c# program, and the screen saver has activated, I always get the error message: "Excel cannot complete this task with available resources". I've looked...
1
by: Daniel | last post by:
Hi all, i have a doubt related to the screen saver ability. After developing the asp.net webform, can i add screen saver ability in this webform? which means, i open the asp.net webform, after a...
3
by: James Mc | last post by:
I need some help creating a screensaver in VB.NET How do I detect a mouse movement while the screen saver is running, then close the screen saver? Thanks JamesMc
4
by: Shawn Mehaffie | last post by:
I have created a screen saver using VB.Net but cannot find any articles or examples on how to write the code for the /p parameter (display in dialog preview window). All the .Net exmaples I have...
1
by: ashwiniappajigowda | last post by:
Hi, I have an simple MFC dialog based application. On launch of that application 'Password protected screen saver' is not getting activated after the screen saver timeout. If 'On resume,...
0
by: rehanrana | last post by:
I built application in VB6, my application appear in system tray, when I double click on icon of my application, it run screen saver, my screen saver shows images and news. Screen saver...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.