Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Mouse/Key Messages in Windows Service

Mouse/Key Messages in Windows Service

Scheduled Pinned Locked Moved C#
csharpjsontutorialquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    krisp
    wrote on last edited by
    #1

    I would like to be able to perform background work in my C# .net Windows Service if no mouse messages or key messages have be received for 10 minutes. It involves downloading, uploading and processing, I would like to be able to tell if the computer has been idle from the user to a 10 minute period and then I would start these routines/processes. I see how to do this with Forms with overriding the WinProc method, but I need Windows Messages for a Service, and I think the Forms WinProc method only gets events when the mouse is moved over top of it. I need Messages that occure anywhere within Windows/OS/Desktop. Is there any Windows API methods to import or any idea how to do this? Thanks in advance.

    J J J 3 Replies Last reply
    0
    • K krisp

      I would like to be able to perform background work in my C# .net Windows Service if no mouse messages or key messages have be received for 10 minutes. It involves downloading, uploading and processing, I would like to be able to tell if the computer has been idle from the user to a 10 minute period and then I would start these routines/processes. I see how to do this with Forms with overriding the WinProc method, but I need Windows Messages for a Service, and I think the Forms WinProc method only gets events when the mouse is moved over top of it. I need Messages that occure anywhere within Windows/OS/Desktop. Is there any Windows API methods to import or any idea how to do this? Thanks in advance.

      J Offline
      J Offline
      J Dunlap
      wrote on last edited by
      #2

      krisp wrote: I see how to do this with Forms with overriding the WinProc method, but I need Windows Messages for a Service, and I think the Forms WinProc method only gets events when the mouse is moved over top of it. I need Messages that occure anywhere within Windows/OS/Desktop. You'll need to use a system-wide hook DLL, which cannot be written from C# - you'll probably want to write it in C++. You can then use this from your C# application.

      **"Worry not that no one knows of you; seek to be worth knowing." -- Confucius

      FLUID UI Toolkit | FloodFill in C# & GDI+**

      1 Reply Last reply
      0
      • K krisp

        I would like to be able to perform background work in my C# .net Windows Service if no mouse messages or key messages have be received for 10 minutes. It involves downloading, uploading and processing, I would like to be able to tell if the computer has been idle from the user to a 10 minute period and then I would start these routines/processes. I see how to do this with Forms with overriding the WinProc method, but I need Windows Messages for a Service, and I think the Forms WinProc method only gets events when the mouse is moved over top of it. I need Messages that occure anywhere within Windows/OS/Desktop. Is there any Windows API methods to import or any idea how to do this? Thanks in advance.

        J Offline
        J Offline
        jeff_martin
        wrote on last edited by
        #3

        If you are using Windows 2000 or above, you can use the GetLastInputInfo API call. You get a structure with the tick count when the last input event happened.

        K 1 Reply Last reply
        0
        • K krisp

          I would like to be able to perform background work in my C# .net Windows Service if no mouse messages or key messages have be received for 10 minutes. It involves downloading, uploading and processing, I would like to be able to tell if the computer has been idle from the user to a 10 minute period and then I would start these routines/processes. I see how to do this with Forms with overriding the WinProc method, but I need Windows Messages for a Service, and I think the Forms WinProc method only gets events when the mouse is moved over top of it. I need Messages that occure anywhere within Windows/OS/Desktop. Is there any Windows API methods to import or any idea how to do this? Thanks in advance.

          J Offline
          J Offline
          Jonathan Slenders
          wrote on last edited by
          #4

          I've a similar question. I'm being with a project which can create shortcuts for windows. Is it possible to get a signal if for example the "P" button is pressed Jonathan Slenders

          1 Reply Last reply
          0
          • J jeff_martin

            If you are using Windows 2000 or above, you can use the GetLastInputInfo API call. You get a structure with the tick count when the last input event happened.

            K Offline
            K Offline
            krisp
            wrote on last edited by
            #5

            Awesome, thanks alot Jeff, that is exaclty what I needed, i guess I can just call it in a seperate thread every minute or so. Thanks again :) The GetLastInputInfo function retrieves the time of the last input event. Syntax: BOOL GetLastInputInfo( PLASTINPUTINFO plii ); Parameters: plii - [out] - Pointer to a LASTINPUTINFO structure that receives the time of the last input event. Return Value: If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. Remarks: This is useful for input idle detection. Function Information: Header Declared in Winuser.h, include Windows.h Import library User32.lib Minimum operating systems Windows 2000 See Also: Keyboard Input, LASTINPUTINFO

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups