 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Lexikos
Joined: 17 Oct 2006 Posts: 4473 Location: Qld, Australia
|
Posted: Wed Jul 15, 2009 10:45 pm Post subject: |
|
|
I wrapped it for symmetry. I don't suppose it has much use.
| Quote: | | It is typically unnecessary to call the Stop method, because the code stops executing when the process exits. |
|
|
| Back to top |
|
 |
fasto
Joined: 22 May 2009 Posts: 12
|
Posted: Fri Dec 11, 2009 1:46 am Post subject: |
|
|
zip library for dotnet from http://dotnetzip.codeplex.com/
| Code: |
CLR_Start()
Zip := CLR_LoadLibrary("Ionic.Zip.dll")
ZipFile := CLR_CreateObject(Zip,"Ionic.Zip.ZipFile")
com_invoke(zipfile, "password=", "1234")
com_invoke(zipfile, "addfile", "Contents.txt")
com_invoke(zipfile, "adddirectory", A_scriptdir "\DotNetZip-v1.8")
com_invoke(Zipfile, "name=", A_scriptdir "\xxx.zip")
com_invoke(zipfile,"save")
com_release(zipFile)
msgbox, compressed done!
zipFile := CLR_CreateObject(Zip,"Ionic.Zip.ZipFile")
com_invoke(zipfile, "password=", "1234")
com_invoke(zipFile, "initialize", A_scriptdir "\xxx.zip" )
filecreatedir, %A_scriptdir%\xxx
com_invoke(zipfile,"extractall", A_scriptdir "\xxx")
msgbox, extracted in xxx folder
com_release(zipFile)
com_release(Zip)
exitapp
|
the script is working ok, but unfortunatley problemes are
1)
it's not compatible with COM_L.
When calling CLR_createobject, com_l throws an error message.
2)
And I notice you made an explicit statment that the "static" method can't be called, which I don't know at all.
but from what i have tested so far, I guess that it means like system.Net.Dns class's gethostname method
'cause dns class has no contruction method so i couldn't create object for it and therefore couldn't call Gethostname method.
or is it possible to call dns.gethostname method with CLR lib?
3)
and finally could it be possible to make dot syntax possible as in Autohotkey_L and Com_L
possible or not, thanks for the script and Autohotkey_L.
Com_L and autohotkey_L combination is really fantastic. |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 4473 Location: Qld, Australia
|
Posted: Sat Dec 12, 2009 3:49 am Post subject: |
|
|
| fasto wrote: | | it's not compatible with COM_L. | COM_L has been updated to fix this issue.
| Quote: | | When calling CLR_createobject, com_l throws an error message. | I'm going to assume you mean that CLR.ahk was throwing an error mesage about number of parameters passed to COM_CreateObject. If that's not correct, please give more detail.
| Quote: | | And I notice you made an explicit statment that the "static" method can't be called, | Static methods can't be called with COM_Invoke because it requires an object to invoke. Static methods can be called, and in fact are called internally by CLR.ahk. It is difficult enough that I would recommend using embedded C# or VB in your scripts (as in the MessageBox.Show example).
| Quote: | | and finally could it be possible to make dot syntax possible as in Autohotkey_L and Com_L | You may use COM_Enwrap to wrap any pointer which works with COM_Invoke, including those returned by CLR_CreateObject.
I tested briefly with the following (and updated COM_L):
| Code: | CLR_Start()
lib := CLR_LoadLibrary("mscorlib")
obj := COM_Enwrap(CLR_CreateObject(lib,"System.Object"))
COM_Release(lib)
MsgBox % obj.ToString()
| A "select few" types have ProgID's (keys in HKEY_CLASSES_ROOT), so can be simply instantiated with COM_CreateObject:
| Code: | obj := COM_CreateObject("System.Collections.ArrayList")
MsgBox % obj.ToString()
|
|
|
| Back to top |
|
 |
fasto
Joined: 22 May 2009 Posts: 12
|
Posted: Sat Dec 12, 2009 4:01 pm Post subject: |
|
|
| Quote: | | COM_L has been updated to fix this issue. |
At first I couldn't decide whether it is appropritate to ask here or COM Thread.
But since I had some other questions about CLR, I came here. Thanks for the request.
| Quote: | | I would recommend using embedded C# or VB in your scripts (as in the MessageBox.Show example) |
OK, I tried that. It's working flawlessly though it's a bit tricky for me.
| Quote: | | You may use COM_Enwrap to wrap any pointer which works with COM_Invoke. |
I saw that function name before but until now i didn't know what the heck it is for.
Now I get it!
Some silly requests and sweet, detailed guides from the master!
Thanks, Lexikos |
|
| Back to top |
|
 |
fincs
Joined: 05 May 2007 Posts: 474 Location: Seville, Spain
|
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 4473 Location: Qld, Australia
|
Posted: Sun Dec 13, 2009 2:05 am Post subject: |
|
|
|
|
| Back to top |
|
 |
fincs
Joined: 05 May 2007 Posts: 474 Location: Seville, Spain
|
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 4473 Location: Qld, Australia
|
Posted: Sun Jan 10, 2010 10:55 am Post subject: |
|
|
CLR_CompileAssembly wasn't working in COM_L/U, so I've uploaded a new version of CLR with the following changes:
- AutoHotkey_L or AutoHotkeyU required. (However, the old version is still available.)
- CLR_LoadLibrary, CLR_CreateObject, and CLR_CompileC#/VB return a COM wrapper object.
- It should not be necessary to call CLR_Start explicitly.
Note that in simple cases, Assembly.CreateInstance(TypeName) can be used in place of CLR_CreateObject:
| Code: | CorLib := CLR_LoadLibrary("mscorlib")
stk := CorLib.CreateInstance("System.Collections.Stack")
que := CorLib.CreateInstance("System.Collections.Queue")
...
|
| Code: | CLR_CompileC#("class c{public void F(){System.Windows.Forms.MessageBox.Show(""Hello, world!"");}}" ,"System.dll|System.Windows.Forms.dll").CreateInstance("c").F()
|
|
|
| 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
|