This feature is sometimes used when testing an on-board load on Windows, and the versions of the two languages found online are as follows:
C # version:
Shell shell = new Shell (); Folder folder = Shell. NameSpace (Path.getdirectoryname (AppPath)); FolderItem app = folder. ParseName (Path.getfilename (AppPath)); string sverb = Islock? "Lock to Taskbar (&k)": "Detach from Taskbar (&k)"; foreach (Folderitemverb Fib in app. Verbs ()) { if (fib.name = = Sverb) { fib.doit (); return true; }} return false;
VB version:
Public Shared Function Lockapp (islock as Boolean, AppPath as String) as Booleandim shell as New shell () Dim folder as Folde R = Shell. [NameSpace] (Path.getdirectoryname (AppPath)) Dim app as FolderItem = folder. ParseName (Path.getfilename (AppPath)) Dim sverb as String = If (Islock, "Locked (&k)", "Detached (&k)") for each Fib as Folderite Mverb in App. Verbs () If fib.name = Sverb thenfib.doit () Return trueend Ifnextreturn falseend Function
The next step is to convert the above code into Python, where the Windows interface is used, and the Windows interface is called in Python, and you can use the win32com
The code is as follows:
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 "Detach from taskbar (&k)" or desktopcommon.tounicode (verb. Name) = = u "Unpin from Tas&kbar": verb. DoIt ()
The Python version of the icon operation is OK.
Welcome to the "Sogou test" of the public, a daily test-related articles to share with you to discuss the technology and development of software testing
Reprint Please specify: Http://blog.csdn.net/sogouauto
Python write automation icon lock to taskbar or delete icon