Skip to content

Automatically toggle listen mode in UltraVNC Viewer when the PC is idle/not idle #197

Open
@panreyes

Description

It would be a nice feature to automatically disable listen mode in UltraVNC Viewer then the PC is idle and enable it back again when the user gets back.

It would be helpful to:

  • Find out if the user is available to receive the connection.
  • Improve security in PCs that are never shut down.

I believe it could be done with GetLastInputInfo from windows.h:
https://learn.microsoft.com/bs-latn-ba/windows/win32/api/winuser/nf-winuser-getlastinputinfo

Here's an example snippet:

#include <iostream>
#include <windows.h>

// Function to get the idle time in seconds
DWORD GetIdleTime() {
    LASTINPUTINFO lastInputInfo;
    lastInputInfo.cbSize = sizeof(LASTINPUTINFO);
    if (GetLastInputInfo(&lastInputInfo)) {
        DWORD currentTime = GetTickCount();
        return (currentTime - lastInputInfo.dwTime) / 1000;
    }
    return 0;
}

int main() {
    while (true) {
        DWORD idleTime = GetIdleTime();
        std::cout << "Idle time in seconds: " << idleTime << std::endl;
        Sleep(1000);  // Sleep for 1 second before checking again
    }
    return 0;
}

Metadata

Assignees

Labels

RudiRudi answer is needed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions