473,856 Members | 1,659 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Screensaver Event WM_GETMESSAGE Hook

I am trying to capture an event when the screensaver starts. I have code
working on Windows XP etc when the Password/Welcome Screen is enabled
[Workstation is Locked]. Using the Fast User Switching Notifications.

However I am unable to detect the screensaver starting when the screensaver
password option is disabled. When using the WndProc Overrides I am unable to
capture the screensaver event unless the application is active [Our software
often sits in the Windows system tray].

Thank you in advance for any help that is given. I am attempting to use a
Hook to capture the WM_GETMESSAGE Hook using VB.NET my code is as follows:
'--------------------------------------------------------

Imports System.Windows. Forms
Imports System.Runtime. InteropServices

Public Class Screensaver

Dim hp As New HookProc(Addres sOf KeyboardProc)

Public Const WH_GETMESSAGE = 3
Public Const HC_ACTION = 0

Private m_ScreensaverHo ok As IntPtr

Private Declare Auto Function UnhookWindowsHo okEx Lib "user32" Alias
"UnhookWindowsH ookEx" (ByVal hHook As IntPtr) As Integer
Private Declare Auto Function SetWindowsHookE x Lib "user32" (ByVal
idHook As Integer, ByVal lpfn As HookProc, ByVal hMod As Long, ByVal
dwThreadId As Integer) As IntPtr
Private Declare Auto Function CallNextHookEx Lib "user32" (ByVal curHook
As IntPtr, ByVal nCode As Integer, ByVal wParam As Integer, ByVal lParam As
Integer)
Private Delegate Function HookProc(ByVal code As Integer, ByVal wParam
As Integer, ByVal lParam As IntPtr) As IntPtr

' Events
Public Event Screensaver(ByV al m As Message)

Public Sub SetHook()
Dim hInstance As Long =
System.Runtime. InteropServices .Marshal.GetHIN STANCE(System.R eflection.Assem bly.GetExecutin gAssembly.GetMo dules()(0)).ToI nt32()
Dim hThreadId As Integer = AppDomain.GetCu rrentThreadId()
'Dim hThreadId As Integer = 0
m_ScreensaverHo ok = SetWindowsHookE x(WH_GETMESSAGE , hp, hInstance,
hThreadId)
End Sub

Public Sub Unhook()
If m_ScreensaverHo ok.ToInt32 <> 0 Then
UnhookWindowsHo okEx(m_Screensa verHook)
End Sub

Private Function KeyboardProc(By Val nCode As Integer, ByVal wParam As
Integer, ByVal lParam As IntPtr) As IntPtr

If (nCode < HC_ACTION) Then
Return CallNextHookEx( m_ScreensaverHo ok, nCode, wParam,
lParam.ToInt32)

ElseIf (nCode = HC_ACTION) Then
Dim m As Message
m = CType(Marshal.P trToStructure(l Param, GetType(Message )),
Message)
Debug.WriteLine ("Screensave r")
RaiseEvent Screensaver(m)
End If

End Function
End Class
Jul 21 '05 #1
0 4185

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

Similar topics

1
6663
by: klappnase | last post by:
Hello everyone, does anyone know a way to stop the screensaver under linux from starting up while a certain process is running? I need this because I experience a memory leak while recording wav-files every time the screensaver starts. It is a Tkinter application, btw. Any help would be very appreciated. Thanks
2
8575
by: DanielB | last post by:
Does anyone know what the command line argumentto launch a screensaver's options/configuration dialog is on Windows XP Pro? From most of the example source code I can find on the web, it would seem to be '/c' but that does not seem to work for the screensaver I have written. I've tested my code and if '/c' is the first argument then the options dialog is launched but Windows XP does not seem to be supplying the '/c' argument when I...
4
5116
by: Paul Smith | last post by:
I have been given an unusual task to create a Windows Service to do something periodically to make the screensaver timer reset. We have a general policy of locking computers automatically after 10 minutes of inactivity. This windows service would be used on some machines to prevent the lock from occurring every 10 minutes. I have tried to reposition the mouse pointer with the Cursor class in a service, but it does not work -- always...
0
1375
by: Vaughn | last post by:
I'm working on a simple screensaver (it just displays a different image every 5 seconds) but I'm having trouble displaying an image in my form using the BackGroundImage property. I was trying to use an ImageList with 4 items so my code in the ScreenSaverForm_Load event handler looked like this: int iImageShown = 0; int iImageCount = imageList_saver.Images.Count-1; Cursor.Hide(); TopMost = true; while (n != 1) //my infinite loop ; is...
2
2122
by: wushupork | last post by:
I have written a screensaver application in C# .NET and have noticed that whenever the animation loop is running - CPU usage always spikes up close to 100%. My application uses a paint thread which is set at 100ms. the program looks sort of like this: // constructor public Form1() {
4
5511
by: Simon Mercer | last post by:
I have been trying to build a screensaver that will connect to a database and display specific data depending on the user that is logged in. I have managed to get a simple data access screensaver to work, however, i can't get the application to work with some prebuilt assemblies i have. Also, when the screensaver is running under the windows screensaver settings it also will not access the config file. Any pointers would be greatly...
3
9276
by: sanjana | last post by:
hi i want to fire an event if the screen saver starts up i have done it using a timer tick event where i have used the api function to detect if screensaver has started..but this means continuous polling at each timer click.. private void tick(object sender, System.EventArgs e) { const int SPI_GETSCREENSAVERRUNNING = 114; int screenSaverRunning = -1; // is the screen saver running?
2
2870
by: Boris Fortes | last post by:
I need to unhook event receiver as result of native C++ event. It unhooks successfully, but __raise does not return and throws access violation. Visual Studio 2003 How to reproduce: Consol Win32 exe project
0
366
by: Luke | last post by:
I am trying to capture an event when the screensaver starts. I have code working on Windows XP etc when the Password/Welcome Screen is enabled . Using the Fast User Switching Notifications. However I am unable to detect the screensaver starting when the screensaver password option is disabled. When using the WndProc Overrides I am unable to capture the screensaver event unless the application is active . Thank you in advance for any...
0
9920
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9764
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11063
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10790
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10390
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7932
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7098
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5960
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3203
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.