-1

I want to check if device is enabled or disabled using python. I want to make a program that would toggle touchscreen on my laptop.

I tried looking for module or cmd command that could do this, but I didn't find any solutions.

Compo
  • 36,585
  • 5
  • 27
  • 39
  • What exactly do "device is enabled" and "device is disabled" mean? What does "toggle touchscreen" mean? I do not know what you are asking for. – John Gordon Aug 15 '23 at 22:23
  • In device manager you can disable or enable device, that looks something like [this](https://imgur.com/a/yGs5z0m). I want to check state of it. If you need any more info let me know. – David Tomic Aug 15 '23 at 22:30
  • That screenshot is so generic, I have no idea what it is actually meant to do. Please explain what "disabling a device" **actually means**. – John Gordon Aug 15 '23 at 22:32
  • If you disable a device it won't function at all. For example, I have a camera and I disable it, it won't work until I enable it again. – David Tomic Aug 15 '23 at 22:39

1 Answers1

1

I have two choices for you.

Everything that Device Manager does is done through the "setupapi.dll" APIs, which all start with SetupDi. Here is a sample module which can iterate through your devices and return their attributes:

https://github.com/gwangyi/pysetupdi

Alternatively, there is a command called "pnputil" that ships with Windows that can enumerate, enable, and disable devices by their hardware IDs.

https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/pnputil-command-syntax

Tim Roberts
  • 48,973
  • 4
  • 21
  • 30