Jump to content
ptrex

.NET Common Language Runtime (CLR) Framework

Recommended Posts

ptrex

@STetters

Using the WinSCP this way is the hard way ... Especially if you are not acquainted with .NET CLR.

I would recommend you to using either the traditional COM object approach :

 

 

Or the PowerShell .NET way.

I will see if I can make an example using the PS .NET way. But it will no be soon though ...

rgds

ptrex

Share this post


Link to post
Share on other sites
STetters

Many thanks PTrex for replying so promptly - the reference to the UDF option is really useful.

 

Many thanks

 

Share this post


Link to post
Share on other sites
wuruoyu

Hi @ptrex, if it possible to use your framework to add .Net control "MenuStrip" to AutoIt form.

I posted the question here:

Thank you in advance!

Share this post


Link to post
Share on other sites
ptrex
wuruoyu

Thanks for your reply! @ptrex

The Ribbon is a nice option, but it doesn't have the MenuStrip like style I want. The MenuStrip is just a standard menu with better looking skin.

If is possible for you to show me an example of how to add a .Net Control to AutoIt GUI (not on WinForm).

Edited by wuruoyu

Share this post


Link to post
Share on other sites
ptrex

There is no way that I know to get .NET controls on AutoIT GUI's ?  Where did you pick this up ?

The examples shown here is the opposite ... AutoIT controls on WinForms.

Sorry if this was not clear.

According to me you are just looking for this ?

https://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateMenu.htm 

 

Edited by ptrex

Share this post


Link to post
Share on other sites
Deye

