The following is the code I run,
from ApplicationServices import AXUIElementCreateSystemWide,AXUIElementCopyAttributeValue
root=AXUIElementCreateSystemWide()
error,value=AXUIElementCopyAttributeValue(root,'AXFocusedApplication',None)
print(value,error)
and on console I got
I granted the permission for accessibility in the settings for Terminal, vs-code, vmware-tools-daemon
The macos is in VM.
Thanks for creating this project...