language agnostic - जब कोई उपयोगकर्ता अंतिम बार कुंजी दबाता है (या माउस को स्थानांतरित करता है) तो आप कैसे बता सकते हैं?

original title: "language agnostic - How can you tell when a user last pressed a key (or moved the mouse)?"


In a Win32 environment, you can use the GetLastInputInfo API call in Microsoft documentation. Basically, this method returns the last tick that corresponds with when the user last provided input, and you have to compare that to the current tick to determine how long ago that was.

Xavi23cr has a good example for C# at codeproject.

Any suggestions for other environments?

Win32 वातावरण में, आप Microsoft दस्तावेज़ में GetLastInputInfo API कॉल का उपयोग कर सकते हैं। मूल रूप से, यह विधि उस अंतिम टिक को लौटाती है जो उपयोगकर्ता द्वारा अंतिम बार दिए गए इनपुट से मेल खाती है, ...

यह अनुवाद के बाद का सारांश है, अगर आपको पूरा अनुवाद देखने की आवश्यकता है, तो कृपया 'अनुवाद' आइकन पर क्लिक करें

सभी उत्तर
  • Translate

    As for Linux, I know that Pidgin has to determine idle time to change your status to away after a certain amount of time. You might open the source and see if you can find the code that does what you need it to do.

  • Translate

    You seem to have answered your own question there Nathan ;-) "GetLastInputInfo" is the way to go.

    One trick is that if your application is running on the desktop, and the user connects to a virtual machine, then GetLastInputInfo will report no activity (since there is no activity on the host machine).

    This can be different to the behaviour you want, depending on how you wish to apply the user input.