As an idea: An interesting approach for this development would be to some how build a layer into scite using some special config file where known function calls can be switched (#UseCLR) to using CLR , for instance porting the simple Basic File I/O functions at first which is significant, then move on from there .., might get more interested and get the development speed to where it should be ..

Share this post


Link to post
Share on other sites
Danyfirex

Hello. I was needing to zip and unzip some folders. So I found an easy way using CLR. here a simple example.

 

#include ".\Includes\CLR.au3"
#include ".\Includes\CLR Constants.au3"




Local $oAssembly = _CLR_LoadLibrary("System.IO.Compression.FileSystem")
ConsoleWrite("!$oAssembly: " & IsObj($oAssembly) & @CRLF)

Local $pAssemblyType = 0
$oAssembly.GetType_2("System.IO.Compression.ZipFile", $pAssemblyType)
ConsoleWrite("$pAssemblyType = " & Ptr($pAssemblyType) & @CRLF)

Local $oAssemblyType = ObjCreateInterface($pAssemblyType, $sIID_IType, $sTag_IType)
ConsoleWrite("IsObj( $oAssemblyType ) = " & IsObj($oAssemblyType) & @CRLF)

Local $sInputFolder="C:\Users\Raziel\Desktop\Files"
Local $sOutZipFile="C:\Users\Raziel\Desktop\Files.zip"

Local $aArray[] = [$sInputFolder,$sOutZipFile]
Local $Return = 0
;compress
$oAssemblyType.InvokeMember_3("CreateFromDirectory", 0x158, 0, 0, CreateSafeArray($aArray), $Return)

Local $aArray[] = [$sOutZipFile,$sInputFolder & "-Extracted"]
;decompress
$oAssemblyType.InvokeMember_3("ExtractToDirectory", 0x158, 0, 0, CreateSafeArray($aArray), $Return)

Exit

Saludos

 

  • Like 3

Share this post


Link to post
Share on other sites
antonioj84
17 minutes ago, Danyfirex said:

Hello. I was needing to zip and unzip some folders. So I found an easy way using CLR. here a simple example.

 

#include ".\Includes\CLR.au3"
#include ".\Includes\CLR Constants.au3"




Local $oAssembly = _CLR_LoadLibrary("System.IO.Compression.FileSystem")
ConsoleWrite("!$oAssembly: " & IsObj($oAssembly) & @CRLF)

Local $pAssemblyType = 0
$oAssembly.GetType_2("System.IO.Compression.ZipFile", $pAssemblyType)
ConsoleWrite("$pAssemblyType = " & Ptr($pAssemblyType) & @CRLF)

Local $oAssemblyType = ObjCreateInterface($pAssemblyType, $sIID_IType, $sTag_IType)
ConsoleWrite("IsObj( $oAssemblyType ) = " & IsObj($oAssemblyType) & @CRLF)

Local $sInputFolder="C:\Users\Raziel\Desktop\Files"
Local $sOutZipFile="C:\Users\Raziel\Desktop\Files.zip"

Local $aArray[] = [$sInputFolder,$sOutZipFile]
Local $Return = 0
;compress
$oAssemblyType.InvokeMember_3("CreateFromDirectory", 0x158, 0, 0, CreateSafeArray($aArray), $Return)

Local $aArray[] = [$sOutZipFile,$sInputFolder & "-Extracted"]
;decompress
$oAssemblyType.InvokeMember_3("ExtractToDirectory", 0x158, 0, 0, CreateSafeArray($aArray), $Return)

Exit

Saludos

 

About zip.au3 is the compression ratio better using your method above ?

 

Edited by antonioj84
  • Like 1

Share this post


Link to post
Share on other sites
Danyfirex

@antonioj84 I really don't now you should take a look at System.IO.Compression.ZipFile in msdn.

I just need to zip a folder without take care of compression level.

 

Saludos

  • Like 2

Share this post


Link to post
Share on other sites
ptrex
ptrex

@antonioj84 , The compression will propably be the same since the ZIP.AU3 using the same windows build in classes. The ZIP.AU3 UDF use the traditional COM approach, while the .NET version use the CLR framework to access the classes. The main difference will be speed I guess... where the CLR might win over tradinational COM approach. You can do a simple test to compress using both approaches and compress speed and compression rate... easy to find out.

  • Like 2

Share this post


Link to post
Share on other sites
junkew

I think the approach above of .NET will be safer then the zip.au3 that is based on below logic where time / sleep function is important to function properly and script should not end before zipping is finished.

#include <Array.au3>
#include <File.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Zip all the files and folders in the desktop directory using the default parameters.
    Local $aFileList = _FileListToArray(@DesktopDir, Default, Default, True)
    If @error = 1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.")
        Exit
    EndIf
    If @error = 4 Then
        MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.")
        Exit
    EndIf

;Create empty zip file
    $str18zero=chr(0) & chr(0) & chr(0) & chr(0) & chr(0) & chr(0)
    $str18zero=$str18zero & $str18zero & $str18zero
    $EmptyZipFile="PK" & Chr(5) & Chr(6) & $str18zero
    $zipFileName=@tempdir & "\dummyfile.zip"
    
    $hZip=fileopen($zipFileName, $FO_OVERWRITE)
    filewrite($hZip,$emptyZipFile)
    fileclose($hZip)

;Add all the files  
    $oWsh = ObjCreate("Shell.Application")
    for $i=0 to ubound($aFileList)-1
        $oWsh.NameSpace($zipFileName).CopyHere($afilelist[$i] )
        sleep(150) ;Some weird speed issue
        ;consolewrite($afilelist[$i] & @CRLF)
    Next

    ; Display the results returned by _FileListToArray.
    ;_ArrayDisplay($aFileList, "$aFileList")
EndFunc   ;==>Example

 

Share this post


Link to post
Share on other sites
Earthshine

You could loop while the zipping process is running as a dynamic way to sleep


My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
junkew

Found another nice one for Delphi example to call .NET classes that are not comvisible

Assm := Host.DefaultAppDomain.Load_2('NetAddr');
T := Assm.GetType_2('DelphiNET.NETAdder');
Obj := T.InvokeMember_3('ctor', BindingFlags_CreateInstance, nil, null, nil);
Params := VarArrayOf([2]);
WriteLn('2 + 3 = ' + IntToStr(T.InvokeMember_3('Add3', BindingFlags_InvokeMethod, nil, Obj, PSafeArray(VarArrayAsPSafeArray(Params)))));

https://stackoverflow.com/questions/2048540/hosting-clr-in-delphi-with-without-jcl-example

With the examples we already have above should be (whenever people are interested and have time ;-)) completing the stuff

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • Earthshine
      By Earthshine
      This baby can do almost any language! I found Gleany on this site and set it up on a fresh win10 install. all i would need to do to make it build an exe of the search files app we discovered is the .NET Target Framework download to build 100 % but the exe works and generates! You also need to add the path the the version of csc.exe that you want to run. MSBuild is part of .NET and can read your .csproj file.
      YOU can develop .NET OR C/C++ on this baby!
      Super lightweight (fit for crappy laptops), and you can use any dev compilers you wish, Ming, MS, etc, whatever.
      To use the build, you need to open the csproj file, else, to check your syntax it can compile individual files as well. The warning are because I do not have the .NET 4.6 Targeting Pack installed... LOL, and I could get rid of the Core warning, yes, I did not want to build a .NET Core.dll I wanted a live x64 exe! Told you MSBUILD could handle .CSPROJ, .VBPROJ, and all others Microsoft. Don't let Visual Code or Visual Studio slow you down, although, this works with Visual Code as well but there is only debugging in CORE.DLL projects

      ListFiles Example.zip
       

    • breakbadsp
      By breakbadsp
      AutoIT AU3info doeas not detect all gui objects uniquely for .NET GUIs developed in C#.
      this is not working now i am using COM windows approach for this, But its very difficult.
      Please let me know if anyone has done it before.
    • QuickWhiteWolf
      By QuickWhiteWolf
      Hi everyone,
       
      I was previously a member of this forum under the username Wombat. It's been years and multiple email accounts closed since then so I decided to start fresh and take a moment to thank you all... (Admins/Mods let me know if we need to discuss this...)
       
      I started programming with AutoIT while working as a scrap catcher for a machine that chopped scrap into pieces for easier moving, I learned styles and gained strengths from some of the best members on this forum by reverse engineering their code. I gained the confidence of our IT manager by making a boast that I could write an application to replace a p.o.s. cobalt based app we were using on the floor at that time, needless to say I was way in over my head but he saw that I had potential and I luckily had built several other apps on the side that were of equal or greater value to the company. I've been working as help-desk for the past 3 years and writing software as well to facilitate the help desk and solve recurring issues with our users. I was given an office and moved out of help-desk about a year ago, after 5 years of hard work I've actually landed the title of Jr. Developer moving into mid level title/pay this year! The company has already set out an improvement path that sees me with 4 certs and a bachelors in 4 more years making great money. Before this I had only ever worked at gas stations, fast food and manual labor jobs. If you're ever worried about your life, want something more, or just want a change you can do it. It's not easy, not at all, but it's possible and software programming is a very rewarding field if you like to make things and see how others interact with them.

      I utilized AutoIT to bring a company into the twenty-first century, away from paper trails and sticky notes improving the quality of life for the employees on the floor (where I started before learning AutoIT). I was given the go ahead to purchase visual studio and I learned VB.Net and built an awesome piece of Zebra labeling software (Utilizing ZPL code translated froma graphical editor) for our shipping department. Now I'm diving head first into C# and we have another programmer on board as we move on to MS Team Services and begin to tackle a sweet new project involving real time awareness of our product on the factory floor utilizing RFID and windows 10 tablets.

      That's a long way to come in just 4 years, and I couldn't have done it without the gigantic heart this community has and the mentorship provided for people looking to get into programming.

      So from the bottom of my heart, with immense respect.... Thank you so much AutoIT community
    • Sucre
      By Sucre
      I turned to Autoit from AHK just because it support WinForm Application so well. The problem often haunts me that all the application in my job is WinForm. And it indeed help my work so much. Great thanks in advance.
      However, I can't get the ToolTip text in the application of my company. Specifically,now I want to get the information about some data, however the information is all displayed in the tooltip on the scatter diagram which is made of those data.
      Is there any advice ? Relative topics I have searched can't get any information about the winform tooltip...
       
    • Vexhero
      By Vexhero
      Hello! I have a script in autoit which I made yesterday and Im still getting the hang of autoit
      My question is, is there anyone here who would be able to explain how the convertion would go between AutoIt and C# when it comes to these lines of code, would I need to declare an array to show the $x & $y position? Also The LC is a function I have a bit down the code

       
      While (Not($it_full)) $pixels = PixelSearch(257, 181, 276, 202,0xA19695,10) ;Check color If NOT(@error) Then LC($pixels[0],$pixels[1]) EndIf $pixels = PixelSearch(693, 479, 729, 504,0x000001,3) ;Search If NOT(@error) Then ; MsgBox(0,"Title","Found It!") $it_full = True Sleep(8000) EndIf WEnd  
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.