I am trying to get the positions of the desktop icons in python so that i can get the number items lies horizontally and vertically. So is there any python package so i can use that.
If the info is in the Windows registry, as I suspect it is, then one can access it via the winreg module. But I would not know the keys. Also note that icon are not neatly packed.
@eryksun Do you have an answer, or an idea of where to look?
The shell saves the state in a
REG_BINARY value named “IconLayouts”. This registry value can be parsed to try to determine the grid layout of desktop icons, if the user has grid alignment enabled. Bear in mind that the structure of “IconLayouts”, and even its existence, is an unreliable implementation detail.
Alternatively, there are examples online that directly access the shell’s ListView control that contains the desktop icons. However, that’s also an implementation detail, which actually has changed in recent versions of Windows.
The recommended way to get the positions of desktop icons is to use the documented COM interfaces of the shell. Raymond Chen provides an example in “Manipulating the positions of desktop icons”. Unfortunately, PyWin32 doesn’t implement the required
IFolderView interface, but Simon Mourier is working on it.