 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Krogdor
Joined: 18 Apr 2008 Posts: 1390 Location: The Interwebs
|
Posted: Thu Jan 22, 2009 12:45 am Post subject: |
|
|
Just out of curiosity, what are the following two values for?
| Code: | nPort := 465 ; 25
bTLS := True ; False |
I guess nPort is... which port it tries to send through, or something like that? But I have no clue what bTLS might be.
Edit: Nvm, I saw the "smtpusessl" in the function call, so I'm going to guess it toggles whether or not to use SSL... Which, IIRC, is some sort of encryption? |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Thu Jan 22, 2009 4:05 am Post subject: |
|
|
| Krogdor wrote: | | Edit: Nvm, I saw the "smtpusessl" in the function call, so I'm going to guess it toggles whether or not to use SSL... Which, IIRC, is some sort of encryption? |
Read here: TLS/SSL. |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Thu Jan 22, 2009 4:09 am Post subject: |
|
|
| Yetti wrote: | It does not work for me Sean
I tested in XP SP3. |
OK, I didn't read your code when I replied. Are you sure your smtp server uses the port 2525? Otherwise, try
| Code: | nPort := 25
bTLS := False |
or
| Code: | nPort := 465
bTLS := True |
|
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Thu Jan 22, 2009 12:44 pm Post subject: |
|
|
If got bored and .NET installed in the system, it may be interesting to compare System.Web.Mail & System.Net.Mail. I think System.Web.Mail is essentially RCW over the CDO(SYS) COM object we're using in this script. Now time about CCW over .NET System.Net.Mail.
As a matter of fact, I had already done exactly the same job using System.Net.Mail. One interesting difference: System.Net.Mail worked only with port 587 but not with 465 for Gmail, contrary to System.Web.Mail/CDO(SYS). So there is an inherent difference in their implementations. BTW, although I used only COM.ahk, it might be easier to use CLR.ahk for this. |
|
| Back to top |
|
 |
Yetti
Joined: 18 Dec 2008 Posts: 6
|
Posted: Thu Jan 22, 2009 6:21 pm Post subject: |
|
|
| Thanks, but are visible for me are not installed CDO, I will try on other operating system. |
|
| Back to top |
|
 |
ribbs2521
Joined: 28 Sep 2007 Posts: 273 Location: New York
|
Posted: Thu Jan 29, 2009 9:17 pm Post subject: |
|
|
OK, I'm having an issue with this as well. It's probably my stupidity but that's how I learn. Here is what I did, I'm using this for Lotus Notes.
One thing I am unsure of is the username, technically we don't have usernames because the shortcut on the desktop refers directly to our .id file. I'm assuming it's gberl because when I access Lotus Notes from home on the internet my username is gberl. Is there anything anyone can see here that is in the wrong format or anything?
| Code: | StringReplace, Attachment, A_AhkPath, AutoHotkey.exe, License.txt
sFrom := "Geoff_Berl@MKSINST.com"
sTo := "Geoff_Berl@MKSINST.com"
sSubject := "testing email program"
sText := "see subject..."
sAttach := ;Attachment
sServer := "ROC-MKS-ROCHESTER.mksinternal.com" ; specify your SMTP server
nPort := 25 ; 465
bTLS := True ; False
sUsername := "gberl"
sPassword := "password"
COM_Init()
pmsg := COM_CreateObject("CDO.Message")
pcfg := COM_Invoke(pmsg, "Configuration")
pfld := COM_Invoke(pcfg, "Fields")
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/sendusing", 2)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout", 60)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpserver", sServer)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpserverport", nPort)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpusessl", bTLS)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/sendusername", sUsername)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/sendpassword", sPassword)
COM_Invoke(pfld, "Update")
COM_Invoke(pmsg, "From", sFrom)
COM_Invoke(pmsg, "To", sTo)
COM_Invoke(pmsg, "Subject", sSubject)
COM_Invoke(pmsg, "TextBody", sText)
COM_Invoke(pmsg, "AddAttachment", sAttach)
COM_Invoke(pmsg, "Send")
COM_Release(pfld)
COM_Release(pcfg)
COM_Release(pmsg)
COM_Term() |
|
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Fri Jan 30, 2009 12:10 am Post subject: |
|
|
| ribbs2521 wrote: | | One thing I am unsure of is the username |
Maybe you don't need the authentication.
http://msdn.microsoft.com/en-us/library/ms526318.aspx
I updated the top post. You may need to change the following fields in addtion to your smtp server.
| Code: | nPort := 25
bTLS := False
nAuth := 0
|
|
|
| Back to top |
|
 |
