AutoHotkey Community

It is currently May 27th, 2012, 5:24 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: February 2nd, 2011, 1:39 pm 
Offline

Joined: February 7th, 2009, 11:28 pm
Posts: 384
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.

_________________
Hardware: 1.8 GHz laptop with 4 GB ram, Windows XP/SP3
Software: Prevx, Privatefirewall, KeyScrambler.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2011, 7:24 pm 
Code:
ShellMainMenu(sPath,sVerb,sFile="") {
   psf := ComObjCreate("Shell.Application").NameSpace(sPath)
   psi := sFile? psf.ParseName(sFile):psf.self
   psi.InvokeVerb(sVerb)
}


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2011, 6:23 am 
Offline

Joined: February 7th, 2009, 11:28 pm
Posts: 384
thank you a4u. the functions works great again.

a4u wrote:
Code:
ShellMainMenu(sPath,sVerb,sFile="") {
   psf := ComObjCreate("Shell.Application").NameSpace(sPath)
   psi := sFile? psf.ParseName(sFile):psf.self
   psi.InvokeVerb(sVerb)
}

_________________
Hardware: 1.8 GHz laptop with 4 GB ram, Windows XP/SP3
Software: Prevx, Privatefirewall, KeyScrambler.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Exabot [Bot], HotkeyStick, rbrtryn, XstatyK and 84 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group