Python实现图标锁定到Windows任务栏或删除图标

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

此处使用到了Windows接口,Python中调用windows接口,可以使用win32com

代码如下:

    def DeleteQuickLaunchOnTaskBar(lnkName):  
        objShell = win32com.client.Dispatch("Shell.Application")  
          
        taskbarPath = os.path.join(os.environ["appdata"], r'Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar')  
        lnkName = DesktopCommon.ToUnicode(lnkName)  
        objFolder = objShell.NameSpace(taskbarPath)  
        desktopItems = objFolder.Items()  
          
        for item in desktopItems:  
            if DesktopCommon.ToUnicode(item.Name) == lnkName:  
                verbs = item.Verbs()  
                for verb in verbs:  
                    if DesktopCommon.ToUnicode(verb.Name) == u"从任务栏脱离(&K)" or  DesktopCommon.ToUnicode(verb.Name) == u"Unpin from Tas&kbar":  
                        verb.DoIt()