Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than user32, prefix the name with the module name and a period.
let idleTimeSeconds() =
let size = sizeof<LastInputInfo>
let now = uint32 Environment.TickCount
let mutable info = { size = size; dwTime = 0u }
match GetLastInputInfo(&info) with
| 0 -> 0.
| _ -> (now - info.dwTime) / 1000.
Sample code gcc Cygwin:
Prints time in seconds since last user input.
Save to idle.c
Compile at bash command line with: gcc -Wall idle.c
Test it with: sleep 15; ./a.exe
Moving the mouse or pressing the keyboard during the test will alter the result, as expected!
The LASTINPUTINFO structure contains the time of the last input.
5/7/2017 5:16:37 AM - dreijer-75.73.43.6
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).