def get_windows_sys_props(self, filename): print("WIN32COM.PROPSYS FILE PROPERTIES: ") pk = propsys.PSGetPropertyKeyFromName("System.Keywords") # get property store for a given shell item (here a file) # MAKE SURE YOU USE THE RIGHT SLASHES HERE: ps = propsys.SHGetPropertyStoreFromParsingName( filename.replace('/', '\\')) # build an array of string type PROPVARIANT # newValue = propsys.PROPVARIANTType(["hello", "world"], pythoncom.VT_VECTOR | pythoncom.VT_BSTR) # # write property # ps.SetValue(pk, newValue) # ps.Commit() # read & print existing (or not) property value, System.Keywords type is an array of string title = ps.GetValue(pscon.PKEY_Title).GetValue() print(title) print( "System.Audio.Format", ps.GetValue(propsys.PSGetPropertyKeyFromName( "System.Audio.Format")).GetValue()) # keywords = ps.GetValue(pk).GetValue() # print(keywords) for keyname in keysToGet: print( "{}: ".format(keyname), ps.GetValue( propsys.PSGetPropertyKeyFromName(keyname)).GetValue())
def set_window_group(hwnd, lhandle): try: ps = propsys.SHGetPropertyStoreForWindow(hwnd) key = propsys.PSGetPropertyKeyFromName("System.AppUserModel.ID") value = propsys.PROPVARIANTType(lhandle) log("win32 hooks: calling %s(%s, %s)", ps.SetValue, key, value) ps.SetValue(key, value) except Exception as e: log("set_window_group(%s, %s)", hwnd, lhandle, exc_info=True) log.error("Error: failed to set group leader '%s':", lhandle) log.error(" %s", e)
def set_group(leader): try: log("win32 hooks: set_group(%#x)", leader.handle) ps = propsys.SHGetPropertyStoreForWindow(handle) key = propsys.PSGetPropertyKeyFromName( "System.AppUserModel.ID") value = propsys.PROPVARIANTType(leader.handle) log("win32 hooks: calling %s(%s, %s)", ps.SetValue, key, value) ps.SetValue(key, value) except Exception as e: log.error("failed to set group leader: %s", e)
def win32_propsys_set_group_leader(self, leader): """ implements set group leader using propsys """ hwnd = get_window_handle(self) if not hwnd: return try: lhandle = leader.handle except: return if not lhandle: return #returns the setter method we can use try: log("win32 hooks: set_group(%#x)", lhandle) propsys = get_propsys() ps = propsys.SHGetPropertyStoreForWindow(hwnd) key = propsys.PSGetPropertyKeyFromName("System.AppUserModel.ID") value = propsys.PROPVARIANTType(lhandle) log("win32 hooks: calling %s(%s, %s)", ps.SetValue, key, value) ps.SetValue(key, value) except Exception as e: log.error("failed to set group leader: %s", e)