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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Screensaver: keyboard and mouse hook and kill screensaver

Screensaver: keyboard and mouse hook and kill screensaver

Scheduled Pinned Locked Moved C / C++ / MFC
comquestionlounge
3 Posts 1 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.
  • D Offline
    D Offline
    Drugodrf
    wrote on last edited by
    #1

    In a application i writing, i want: - read if the user enabled system screen saver - read screen saver timeout - disable screen saver - the computer is connected to a external device: when this device is "sleeping", i starts to counts time and when it arrives to screen saver timeout, starts the screen saver. Until here i don't have problems: they start from here: - if the user move mouse or hit key, screen saver has to stop: is used this: http://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/3d9bb875-8e79-4c1e-b2ef-b24503e6abbd/how-to-create-a-keyboard-and-mouse-hook-in-visual-c-2005?forum=windowssdk[^] but it works only if the focus is on my application, don't works if focus it's on another window. - when the device "wake-up", the screen saver have to stop: i used this: http://msdn.microsoft.com/en-us/magazine/cc301462.aspx[[^](http://msdn.microsoft.com/en-us/magazine
    /cc301462.aspx "New Window")] but it's works only the first time: if the screen saver starts another time it don't works no more; i have to exit and starts again my application and then it works again only one time. Thanks Drugo

    D 1 Reply Last reply
    0
    • D Drugodrf

      In a application i writing, i want: - read if the user enabled system screen saver - read screen saver timeout - disable screen saver - the computer is connected to a external device: when this device is "sleeping", i starts to counts time and when it arrives to screen saver timeout, starts the screen saver. Until here i don't have problems: they start from here: - if the user move mouse or hit key, screen saver has to stop: is used this: http://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/3d9bb875-8e79-4c1e-b2ef-b24503e6abbd/how-to-create-a-keyboard-and-mouse-hook-in-visual-c-2005?forum=windowssdk[^] but it works only if the focus is on my application, don't works if focus it's on another window. - when the device "wake-up", the screen saver have to stop: i used this: http://msdn.microsoft.com/en-us/magazine/cc301462.aspx[[^](http://msdn.microsoft.com/en-us/magazine
      /cc301462.aspx "New Window")] but it's works only the first time: if the screen saver starts another time it don't works no more; i have to exit and starts again my application and then it works again only one time. Thanks Drugo

      D Offline
      D Offline
      Drugodrf
      wrote on last edited by
      #2

      I find a error in the thread code: i call stop to screen saver in the other thread, more slow, than the thread where check if is all in stop; so the first don't know that if is all stopped; now it works - i'm sorry. At the moment remains the problem regarding the hook: if i have the focus in my application, it works, but if i open the notepad and change focus, this hook don't works. Feel like the hook is "attacked" only on my application: It's due to the fact that the winthread object is called inside my application ? I have to change hook code ? Thank you Drugo

      D 1 Reply Last reply
      0
      • D Drugodrf

        I find a error in the thread code: i call stop to screen saver in the other thread, more slow, than the thread where check if is all in stop; so the first don't know that if is all stopped; now it works - i'm sorry. At the moment remains the problem regarding the hook: if i have the focus in my application, it works, but if i open the notepad and change focus, this hook don't works. Feel like the hook is "attacked" only on my application: It's due to the fact that the winthread object is called inside my application ? I have to change hook code ? Thank you Drugo

        D Offline
        D Offline
        Drugodrf
        wrote on last edited by
        #3

        Today i'm find the correct way to work; i don't know why, but i'm fixed on the way to count time for starts screen saver inside my application, so i need hooks; i try to use hooks (i need global hook) and it works, but i think it's better in another way: the correct way is leave the screen saver administration to the system and enable it or disable it when occurs; the correct way is: - Read if the screen saver is enabled from the system (so i know if i have to use it) - If disabled i do nothing - If enabled, disable it - Run all on my application - If device is sleeping for 1 minute, enable screen saver and reset counting - If device is current in use, disable screen saver and reset counting The rest it' better leave to the system: in this way i have only a delay of one minute for screen saver starting. Now it works fine; i'm sorry for these post. Thank you Drugo

        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