0

I'm writing a python script in Windows that can control the mouse by using ctypes to call the SendInput function from User32.dll. The script is run as an elevated process, and generally it can interact with all windows, including those from other elevated processes.

However, it cannot click any of the contents of a "User Account Control" window. Note that in my User Account Control settings, I have it configured to not dim the desktop.

What do I need to do so that mouse events created by my script can control the UAC window?

Bri Bri
  • 2,169
  • 3
  • 19
  • 44
  • 1
    You would need to launch a process on the secure desktop to do it on your behalf. – Harry Johnston Nov 03 '16 at 03:10
  • @HarryJohnston Would a process running on the secure desktop be able to send mouse events to processes running on the regular desktop? – Bri Bri Nov 03 '16 at 03:57
  • 1
    Opening a handle to a desktop requires at least read-write access (i.e. `DESKTOP_READOBJECTS | DESKTOP_WRITEOBJECTS`). Only SYSTEM is granted this level of access to the secure `"winlogon"` desktop. You can use a service or the task scheduler to run a process as SYSTEM in the active console session. Then call [`OpenDesktop`](https://msdn.microsoft.com/en-us/library/ms684303) and [`SetThreadDesktop`](https://msdn.microsoft.com/en-us/library/ms686250) to switch the current thread between the `"default"` and `"winlogon"` desktops. – Eryk Sun Nov 03 '16 at 09:58
  • @eryksun is of course correct that you can switch between desktops dynamically - my mistake. – Harry Johnston Nov 03 '16 at 11:05

0 Answers0