How to perform some event if the computer is idle for a certain time. Tell me, please, some clever API function. Or if there are none, or you know how to track the mouse movement outside the window of your application, and / or when it is inactive, then share your advice.

    3 answers 3

    Perhaps you need this: GetLastInputInfo (Windows API)

    Only starting from whists, this function gives the structure only to the current user - i.e. in the service will not work.

    • Oh my God, this is exactly what I need! ... Thank you, kind man. “Only starting from whists, this function gives the structure only to the current user” _ in my program it doesn’t matter at all =) especially since it already works in the same username - BStudio
    • Please note that the latter requires a minimum of Windows Vista. - cy6erGn0m
    • I hasten to note that the "minimum Windows Vista" came out already in 2006, i.e. already more than 4 years ago .. it would be time .. it's time to get rid of XP ... - KmUsr
    • Come on you. It’s time to go down with Windows;) - cy6erGn0m
    • Windows 7 is quite happy.) I tried to switch to Ubuntu somehow, but I couldn’t do it anyway .. I came back after a month. And so if you go, then the newcomers to Ubuntu will be the most ... - BStudio
    • And you can a little more detail about the 'Method number 1'? - BStudio

    And what does it mean idle? Do you mean the analysis of CPU usage? Use PerformanceCounter .

    If it's about catching mouse and keyboard movement everywhere, then read Processing Global Mouse and Keyboard Hooks in C # . To understand where your legs grow from, read How to set a Windows hook in Visual C # .NET

    • Second) - BStudio 1:59 pm
    • In general, I would draw attention to the swearing comrade, who was removed for non-normative behavior. In his huge narration about what all the goats and stupid people said that there is some way to zaskedyulit tasku on IDLE, but he did not say how to do it. - cy6erGn0m
    • IDLE .. I heard about such a thing .. but I think this is only for my application ... - BStudio
    • <Processing Global Mouse and Keyboard Hooks in C #> I think it will work .. - BStudio
    • = (... epic fail. B-Sharp is completely there, but I need a hanging Basik ... and translate .. I'm going crazy there. Not a B-Sharp guru =) - BStudio