AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ez_invoke() EZ-COM Wrapper ez_invoke("root.obj.prop[3
Goto page Previous  1, 2, 3, 4, 5, 6  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
COM TTS
Guest





PostPosted: Wed Dec 26, 2007 1:39 am    Post subject: Reply with quote

Code:
"this=object.two" ==> "this", "+" ez_invoke("object.two")


I got it, but how about "this=object"?

Code:
Com_invoke(objVoice, "AudioOutputStream=", spFileStream)


SpFileStream is an object that has been alread created!
Back to top
Lexikos



Joined: 17 Oct 2006
Posts: 2542
Location: Australia, Qld

PostPosted: Wed Dec 26, 2007 2:37 am    Post subject: Reply with quote

For IDispatch.Invoke(), each parameter has an associated type (like DllCall.) COM_Invoke() assumes each parameter is of type VT_BSTR (string). This will not work for object references, which must be VT_DISPATCH (or VT_UNKNOWN), so Sean invented the "+" prefix to mean VT_DISPATCH. The alternative is to explicitly specify the type of each parameter, using COM_Invoke_().
Back to top
View user's profile Send private message
COM TTS
Guest





PostPosted: Wed Dec 26, 2007 3:28 am    Post subject: Reply with quote

Thanks, Lexicos.

Now I understand the usage of Plus sign(not the internal operation )
But is there no way to set object = object?

I think it should be there in Com.ahk, I think.
Not just for me, for others.
'cause there are so many codes(vb or jscript) using, "Set object1.prop= object2"
Isn't it?
Back to top
Joy2DWorld



Joined: 04 Dec 2006
Posts: 422
Location: Galil, Israel

PostPosted: Wed Dec 26, 2007 3:42 am    Post subject: Reply with quote

COM TTS wrote:
But is there no way to set object = object?

"Set object1.prop= object2"



in ez_invoke syntax:

Code:

ez_invoke("object1.prop=", "+" ez_invoke("object2"))


or

Code:

ez_invoke("object.prop=", "+" #_object2)

_________________
Joyce Jamce
Back to top
View user's profile Send private message
COM TTS
Guest





PostPosted: Wed Dec 26, 2007 4:44 am    Post subject: Reply with quote

God, I am sorry I can't understand.
Code:

Could you give me a correction?

com_init()
filedir = %A_mydocuments%\tts_sample.wav

#_objVoice := Com_CreateObject("SAPI.SpVoice")
COM_Invoke(#_objVoice, "Voice=", "+" . COM_Invoke(COM_Invoke(#_objVoice, "GetVoices", "Name=Microsoft Sam"), "Item", 0))

#_spFileStream := Com_createObject("SAPI.SpFileStream")
ez_invoke("spFileStream.Format.Type=", 22)
ez_invoke("spFileStream.open", filedir, 3, False)
ez_invoke("objVoice.AudioOutputStream=", "+" ez_invoke("spFileStream"))  ; <----- still not working
ez_Invoke("objVoice.Speak", "My name is Sam!")


Have you ever actually used set object.prop = object in your code and did it work?
It always fails in my other scripts, too
Back to top
Lexikos



Joined: 17 Oct 2006
Posts: 2542
Location: Australia, Qld

PostPosted: Wed Dec 26, 2007 5:56 am    Post subject: Reply with quote

I'm not familiar with ez_invoke, but
Code:
Set obj1.property = obj2
should be equivalent to
Code:
COM_Invoke(obj1, "property=", "+" obj2)
Back to top
View user's profile Send private message
COM TTS
Guest





PostPosted: Wed Dec 26, 2007 6:27 am    Post subject: Reply with quote

Ok, thanks lexicos and Joy2dworld.

Thanks to your making sure the usage is right,
I tried additional code, and it worked.

I should close the filestream.

Code:
ez_invoke("spFileStream.close")
ez_invoke("spFileStream=", Nothing)
ez_invoke("objVoice.AudioOutputStream=", nothing)
Back to top
Joy2DWorld



Joined: 04 Dec 2006
Posts: 422
Location: Galil, Israel

PostPosted: Wed Dec 26, 2007 6:49 pm    Post subject: Reply with quote

COM TTS wrote:


COM_Invoke(#_objVoice, "Voice=", "+" . COM_Invoke(COM_Invoke(#_objVoice, "GetVoices", "Name=Microsoft Sam"), "Item", 0))



can also be:
Code:

#_MSSam := ez_invoke("objVoice.GetVoices", "Name=Microsoft Sam")

ez_invoke("objVoice.Voice=", "+" . ez_Invoke("MSSam.Item", 0)



edit:


and now, can also be:

Code:

ez_invoke("objVoice.Voice=", "+" ez_invoke("objVoice.GetVoices[""Name=Microsoft Sam""].Item", 0 ))


or even


Code:

ez_invoke("objVoice.Voice=", "+" ez_invoke("objVoice.GetVoices[""Name=Microsoft Sam""].Item[0]" ))



which should hopefully help with the 'drop and use' idea for VB objects.
_________________
Joyce Jamce
Back to top
View user's profile Send private message
Joy2DWorld



Joined: 04 Dec 2006
Posts: 422
Location: Galil, Israel

PostPosted: Thu Dec 27, 2007 7:07 am    Post subject: Reply with quote

ie.

Code:
Set objVoice = CreateObject("SAPI.SpVoice")
Set objVoice.Voice = objVoice.GetVoices("Name=Microsoft Sam").Item(0)



just becomes:

Code:
#_objVoice := com_createObject("SAPI.SPVoice")

ez_invoke("objVoice.Voice=", "+" ez_invoke(objVoice.GetVoices[""Name=Microsoft Sam""].Item[0]"))


_________________
Joyce Jamce
Back to top
View user's profile Send private message
COMTTS
Guest





PostPosted: Thu Dec 27, 2007 8:44 am    Post subject: Reply with quote

Code:
com_init()
#_objVoice := com_createObject("SAPI.SPVoice")
ez_invoke("objVoice.Voice=", "+" ez_invoke("objVoice.GetVoices[""Name=Microsoft Sam""].Item[0]"))
ez_invoke("objvoice.speak", "Now I got all I need to know, thanks again.")


But how about considering single quote in your ez stdlib?
Like below.

Code:
ez_invoke("objVoice.Voice=", "+" ez_invoke("objVoice.GetVoices['Name=Microsoft Sam'].Item[0]"))
Back to top
Joy2DWorld



Joined: 04 Dec 2006
Posts: 422
Location: Galil, Israel

PostPosted: Thu Dec 27, 2007 6:36 pm    Post subject: Reply with quote

ok,

does seem easier...


ez_invoke("object.property[""this should also work""].method['this works']", x)

should now work...

Code:
ez_invoke("objVoice.Voice=", "+" ez_invoke("objVoice.GetVoices['Name=Microsoft Sam'].Item[0]"))


works for me.

(and actually, it's pretty cool.)


ps: just a reminder :: this is just feeding to SEAN'S INVOKE function which is the real genius behind what is... well.... pretty darn cool!

edit:

ok, screw it.

if we're trying to make it as easy as possible, this now should work also:

Code:
ez_invoke("objVoice.Voice =+ objVoice.GetVoices['Name=Microsoft Sam'].Item[0]")



but if setting value to anything OTHER than another invoke returned handle, use regular ez_invoke("xxx.xxx.xx=", the value)


hope helpful...

ps: this is just to save the double ez_invoke entry when setting one object with pointer to another object. anything beyond this is just getting into psuedo VB and... since you can run vb script directly if wanted... not seem necessary...

real idea here is able to use cut and paste VB *OBJECTS* in AHK... not to drop VB code into interpreter...


anyhows...
_________________
Joyce Jamce
Back to top
View user's profile Send private message
Joy2DWorld



Joined: 04 Dec 2006
Posts: 422
Location: Galil, Israel

PostPosted: Thu Dec 27, 2007 7:45 pm    Post subject: Reply with quote

oh,

and

ez_invoke("object.propety.method.+object2.property.method")

*should* also work same as ez_invoke("object.prop.method","+" ez_invoke("object2.prop.method")
_________________
Joyce Jamce
Back to top
View user's profile Send private message
comtts
Guest





PostPosted: Sat Dec 29, 2007 4:53 am    Post subject: Reply with quote

yeah, I tested and working fine, all three ways.

Code:
ez_invoke("objVoice.Voice=", "+" ez_invoke("objVoice.GetVoices[""Name=Microsoft Sam""].Item[0]"))


Code:
ez_invoke("objVoice.Voice=", "+" ez_invoke("objVoice.GetVoices['Name=Microsoft Sam'].Item[0]"))


Quote:
ez_invoke("objVoice.Voice =+ objVoice.GetVoices['Name=Microsoft Sam")


I like 2nd, 3rd way. Thank you.
Back to top
majkinetor



Joined: 24 May 2006
Posts: 3624
Location: Belgrade

PostPosted: Fri Jan 04, 2008 7:03 pm    Post subject: Reply with quote

I always get
Quote:
---------------------------
xml.ahk
---------------------------
Error in #include file "d:\Utils\AutoHotkey\Lib\ez_Invoke.ahk": Too many parameters passed to function.

Specifically: Com_Invoke(_object, _param . _dparamQ,regexreplace( _dualparam,"^['""]|['""]$"), arg1 ,arg2 ,arg3,ar...

Line#
039: _object := ez_invoke_findhandle(_object,revoke)
042: if _obj
042: {
044: if ( _param != _param + 0 )
045: _param := ez_invoke_findhandle( _param , revoke)
047: _param := "+" . _param
048: }
---> 058: Return,(_param = "") ? Com_Invoke(_object, arg1 ,arg2 ,arg3,arg4,arg5,arg6,arg7,arg8,arg9) : (_dualparam = "") ? Com_Invoke(_object, _param , arg1 ,arg2 ,arg3,arg4,arg5,arg6,arg7,arg8,arg9) : Com_Invoke(_object, _param . _dparamQ,regexreplace( _dualparam,"^['""]|['""]$"), arg1 ,arg2 ,arg3,arg4,arg5,arg6,arg7,arg8,arg9)
061: }
063: {
070: myobject := "#_" . regexreplace(object, "\.", "#_", parts)
077: if !(revoke || parts || regexmatch(myobject, illegal) ) && ((handle := %myobject%) > 0 )
078: Return,handle
080: position = 1
081: Loop

The program will exit.
---------------------------
OK
---------------------------

_________________
Back to top
View user's profile Send private message MSN Messenger
Joy2DWorld



Joined: 04 Dec 2006
Posts: 422
Location: Galil, Israel

PostPosted: Sat Jan 05, 2008 10:42 pm    Post subject: Reply with quote

try latest ver ?
_________________
Joyce Jamce
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6  Next
Page 2 of 6

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group