Here's an
example from Sean that I used to use all the time for executing actions from the context menu indirectly (main menu only):
Code:
sPath:= "C:\" ; Folder Path
sVerb:= "&Open" ; specify exact one shown in the main-menu.
COM_Init()
psh := COM_CreateObject("Shell.Application")
psf := COM_Invoke(psh, "NameSpace", sPath)
psi := COM_Invoke(psf, "Self") ; COM_Invoke(psf, "ParseName", sFile)
COM_Invoke(psi, "InvokeVerb", sVerb)
COM_Release(psi)
COM_Release(psf)
COM_Release(psh)
COM_Term()
I used more generally as a useful function:
Code:
ShellMainMenu(sPath,sVerb,sFile="")
{
COM_Init()
psh := COM_CreateObject("Shell.Application")
psf := COM_Invoke(psh, "NameSpace", sPath)
psi := sFile ? COM_Invoke(psf, "ParseName", sFile) : COM_Invoke(psf, "Self")
COM_Invoke(psi, "InvokeVerb", sVerb)
COM_Release(psi)
COM_Release(psf)
COM_Release(psh)
COM_Term()
}
Now that I've switched to AutoHotkey_L Unicode, it doesn't work anymore. I get the following error message:
Quote:
Function Name: "NameSpace"
ERROR: The COM Object may not be a valid Dispatch Object!
First ensure that COM Library has been initialized through COM_Init().
()
How could I change that code to make it AHK_L Unicode compatible?
Has anyone written a similar script that covers submenu items too? (I was away from the AHK forums for a while so I've missed the latest developments that came with AHK_L).
Thanks in advance.