ribbs2521
Joined: 28 Sep 2007 Posts: 273 Location: New York
|
Posted: Fri Jan 30, 2009 12:35 am Post subject: |
|
|
Well, I tried it with gmail since there are examples of that I figure it would be easier. I followed the instructions on google's website to setup and outgoing smtp and still I get the CDO.message.1 or something, it says it couldn't connect. Also, it says
Error 2: Parameter is incorrect (0x80070057).
I'm not proficient in COM so I'm not sure how to find out which parameter they are referring to with that address. I don't want you wasting all of your time helping me so if you don't want to continue helping I'm fine with that. Which brings me to my next question, are there any decent sites for learning COM, I haven't found any.
Here is my gmail version:
| Code: | ;StringReplace, Attachment, A_AhkPath, AutoHotkey.exe, License.txt
#include, C:\Program Files\AutoHotkey\Lib\COM.ahk
sFrom := "ribbs2521@gmail.com"
sTo := "Geoff_Berl@MKSINST.com"
sSubject := "GNU Public License"
sText := "Please Read The Attachment"
sAttach := ; Attachment delimiter is | (use path)
sServer := "smtp.gmail.com" ; specify your SMTP server
nPort := 465 ; 25
bTLS := True ; False
nSend := 2 ; cdoSendUsingPort
nAuth := 1 ; cdoBasic
sUsername := "ribbs2521@gmail.com"
sPassword := "password"
COM_Init()
pmsg := COM_CreateObject("CDO.Message")
pcfg := COM_Invoke(pmsg, "Configuration")
pfld := COM_Invoke(pcfg, "Fields")
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/sendusing", nSend)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout", 60)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpserver", sServer)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpserverport", nPort)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpusessl", bTLS)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", nAuth)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/sendusername", sUsername)
COM_Invoke(pfld, "Item", "http://schemas.microsoft.com/cdo/configuration/sendpassword", sPassword)
COM_Invoke(pfld, "Update")
COM_Invoke(pmsg, "From", sFrom)
COM_Invoke(pmsg, "To", sTo)
COM_Invoke(pmsg, "Subject", sSubject)
COM_Invoke(pmsg, "TextBody", sBody)
Loop, Parse, sAttach, |, %A_Space%%A_Tab%
COM_Invoke(pmsg, "AddAttachment", A_LoopField)
COM_Invoke(pmsg, "Send")
COM_Release(pfld)
COM_Release(pcfg)
COM_Release(pmsg)
COM_Term()
|
|
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Fri Jan 30, 2009 12:54 am Post subject: |
|
|
| ribbs2521 wrote: | | Error 2: Parameter is incorrect (0x80070057). | You have to post the whole error message, although I can guess easily where it came from in this case. I changed the variable sText to sBody as there exists also a function HTMLBody in addition to TextBody. Otherwise, I recommend to update to the latest COM.ahk.
| Code: | sBody := "Please Read The Attachment"
sAttach := "" ; Attachment delimiter is | (use path)
|
| Quote: | | I'm not proficient in COM so I'm not sure how to find out which parameter they are referring to with that address. I don't want you wasting all of your time helping me so if you don't want to continue helping I'm fine with that. Which brings me to my next question, are there any decent sites for learning COM, I haven't found any. | I suppose there are many places, however, I think I only/mainly used MSDN. |
|
| Back to top |
|
 |
ribbs2521
Joined: 28 Sep 2007 Posts: 273 Location: New York
|
Posted: Fri Jan 30, 2009 2:22 am Post subject: |
|
|
OK, so I changed those variables you mentioned, I updated COM but the error still appears. Here is the full error:
COM Error Notification :
Function Name: “Send”
ERROR: (0x80040213)
PROG: CDO.Message.1
DESC: The transport failed to connect to the server.
HELP: ,0
ERROR2: The parameter is incorrect. (0x80070057)
Will Continue? |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Fri Jan 30, 2009 3:43 am Post subject: |
|
|
| ribbs2521 wrote: | | I updated COM but the error still appears. | No, it can't be. With the latest COM.ahk (date: 2009/01/27) there shouldn't be a second error message ERROR2 with the function Send. Anyway, that seems not important here. Which OS are you using? Judging from your CDO error report doesn't contain any garbage in it, I reckon it's an improvement in Vista, right? If yes, the internals may have been also changed in Vista. I suggest to try to change nPort, then. And don't forget to replace with your real password.
|
|
| Back to top |
|
 |
ribbs2521
Joined: 28 Sep 2007 Posts: 273 Location: New York
|
Posted: Fri Jan 30, 2009 5:26 am Post subject: |
|
|
I am running XP SP3.
Here is the COM I downloaded from your link about an hour or two ago.
| Code: | ;------------------------------------------------------------------------------
; COM.ahk Standard Library
; by Sean
; http://www.autohotkey.com/forum/topic22923.html
;------------------------------------------------------------------------------
COM_Init()
{
Return DllCall("ole32\OleInitialize", "Uint", 0)
}
COM_Term()
{
Return DllCall("ole32\OleUninitialize")
}
COM_VTable(ppv, idx)
{
Return NumGet(NumGet(1*ppv)+4*idx)
}
COM_QueryInterface(ppv, IID = "")
{
If DllCall(NumGet(NumGet(1*ppv)+0), "Uint", ppv, "Uint", COM_GUID4String(IID,IID ? IID : IID=0 ? "{00000000-0000-0000-C000-000000000046}" : "{00020400-0000-0000-C000-000000000046}"), "UintP", ppv)=0
Return ppv
}
COM_AddRef(ppv)
{
Return DllCall(NumGet(NumGet(1*ppv)+4), "Uint", ppv)
}
COM_Release(ppv)
{
Return DllCall(NumGet(NumGet(1*ppv)+8), "Uint", ppv)
}
COM_QueryService(ppv, SID, IID = "")
{
DllCall(NumGet(NumGet(1*ppv)+4*0), "Uint", ppv, "Uint", COM_GUID4String(IID_IServiceProvider,"{6D5140C1-7436-11CE-8034-00AA006009FA}"), "UintP", psp)
DllCall(NumGet(NumGet(1*psp)+4*3), "Uint", psp, "Uint", COM_GUID4String(SID,SID), "Uint", IID ? COM_GUID4String(IID,IID) : &SID, "UintP", ppv:=0)
DllCall(NumGet(NumGet(1*psp)+4*2), "Uint", psp)
Return ppv
}
COM_FindConnectionPoint(pdp, DIID)
{
DllCall(NumGet(NumGet(1*pdp)+ 0), "Uint", pdp, "Uint", COM_GUID4String(IID_IConnectionPointContainer, "{B196B284-BAB4-101A-B69C-00AA00341D07}"), "UintP", pcc)
DllCall(NumGet(NumGet(1*pcc)+16), "Uint", pcc, "Uint", COM_GUID4String(DIID,DIID), "UintP", pcp)
DllCall(NumGet(NumGet(1*pcc)+ 8), "Uint", pcc)
Return pcp
}
COM_GetConnectionInterface(pcp)
{
VarSetCapacity(DIID, 16, 0)
DllCall(NumGet(NumGet(1*pcp)+12), "Uint", pcp, "Uint", &DIID)
Return COM_String4GUID(&DIID)
}
COM_Advise(pcp, psink)
{
DllCall(NumGet(NumGet(1*pcp)+20), "Uint", pcp, "Uint", psink, "UintP", nCookie)
Return nCookie
}
COM_Unadvise(pcp, nCookie)
{
Return DllCall(NumGet(NumGet(1*pcp)+24), "Uint", pcp, "Uint", nCookie)
}
COM_Enumerate(penum, ByRef Result, ByRef vt = "")
{
VarSetCapacity(varResult,16,0)
If (0 = hr:=DllCall(NumGet(NumGet(1*penum)+12), "Uint", penum, "Uint", 1, "Uint", &varResult, "UintP", 0))
Result:=(vt:=NumGet(varResult,0,"Ushort"))=8||vt<0x1000&&DllCall("oleaut32\VariantChangeTypeEx","Uint",&varResult,"Uint",&varResult,"Uint",LCID,"Ushort",1,"Ushort",8)=0 ? COM_Ansi4Unicode(bstr:=NumGet(varResult,8)) . COM_SysFreeString(bstr) : NumGet(varResult,8)
Return hr
}
COM_Invoke(pdisp, sName, arg0="vT_NoNe",arg1="vT_NoNe",arg2="vT_NoNe",arg3="vT_NoNe",arg4="vT_NoNe",arg5="vT_NoNe",arg6="vT_NoNe",arg7="vT_NoNe",arg8="vT_NoNe",arg9="vT_NoNe")
{
sParams := "0123456789"
Loop, Parse, sParams
If (arg%A_LoopField% == "vT_NoNe")
{
sParams := SubStr(sParams,1,A_Index-1)
Break
}
VarSetCapacity(varg,16*nParams:=StrLen(sParams),0), VarSetCapacity(DispParams,16,0)
Loop, Parse, sParams
If arg%A_LoopField% Is Not Integer
NumPut(8,varg,(nParams-A_Index)*16,"Ushort"), NumPut(COM_SysAllocString(arg%A_LoopField%),varg,(nParams-A_Index)*16+8)
Else NumPut(SubStr(arg%A_LoopField%,1,1)="+" ? 9 : 3,varg,(nParams-A_Index)*16,"Ushort"), NumPut(arg%A_LoopField%,varg,(nParams-A_Index)*16+8)
If SubStr(sName,0)="="
sName:= SubStr(sName,1,-1)
VarSetCapacity(varResult,32,0), VarSetCapacity(ExcepInfo,32,0)
, (0==hr:=DllCall(NumGet(NumGet(1*pdisp)+20),"Uint",pdisp,"Uint",&varResult+16,"UintP",COM_Unicode4Ansi(wName,sName),"Uint",1,"Uint",LCID,"intP",dispID,"Uint"))&&(!nParams||0!=lr:=DllCall(NumGet(NumGet(1*pdisp)+24),"Uint",pdisp,"int",dispID,"Uint",&varResult+16,"Uint",LCID,"Ushort",12,"Uint",NumPut(1,NumPut(nParams,NumPut(NumPut(-3,varResult,4)-4,NumPut(&varg,DispParams))))-16,"Uint",&varResult,"Uint",0,"Uint",0,"Uint"))&&(0==hr:=DllCall(NumGet(NumGet(1*pdisp)+24),"Uint",pdisp,"int",dispID,"Uint",&varResult+16,"Uint",LCID,"Ushort",3,"Uint",nParams ? NumPut(0,NumPut(0,DispParams,4),4)-16:&DispParams,"Uint",&varResult,"Uint",&ExcepInfo,"Uint",0,"Uint"))
Loop, % nParams
NumGet(varg,(A_Index-1)*16,"Ushort")=8 ? COM_SysFreeString(NumGet(varg,(A_Index-1)*16+8)) : ""
Global COM_VT := NumGet(varResult,0,"Ushort")
Return hr=0 ? COM_VT>1 ? COM_VT=8||COM_VT<0x1000&&DllCall("oleaut32\VariantChangeTypeEx","Uint",&varResult,"Uint",&varResult,"Uint",LCID,"Ushort",1,"Ushort",8)=0 ? COM_Ansi4Unicode(bstr:=NumGet(varResult,8)) . COM_SysFreeString(bstr) : NumGet(varResult,8) : "" : COM_Error(hr,lr,&ExcepInfo,sName)
}
COM_Invoke_(pdisp, sName, type0="",arg0="",type1="",arg1="",type2="",arg2="",type3="",arg3="",type4="",arg4="",type5="",arg5="",type6="",arg6="",type7="",arg7="",type8="",arg8="",type9="",arg9="")
{
sParams := "0123456789"
Loop, Parse, sParams
If (type%A_LoopField% = "")
{
sParams := SubStr(sParams,1,A_Index-1)
Break
}
VarSetCapacity(varg,16*nParams:=StrLen(sParams),0), VarSetCapacity(DispParams,16,0)
Loop, Parse, sParams
NumPut(type%A_LoopField%,varg,(nParams-A_Index)*16,"Ushort"), type%A_LoopField%&0x4000=0 ? NumPut(type%A_LoopField%=8 ? COM_SysAllocString(arg%A_LoopField%) : arg%A_LoopField%,varg,(nParams-A_Index)*16+8,type%A_LoopField%=5||type%A_LoopField%=7 ? "double" : type%A_LoopField%=4 ? "float" : "int64") : type%A_LoopField%=0x400C||type%A_LoopField%=0x400E ? NumPut(arg%A_LoopField%,varg,(nParams-A_Index)*16+8) : VarSetCapacity(_ref_%A_LoopField%,8,0) . NumPut(&_ref_%A_LoopField%,varg,(nParams-A_Index)*16+8) . NumPut(type%A_LoopField%=0x4008 ? COM_SysAllocString(arg%A_LoopField%) : arg%A_LoopField%,_ref_%A_LoopField%,0,type%A_LoopField%=0x4005||type%A_LoopField%=0x4007 ? "double" : type%A_LoopField%=0x4004 ? "float" : "int64")
If SubStr(sName,0)="="
sName:= SubStr(sName,1,-1)
VarSetCapacity(varResult,32,0), VarSetCapacity(ExcepInfo,32,0)
, (0==hr:=DllCall(NumGet(NumGet(1*pdisp)+20),"Uint",pdisp,"Uint",&varResult+16,"UintP",COM_Unicode4Ansi(wName,sName),"Uint",1,"Uint",LCID,"intP",dispID,"Uint"))&&(!nParams||0!=lr:=DllCall(NumGet(NumGet(1*pdisp)+24),"Uint",pdisp,"int",dispID,"Uint",&varResult+16,"Uint",LCID,"Ushort",12,"Uint",NumPut(1,NumPut(nParams,NumPut(NumPut(-3,varResult,4)-4,NumPut(&varg,DispParams))))-16,"Uint",&varResult,"Uint",0,"Uint",0,"Uint"))&&(0==hr:=DllCall(NumGet(NumGet(1*pdisp)+24),"Uint",pdisp,"int",dispID,"Uint",&varResult+16,"Uint",LCID,"Ushort",3,"Uint",nParams ? NumPut(0,NumPut(0,DispParams,4),4)-16:&DispParams,"Uint",&varResult,"Uint",&ExcepInfo,"Uint",0,"Uint"))
Loop, Parse, sParams
type%A_LoopField%&0x4000=0 ? (type%A_LoopField%=8 ? COM_SysFreeString(NumGet(varg,(nParams-A_Index)*16+8)) : "") : type%A_LoopField%=0x400C||type%A_LoopField%=0x400E ? "" : type%A_LoopField%=0x4008 ? (COM_BYREF_%A_LoopField%:=COM_Ansi4Unicode(NumGet(_ref_%A_LoopField%))) . COM_SysFreeString(NumGet(_ref_%A_LoopField%)) : (COM_BYREF_%A_LoopField%:=NumGet(_ref_%A_LoopField%,0,type%A_LoopField%=0x4005||type%A_LoopField%=0x4007 ? "double" : type%A_LoopField%=0x4004 ? "float" : "int64"))
Global COM_VT := NumGet(varResult,0,"Ushort")
Return hr=0 ? COM_VT>1 ? COM_VT=8||COM_VT<0x1000&&DllCall("oleaut32\VariantChangeTypeEx","Uint",&varResult,"Uint",&varResult,"Uint",LCID,"Ushort",1,"Ushort",8)=0 ? COM_Ansi4Unicode(bstr:=NumGet(varResult,8)) . COM_SysFreeString(bstr) : NumGet(varResult,8) : "" : COM_Error(hr,lr,&ExcepInfo,sName)
}
COM_DispInterface(this, prm1="", prm2="", prm3="", prm4="", prm5="", prm6="", prm7="", prm8="")
{
Critical
If A_EventInfo = 6
DllCall(NumGet(NumGet(NumGet(this+8))+28),"Uint",NumGet(this+8),"Uint",prm1,"UintP",pname,"Uint",1,"UintP",0), VarSetCapacity(sfn,63), DllCall("user32\wsprintfA","str",sfn,"str","%s%S","Uint",this+40,"Uint",pname,"Cdecl"), COM_SysFreeString(pname), (pfn:=RegisterCallback(sfn,"C F")) ? (hResult:=DllCall(pfn,"Uint",prm5,"Uint",this,"Uint",prm6,"Cdecl")) . DllCall("kernel32\GlobalFree","Uint",pfn) : (hResult:=0x80020003)
Else If A_EventInfo = 5
hResult:=DllCall(NumGet(NumGet(NumGet(this+8))+40),"Uint",NumGet(this+8),"Uint",prm2,"Uint",prm3,"Uint",prm5)
Else If A_EventInfo = 4
NumPut(0,prm3+0), hResult:=0x80004001
Else If A_EventInfo = 3
NumPut(0,prm1+0), hResult:=0
Else If A_EventInfo = 2
NumPut(hResult:=NumGet(this+4)-1,this+4)
Else If A_EventInfo = 1
NumPut(hResult:=NumGet(this+4)+1,this+4)
Else If A_EventInfo = 0
COM_IsEqualGUID(this+24,prm1)||InStr("{00020400-0000-0000-C000-000000000046}{00000000-0000-0000-C000-000000000046}",COM_String4GUID(prm1)) ? NumPut(this,prm2+0) . NumPut(NumGet(this+4)+1,this+4) . (hResult:=0) : NumPut(0,prm2+0) . (hResult:=0x80004002)
Return hResult
}
COM_DispGetParam(pDispParams, Position = 0, vt = 8)
{
VarSetCapacity(varResult,16,0)
DllCall("oleaut32\DispGetParam", "Uint", pDispParams, "Uint", Position, "Ushort", vt, "Uint", &varResult, "UintP", nArgErr)
Return NumGet(varResult,0,"Ushort")=8 ? COM_Ansi4Unicode(NumGet(varResult,8)) . COM_SysFreeString(NumGet(varResult,8)) : NumGet(varResult,8)
}
COM_DispSetParam(val, pDispParams, Position = 0, vt = 8)
{
Return NumPut(vt=8 ? COM_SysAllocString(val) : val,NumGet(NumGet(pDispParams+0)+(NumGet(pDispParams+8)-Position)*16-8),0,vt=11||vt=2 ? "short" : "int")
}
COM_Error(hr = "", lr = "", pExcepInfo = "", sName = "")
{
Static bDebug:=1
If Not (sName="" ? 0*bDebug:=hr : bDebug)
Return
hr ? (VarSetCapacity(sError,1023),VarSetCapacity(nError,10),DllCall("kernel32\FormatMessageA","Uint",0x1000,"Uint",0,"Uint",hr<>0x80020009 ? hr : (bExcep:=1)*(hr:=NumGet(pExcepInfo+28)) ? hr : hr:=NumGet(pExcepInfo+0,0,"Ushort")+0x80040200,"Uint",0,"str",sError,"Uint",1024,"Uint",0),DllCall("user32\wsprintfA","str",nError,"str","0x%08X","Uint",hr,"Cdecl")) : sError:="The COM Object may not be a valid Dispatch Object!`n`tFirst ensure that COM Library has been initialized through COM_Init().`n", lr ? (VarSetCapacity(sError2,1023),VarSetCapacity(nError2,10),DllCall("kernel32\FormatMessageA","Uint",0x1000,"Uint",0,"Uint",lr,"Uint",0,"str",sError2,"Uint",1024,"Uint",0),DllCall("user32\wsprintfA","str",nError2,"str","0x%08X","Uint",lr,"Cdecl")) : ""
MsgBox, 260, COM Error Notification, % "Function Name:`t""" . sName . """`nERROR:`t" . sError . "`t(" . nError . ")" . (bExcep ? SubStr(NumGet(pExcepInfo+24) ? DllCall(NumGet(pExcepInfo+24),"Uint",pExcepInfo) : "",1,0) . "`nPROG:`t" . COM_Ansi4Unicode(NumGet(pExcepInfo+4)) . COM_SysFreeString(NumGet(pExcepInfo+4)) . "`nDESC:`t" . COM_Ansi4Unicode(NumGet(pExcepInfo+8)) . COM_SysFreeString(NumGet(pExcepInfo+8)) . "`nHELP:`t" . COM_Ansi4Unicode(NumGet(pExcepInfo+12)) . COM_SysFreeString(NumGet(pExcepInfo+12)) . "," . NumGet(pExcepInfo+16) : "") . (lr ? "`n`nERROR2:`t" . sError2 . "`t(" . nError2 . ")" : "") . "`n`nWill Continue?"
IfMsgBox, No, Exit
}
COM_CreateIDispatch()
{
Static IDispatch
If Not VarSetCapacity(IDispatch)
{
VarSetCapacity(IDispatch,28,0), nParams=3112469
Loop, Parse, nParams
NumPut(RegisterCallback("COM_DispInterface","",A_LoopField,A_Index-1),IDispatch,4*(A_Index-1))
}
Return &IDispatch
}
COM_GetDefaultInterface(pdisp, LCID = 0)
{
DllCall(NumGet(NumGet(1*pdisp) +12), "Uint", pdisp , "UintP", ctinf)
If ctinf
{
DllCall(NumGet(NumGet(1*pdisp)+16), "Uint", pdisp, "Uint" , 0, "Uint", LCID, "UintP", ptinf)
DllCall(NumGet(NumGet(1*ptinf)+12), "Uint", ptinf, "UintP", pattr)
DllCall(NumGet(NumGet(1*pdisp)+ 0), "Uint", pdisp, "Uint" , pattr, "UintP", ppv)
DllCall(NumGet(NumGet(1*ptinf)+76), "Uint", ptinf, "Uint" , pattr)
DllCall(NumGet(NumGet(1*ptinf)+ 8), "Uint", ptinf)
If ppv
DllCall(NumGet(NumGet(1*pdisp)+ 8), "Uint", pdisp), pdisp := ppv
}
Return pdisp
}
COM_GetDefaultEvents(pdisp, LCID = 0)
{
DllCall(NumGet(NumGet(1*pdisp)+16), "Uint", pdisp, "Uint" , 0, "Uint", LCID, "UintP", ptinf)
DllCall(NumGet(NumGet(1*ptinf)+12), "Uint", ptinf, "UintP", pattr)
VarSetCapacity(IID,16), DllCall("RtlMoveMemory", "Uint", &IID, "Uint", pattr, "Uint", 16)
DllCall(NumGet(NumGet(1*ptinf)+76), "Uint", ptinf, "Uint" , pattr)
DllCall(NumGet(NumGet(1*ptinf)+72), "Uint", ptinf, "UintP", ptlib, "UintP", idx)
DllCall(NumGet(NumGet(1*ptinf)+ 8), "Uint", ptinf)
Loop, % DllCall(NumGet(NumGet(1*ptlib)+12), "Uint", ptlib)
{
DllCall(NumGet(NumGet(1*ptlib)+20), "Uint", ptlib, "Uint", A_Index-1, "UintP", TKind)
If TKind <> 5
Continue
DllCall(NumGet(NumGet(1*ptlib)+16), "Uint", ptlib, "Uint", A_Index-1, "UintP", ptinf)
DllCall(NumGet(NumGet(1*ptinf)+12), "Uint", ptinf, "UintP", pattr)
nCount:=NumGet(pattr+48,0,"Ushort")
DllCall(NumGet(NumGet(1*ptinf)+76), "Uint", ptinf, "Uint" , pattr)
Loop, % nCount
{
DllCall(NumGet(NumGet(1*ptinf)+36), "Uint", ptinf, "Uint", A_Index-1, "UintP", nFlags)
If !(nFlags & 1)
Continue
DllCall(NumGet(NumGet(1*ptinf)+32), "Uint", ptinf, "Uint", A_Index-1, "UintP", hRefType)
DllCall(NumGet(NumGet(1*ptinf)+56), "Uint", ptinf, "Uint", hRefType , "UintP", prinf)
DllCall(NumGet(NumGet(1*prinf)+12), "Uint", prinf, "UintP", pattr)
nFlags & 2 ? DIID:=COM_String4GUID(pattr) : bFind:=COM_IsEqualGUID(pattr,&IID)
DllCall(NumGet(NumGet(1*prinf)+76), "Uint", prinf, "Uint" , pattr)
DllCall(NumGet(NumGet(1*prinf)+ 8), "Uint", prinf)
}
DllCall(NumGet(NumGet(1*ptinf)+ 8), "Uint", ptinf)
If bFind
Break
}
DllCall(NumGet(NumGet(1*ptlib)+ 8), "Uint", ptlib)
Return bFind ? DIID : "{00000000-0000-0000-0000-000000000000}"
}
COM_GetGuidOfName(pdisp, Name, LCID = 0)
{
DllCall(NumGet(NumGet(1*pdisp)+16), "Uint", pdisp, "Uint", 0, "Uint", LCID, "UintP", ptinf)
DllCall(NumGet(NumGet(1*ptinf)+72), "Uint", ptinf, "UintP", ptlib, "UintP", idx)
DllCall(NumGet(NumGet(1*ptinf)+ 8), "Uint", ptinf), ptinf:=0
DllCall(NumGet(NumGet(1*ptlib)+44), "Uint", ptlib, "Uint", COM_Unicode4Ansi(Name,Name), "Uint", 0, "UintP", ptinf, "UintP", memID, "UshortP", 1)
DllCall(NumGet(NumGet(1*ptlib)+ 8), "Uint", ptlib)
DllCall(NumGet(NumGet(1*ptinf)+12), "Uint", ptinf, "UintP", pattr)
GUID := COM_String4GUID(pattr)
DllCall(NumGet(NumGet(1*ptinf)+76), "Uint", ptinf, "Uint" , pattr)
DllCall(NumGet(NumGet(1*ptinf)+ 8), "Uint", ptinf)
Return GUID
}
COM_GetTypeInfoOfGuid(pdisp, GUID, LCID = 0)
{
DllCall(NumGet(NumGet(1*pdisp)+16), "Uint", pdisp, "Uint", 0, "Uint", LCID, "UintP", ptinf)
DllCall(NumGet(NumGet(1*ptinf)+72), "Uint", ptinf, "UintP", ptlib, "UintP", idx)
DllCall(NumGet(NumGet(1*ptinf)+ 8), "Uint", ptinf), ptinf := 0
DllCall(NumGet(NumGet(1*ptlib)+24), "Uint", ptlib, "Uint", COM_GUID4String(GUID,GUID), "UintP", ptinf)
DllCall(NumGet(NumGet(1*ptlib)+ 8), "Uint", ptlib)
Return ptinf
}
; A Function Name including Prefix is limited to 63 bytes!
COM_ConnectObject(psource, prefix = "", DIID = "")
{
If Not DIID
0+(pconn:=COM_FindConnectionPoint(psource,"{00020400-0000-0000-C000-000000000046}")) ? (DIID:=COM_GetConnectionInterface(pconn))="{00020400-0000-0000-C000-000000000046}" ? DIID:=COM_GetDefaultEvents(psource) : "" : pconn:=COM_FindConnectionPoint(psource,DIID:=COM_GetDefaultEvents(psource))
Else pconn:=COM_FindConnectionPoint(psource,SubStr(DIID,1,1)="{" ? DIID : DIID:=COM_GetGuidOfName(psource,DIID))
If !pconn || !ptinf:=COM_GetTypeInfoOfGuid(psource,DIID)
{
MsgBox, No Event Interface Exists!
Return
}
psink:=COM_CoTaskMemAlloc(40+StrLen(prefix)+1), NumPut(1,NumPut(COM_CreateIDispatch(),psink+0)), NumPut(psource,NumPut(ptinf,psink+8))
DllCall("RtlMoveMemory", "Uint", psink+24, "Uint", COM_GUID4String(DIID,DIID), "Uint", 16)
DllCall("RtlMoveMemory", "Uint", psink+40, "Uint", &prefix, "Uint", StrLen(prefix)+1)
NumPut(COM_Advise(pconn,psink),NumPut(pconn,psink+16))
Return psink
}
COM_DisconnectObject(psink)
{
Return COM_Unadvise(NumGet(psink+16),NumGet(psink+20))=0 ? (0,COM_Release(NumGet(psink+16)),COM_Release(NumGet(psink+8)),COM_CoTaskMemFree(psink)) : 1
}
COM_CreateObject(CLSID, IID = "", CLSCTX = 5)
{
DllCall("ole32\CoCreateInstance", "Uint", SubStr(CLSID,1,1)="{" ? COM_GUID4String(CLSID,CLSID) : COM_CLSID4ProgID(CLSID,CLSID), "Uint", 0, "Uint", CLSCTX, "Uint", COM_GUID4String(IID,IID ? IID : IID=0 ? "{00000000-0000-0000-C000-000000000046}" : "{00020400-0000-0000-C000-000000000046}"), "UintP", ppv)
Return ppv
}
COM_ActiveXObject(ProgID)
{
DllCall("ole32\CoCreateInstance", "Uint", SubStr(ProgID,1,1)="{" ? COM_GUID4String(ProgID,ProgID) : COM_CLSID4ProgID(ProgID,ProgID), "Uint", 0, "Uint", 5, "Uint", COM_GUID4String(IID_IDispatch,"{00020400-0000-0000-C000-000000000046}"), "UintP", pdisp)
Return COM_GetDefaultInterface(pdisp)
}
COM_GetObject(Moniker)
{
DllCall("ole32\CoGetObject", "Uint", COM_Unicode4Ansi(Moniker,Moniker), "Uint", 0, "Uint", COM_GUID4String(IID_IDispatch,"{00020400-0000-0000-C000-000000000046}"), "UintP", pdisp)
Return COM_GetDefaultInterface(pdisp)
}
COM_GetActiveObject(ProgID)
{
DllCall("oleaut32\GetActiveObject", "Uint", SubStr(ProgID,1,1)="{" ? COM_GUID4String(ProgID,ProgID) : COM_CLSID4ProgID(ProgID,ProgID), "Uint", 0, "UintP", punk)
DllCall(NumGet(NumGet(1*punk)+0), "Uint", punk, "Uint", COM_GUID4String(IID_IDispatch,"{00020400-0000-0000-C000-000000000046}"), "UintP", pdisp)
DllCall(NumGet(NumGet(1*punk)+8), "Uint", punk)
Return COM_GetDefaultInterface(pdisp)
}
COM_CLSID4ProgID(ByRef CLSID, ProgID)
{
VarSetCapacity(CLSID, 16)
DllCall("ole32\CLSIDFromProgID", "Uint", COM_Unicode4Ansi(ProgID,ProgID), "Uint", &CLSID)
Return &CLSID
}
COM_GUID4String(ByRef CLSID, String)
{
VarSetCapacity(CLSID, 16)
DllCall("ole32\CLSIDFromString", "Uint", COM_Unicode4Ansi(String,String,38), "Uint", &CLSID)
Return &CLSID
}
COM_ProgID4CLSID(pCLSID)
{
DllCall("ole32\ProgIDFromCLSID", "Uint", pCLSID, "UintP", pProgID)
Return COM_Ansi4Unicode(pProgID) . COM_CoTaskMemFree(pProgID)
}
COM_String4GUID(pGUID)
{
VarSetCapacity(String, 38 * 2 + 1)
DllCall("ole32\StringFromGUID2", "Uint", pGUID, "Uint", &String, "int", 39)
Return COM_Ansi4Unicode(&String, 38)
}
COM_IsEqualGUID(pGUID1, pGUID2)
{
Return DllCall("ole32\IsEqualGUID", "Uint", pGUID1, "Uint", pGUID2)
}
COM_CoCreateGuid()
{
VarSetCapacity(GUID, 16, 0)
DllCall("ole32\CoCreateGuid", "Uint", &GUID)
Return COM_String4GUID(&GUID)
}
COM_CoTaskMemAlloc(cb)
{
Return DllCall("ole32\CoTaskMemAlloc", "Uint", cb)
}
COM_CoTaskMemFree(pv)
{
DllCall("ole32\CoTaskMemFree", "Uint", pv)
}
COM_CoInitialize()
{
Return DllCall("ole32\CoInitialize", "Uint", 0)
}
COM_CoUninitialize()
{
DllCall("ole32\CoUninitialize")
}
COM_SysAllocString(sString)
{
Return DllCall("oleaut32\SysAllocString", "Uint", COM_Ansi2Unicode(sString,wString))
}
COM_SysFreeString(bstr)
{
DllCall("oleaut32\SysFreeString", "Uint", bstr)
}
COM_SysStringLen(bstr)
{
Return DllCall("oleaut32\SysStringLen", "Uint", bstr)
}
COM_SafeArrayDestroy(psa)
{
Return DllCall("oleaut32\SafeArrayDestroy", "Uint", psa)
}
COM_VariantClear(pvarg)
{
Return DllCall("oleaut32\VariantClear", "Uint", pvarg)
}
COM_AtlAxWinInit(Version = "")
{
COM_Init()
If Not DllCall("GetModuleHandle", "str", "atl" . Version)
DllCall("LoadLibrary" , "str", "atl" . Version)
Return DllCall("atl" . Version . "\AtlAxWinInit")
}
COM_AtlAxWinTerm(Version = "")
{
COM_Term()
If hModule := DllCall("GetModuleHandle", "str", "atl" . Version)
Return DllCall("FreeLibrary" , "Uint", hModule)
}
COM_AtlAxAttachControl(pdsp, hWnd, Version = "")
{
Return DllCall("atl" . Version . "\AtlAxAttachControl", "Uint", punk:=COM_QueryInterface(pdsp,0), "Uint", hWnd, "Uint", 0), COM_Release(punk)
}
COM_AtlAxCreateControl(hWnd, Name, Version = "")
{
If DllCall("atl" . Version . "\AtlAxCreateControl", "Uint", COM_Unicode4Ansi(Name,Name), "Uint", hWnd, "Uint", 0, "Uint", 0)=0
Return COM_AtlAxGetControl(hWnd, Version)
}
COM_AtlAxGetControl(hWnd, Version = "")
{
If DllCall("atl" . Version . "\AtlAxGetControl", "Uint", hWnd, "UintP", punk)=0
pdsp:=COM_QueryInterface(punk), COM_Release(punk)
Return pdsp
}
COM_AtlAxGetHost(hWnd, Version = "")
{
If DllCall("atl" . Version . "\AtlAxGetHost", "Uint", hWnd, "UintP", punk)=0
pdsp:=COM_QueryInterface(punk), COM_Release(punk)
Return pdsp
}
COM_AtlAxCreateContainer(hWnd, l, t, w, h, Name = "", Version = "")
{
Return DllCall("CreateWindowEx", "Uint",0x200, "str", "AtlAxWin" . Version, "Uint", Name ? &Name : 0, "Uint", 0x54000000, "int", l, "int", t, "int", w, "int", h, "Uint", hWnd, "Uint", 0, "Uint", 0, "Uint", 0)
}
COM_AtlAxGetContainer(pdsp, bCtrl = "")
{
DllCall(NumGet(NumGet(1*pdsp)+ 0), "Uint", pdsp, "Uint", COM_GUID4String(IID_IOleWindow,"{00000114-0000-0000-C000-000000000046}"), "UintP", pwin)
DllCall(NumGet(NumGet(1*pwin)+12), "Uint", pwin, "UintP", hCtrl)
DllCall(NumGet(NumGet(1*pwin)+ 8), "Uint", pwin)
Return bCtrl ? hCtrl : DllCall("GetParent", "Uint", hCtrl)
}
COM_Ansi4Unicode(pString, nSize = "")
{
If (nSize = "")
nSize:=DllCall("kernel32\WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "Uint", 0, "int", 0, "Uint", 0, "Uint", 0)
VarSetCapacity(sString, nSize)
DllCall("kernel32\WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "str", sString, "int", nSize + 1, "Uint", 0, "Uint", 0)
Return sString
}
COM_Unicode4Ansi(ByRef wString, sString, nSize = "")
{
If (nSize = "")
nSize:=DllCall("kernel32\MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", 0, "int", 0)
VarSetCapacity(wString, nSize * 2 + 1)
DllCall("kernel32\MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", &wString, "int", nSize + 1)
Return &wString
}
COM_Ansi2Unicode(ByRef sString, ByRef wString, nSize = "")
{
If (nSize = "")
nSize:=DllCall("kernel32\MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", 0, "int", 0)
VarSetCapacity(wString, nSize * 2 + 1)
DllCall("kernel32\MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", &wString, "int", nSize + 1)
Return &wString
}
COM_Unicode2Ansi(ByRef wString, ByRef sString, nSize = "")
{
pString := wString + 0 > 65535 ? wString : &wString
If (nSize = "")
nSize:=DllCall("kernel32\WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "Uint", 0, "int", 0, "Uint", 0, "Uint", 0)
VarSetCapacity(sString, nSize)
DllCall("kernel32\WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "str", sString, "int", nSize + 1, "Uint", 0, "Uint", 0)
Return &sString
}
COM_ScriptControl(sCode, sLang = "", bEval = False, sFunc = "", sName = "", pdisp = 0, bGlobal = False)
{
COM_Init()
psc := COM_CreateObject("MSScriptControl.ScriptControl")
COM_Invoke(psc, "Language", sLang ? sLang : "VBScript")
sName ? COM_Invoke(psc, "AddObject", sName, "+" . pdisp, bGlobal) : ""
sFunc ? COM_Invoke(psc, "AddCode", sCode) : ""
ret := COM_Invoke(psc, bEval ? "Eval" : "ExecuteStatement", sFunc ? sFunc : sCode)
COM_Release(psc)
COM_Term()
Return ret
}
|
I think it's a lost cause lol. |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Fri Jan 30, 2009 6:03 am Post subject: |
|
|
| ribbs2521 wrote: | | I am running XP SP3. | Then I'm sure you forgot to replace with the real password.
| ribbs2521 wrote: | | I think it's a lost cause lol. | Where did you put the latest COM.ahk? |
|
| Back to top |
|
 |
ribbs2521
Joined: 28 Sep 2007 Posts: 273 Location: New York
|
Posted: Fri Jan 30, 2009 7:16 pm Post subject: |
|
|
| Sean wrote: | | Then I'm sure you forgot to replace with the real password. |
That can't be it because I only change the password when it's pasted in the forum. The original has been my password the whole time. I copy it into the forum and then change it to password when it's copied in the forum.
| Sean wrote: | | Where did you put the latest COM.ahk? |
C:\...AutoHotKey\Lib\Com.ahk. I also tried using #include in case it wasn't finding the file. |
|
| Back to top |
|
 |
Wicked
Joined: 07 Jun 2008 Posts: 369
|
Posted: Fri Jan 30, 2009 8:46 pm Post subject: |
|
|
I get same problem, Sean.
I also run XP SP3. I ran through and made sure I had everything correct as well as the newest COM.AHK. Strange.
I just click YES when it asks me to continue and it still sends, but I imagine people would prefer to not ahve to do that. ^^ |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|