Skip to content

How to enable robotgo to support keyboard input control in Windows lock screen state #709

Open
@Resulte

Description

@Resulte

I want to try using RobotGo for keyboard input control in Windows lock screen state, but the actual call fails.
Here is the sample code for my application:

	var err error
	time.Sleep(3 * time.Second)
	err = robotgo.KeyToggle("1")
	err = robotgo.KeyToggle("1", "up")

	time.Sleep(1 * time.Second)
	err = robotgo.KeyToggle("2")
	err = robotgo.KeyToggle("2", "up")

	time.Sleep(1 * time.Second)
	err = robotgo.KeyToggle("3")
	err = robotgo.KeyToggle("3", "up")

	if err != nil {
		fmt.Println(err)
	}

This code runs successfully under normal conditions, but it fails in lock screen state, and the err is still nil.
In lock screen state, I noticed that the internally used SendInput method fails, returning Error code: 5(ERROR_ACCESS_DENIED).
However, even when I run the application with SYSTEM privileges, the same error still occurs.
My testing environment is:

OS: Windows 10
Go version: 1.22

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions