Executes the context menu item of the given path.
InvokeVerb(path, menu, validate=True) { ;by A_Samurai ;v 1.0.1 http://sites.google.com/site/ahkref/custom-functions/invokeverb objShell := ComObjCreate("Shell.Application") if InStr(FileExist(path), "D") || InStr(path, "::{") { objFolder := objShell.NameSpace(path) objFolderItem := objFolder.Self } else { SplitPath, path, name, dir objFolder := objShell.NameSpace(dir) objFolderItem := objFolder.ParseName(name) } if validate { colVerbs := objFolderItem.Verbs loop % colVerbs.Count { verb := colVerbs.Item(A_Index - 1) retMenu := verb.name StringReplace, retMenu, retMenu, & if (retMenu = menu) { verb.DoIt Return True } } Return False } else objFolderItem.InvokeVerbEx(Menu) }Example:
#persistent ;this is the same as right clicking on the folder and selecting Copy. if InvokeVerb(A_MyDocuments "\AutoHotkey", "Copy") msgbox copied else msgbox not copied ;Opens the property window of Recycle Bin InvokeVerb("::{645ff040-5081-101b-9f08-00aa002f954e}", "Properties") path := A_ScriptDir "\Test" FileCreateDir, % path ;this is the same as right clicking on the folder and selecting Delete. InvokeVerb(path, "Delete")It requires AutoHotkey_L Revision 53 or later. The details are found in the link.