plexpy/lib/win32comext/shell/demos/IActiveDesktop.py
dependabot[bot] faef9a94c4
Bump cherrypy from 18.8.0 to 18.9.0 (#2266)
* Bump cherrypy from 18.8.0 to 18.9.0

Bumps [cherrypy](https://github.com/cherrypy/cherrypy) from 18.8.0 to 18.9.0.
- [Changelog](https://github.com/cherrypy/cherrypy/blob/main/CHANGES.rst)
- [Commits](https://github.com/cherrypy/cherrypy/compare/v18.8.0...v18.9.0)

---
updated-dependencies:
- dependency-name: cherrypy
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update cherrypy==18.9.0

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>

[skip ci]
2024-03-24 15:25:44 -07:00

83 lines
2.1 KiB
Python

import time
import pythoncom
from win32com.shell import shell, shellcon
website = "https://github.com/mhammond/pywin32/"
iad = pythoncom.CoCreateInstance(
shell.CLSID_ActiveDesktop,
None,
pythoncom.CLSCTX_INPROC_SERVER,
shell.IID_IActiveDesktop,
)
opts = iad.GetDesktopItemOptions()
if not (opts["ActiveDesktop"] and opts["EnableComponents"]):
print("Warning: Enabling Active Desktop")
opts["ActiveDesktop"] = True
opts["EnableComponents"] = True
iad.SetDesktopItemOptions(opts)
iad.ApplyChanges(0xFFFF)
iad = None
## apparently takes a short while for it to become active
time.sleep(2)
iad = pythoncom.CoCreateInstance(
shell.CLSID_ActiveDesktop,
None,
pythoncom.CLSCTX_INPROC_SERVER,
shell.IID_IActiveDesktop,
)
cnt = iad.GetDesktopItemCount()
print("Count:", cnt)
for i in range(cnt):
print(iad.GetDesktopItem(i))
component = {
"ID": cnt + 1,
"ComponentType": shellcon.COMP_TYPE_WEBSITE,
"CurItemState": shellcon.IS_NORMAL,
"SubscribedURL": website,
"Source": website,
"FriendlyName": "Pywin32 on SF",
"Checked": True, ## this controls whether item is currently displayed
"NoScroll": False,
"Dirty": False,
"Pos": {
"Top": 69,
"Left": 69,
"Height": 400,
"Width": 400,
"zIndex": 1002,
"CanResize": True,
"CanResizeX": True,
"CanResizeY": True,
"PreferredLeftPercent": 0,
"PreferredTopPercent": 0,
},
"Original": {
"Top": 33,
"Left": 304,
"Height": 362,
"Width": 372,
"ItemState": shellcon.IS_NORMAL,
},
"Restored": {
"Top": 33,
"Left": 304,
"Height": 362,
"Width": 372,
"ItemState": shellcon.IS_NORMAL,
},
}
try:
existing_item = iad.GetDesktopItemBySource(website)
except pythoncom.com_error:
pass
else:
iad.RemoveDesktopItem(existing_item)
iad.ApplyChanges(0xFFFF)
iad.AddDesktopItem(component)
iad.ApplyChanges(0xFFFF) ## need to check which AD_APPLY constants are actually needed