Sign in to follow this  
Followers 0
Angel

#include .a3x file?

11 posts in this topic

Hi,

Is is possible to include an "a3x" file in a regular autoit (.au3) script? That is, I'd like to be able to do #include "my_lib.a3x" in an autoit3 script but I have tried it and it does not seem to work.

The reason why I'd like to do this is that we'd like to distribute an au3 library that we made to some of our clients. However we do not want them to be able to see the actual source code for the library, or at least we do not want it to be easy for them to view the code. We just want them to be able to call the AutoIt functions that we made, but not the actual implementation. I understand that if they really want they can probably "de-compile" the a3x file but it just needs to be hard for them to view the code, not completely impossible (mostly to keep our management happy).

So, is there some other way to achieve what I want to do?

Thanks!

Angel

P.S.- It is not my decision to hide the code in that library. This comes from my company's management and I cannot do anything about it :-(

Share this post


Link to post
Share on other sites



OK, so it seems that there is currently no way to do this and also it seems that Valik is quite opposed to it :-(

In my opinion this is something that would be quite useful for those of us that cannot always share their source code so it would be great if there was a way to do something like this.

Angel

Share this post


Link to post
Share on other sites

OK, so it seems that there is currently no way to do this and also it seems that Valik is quite opposed to it :-(

In my opinion this is something that would be quite useful for those of us that cannot always share their source code so it would be great if there was a way to do something like this.

Angel

I don't think you read Valik's response:

I've changed your summary to be a little more explicit. Really all you're asking for is the ability to #include A3X compiled files as if they were raw source. That's something I've always wanted as well.

Share this post


Link to post
Share on other sites

Here is one method to do this:

The UDFs library should looks like this:

UDFs.plg

#NoTrayIcon

If $CmdLine[0] = 0 Then Exit ;We need at least 1 command line


;Collecting parameters
$sParams = ""

For $i = 2 To $CmdLine[0]
    $sParams &= $CmdLine[$i] & "|"
Next

$sParams = StringTrimRight($sParams, 1)

Call($CmdLine[1], $sParams)


;==== UDFs Part ====

Func TestFunc($sParams)
    Local $iRet = MsgBox(36, "Question", $sParams)
    
    ConsoleWrite($iRet)
EndFuncoÝ÷ Ùh^*.«Þ­æÊØ^&ëj¼°ØT[.׫¶¢Z+¢
Þz{)j{-ÊWoÝ÷ Ù8^*.q©ÜjY^_ºw-åG­+1¨§IÊâ¦×±{öÚºÚ"µÍÚ[ÛYH  ÔÝ[Ë]LÉÝÂÛØ[    ÌÍÜÕQ×Ó[Ù[HH[    [È ][ÝÉÌLß][ÝÈ   [ÈØÜ[YH  [È ][Ý×ÕQË ][ÝÂÌÍÝ]HÑ^XÝ]Q^[[Ê ][ÝÕQËÉ][ÝËLË    ][ÝÕÝ[É][ÝË   ÌÎNÉ][ÝÐH[ÝHÝOÉ][ÝÉÌÎNÊBÙÐÞ
    ][ÝÉ][ÝË    ][ÝÔ]YYÜØYÙHÛH^[[Î   ][ÝÈ  [È ÌÍÝ]
B[ÈÑ^XÝ]Q^[[Ê   ÌÍÜÕQ×Ó[Ù[K  ÌÍÜÑ[ÜÜË ÌÍÜÑ[Ó[YK  ÌÍÜÔ[ÏI][ÝÉ][ÝÊBSØØ[ ÌÍÜÔXYH[TXY
    ÌÍÜÕQ×Ó[Ù[JBBRYÝ[Q^ÝÊ ÌÍÜÕQ×Ó[Ù[JH[Ý[Ò[Ý    ÌÍÜÔXY  ][ÝÎÑ[ÜY    ][ÝÈ  [ÈÔH[BIÌÍÜÔXYHÝ[ÔXÙJ   ÌÍÜÔXY  ][ÝÎÑ[ÜY    ][ÝÈ  [ÈÔ   ][ÝÉ][ÝÊBBBBSØØ[  ÌÍÚÜ[H[SÜ[ ÌÍÜÕQ×Ó[Ù[KBBQ[UÜ]J ÌÍÚÜ[ÔÝ[Ñ[Ü
    ÌÍÜÔXY  ÌÍÜÑ[ÜÜÊJBBQ[PÛÜÙJ    ÌÍÚÜ[BQ[YBRYÝ[Q^ÝÊ   ÌÍÜÕQ×Ó[Ù[JH[]Ù]ÜK ÌÎNÉÌÎNÊBBSØØ[  ÌÍÚTQH[]]Ò]^H   [È ÌÎNÈÐ]]Ò]Ñ^XÝ]TØÜ  ][ÝÉÌÎNÈ   [ÈÂBIÌÍÜÕQ×Ó[Ù[H   [È ÌÎNÉ][ÝÈ   ÌÎNÈ [È ÌÍÜÑ[Ó[YH  [È ÌÎNÈ ÌÎNÈ [È ÌÍÜÔ[Ë ÌÎNÉÌÎNË  ÌÎNÉÌÎNË
È
BSØØ[ ÌÍÜÔÝÝ]XYH    ][ÝÉ][ÝÂBUÚ[HØÙÜÑ^ÝÊ ÌÍÚTQ
BBIÌÍÜÔÝÝ]XY  [ÏHÝÝ]XY
    ÌÍÚTQ
BUÑ[BT]    ÌÍÜÔÝÝ]XY[[Â[ÈÛ]]Ò]^]

BQ[Q[]J ÌÍÜÕQ×Ó[Ù[JB[[

Yes, the users can go to the Temp directory and see the decrypted source, but you can hide it in any other place :), or delete it after every function call, but that's can take a time for each call.


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

I don't think you read Valik's response:

Actually I did read it, I just misunderstood him ;-)

I think he had another comment later on, but he was probably referring to another suggestion, which was to be able to include AutoIt3 executables. I thought he was referring to the inclusion of a3x files as well. Sorry!

Angel

Share this post


Link to post
Share on other sites

I do something similar to MSCreator.

Each of my A3X files performs a specific function, they run the whole of there task on there own.

When the A3X file completes it's job it writes its output to the console with ConsoleWrite()

I then have a main controller script which calls the A3X files and Sits in a loop peeking at the ConsoleRead() until there is data present then it does a propper ConsoleRead() to get the data it needs.

My Main script gets the A3X files to run from a config file, but you can hard code them or put them in a config file too.

Also in my script you will see I put a time out, this is because one f the things I do is to get some receipt printer data and occasionally it used to run on and on, WMI seemed to lock up. So I added in the timeout so if the A3X file was stuck with WMI the main script could kill it and carry on.

$myData = _RunA3x("MyFile.A3X")

Func _RunA3x($a3x)

    $toRun = FileGetShortName(@ScriptDir & "\"& $a3x)
    If NOT FileExists($toRun) then Return Msgbox(0,"Missing file",$a3x)
    $iPid = Run(FileGetShortName(@AutoItExe) & " /Autoit3ExecuteScript " & $toRun,@scriptdir,@SW_HIDE,6)

    $WMItimer = TimerInit()
    $WMItimeout = 60;seconds
    $WMItimeout *= 1000
    Local $line

    Do 
        $line = StdoutRead($iPid,True)
        If @error Then ExitLoop
        Sleep(100)
    Until $line <> "" or TimerDiff($WMItimer) > $WMItimeout
    
    
    If $line <> "" then 
        $line = ""
        
        While 1
            $line &= StdoutRead($iPid)
            If @error Then ExitLoop
        WEnd
        
        StdioClose($iPid)
        $iPid = -1
        Return $line
    Else
        StdioClose($iPid)
        ProcessClose($iPid)
        $iPid = -1
        Return "";fail safe for WMI lock up 
    EndIf
    
    Return ""
EndFunc

Share this post


Link to post
Share on other sites

Each of my A3X files performs a specific function, they run the whole of there task on there own.

When the A3X file completes it's job it writes its output to the console with ConsoleWrite()

I really like this solution. It is a clever work around I will probably use. Unfortunately, it can only succeed if only one script is using it at a time. If you use this with one A3x, but that A3X needs to make calls to another, both your master script, and the A3X (sub-)script will both be grabbing for the StdoutRead(), and not know which one it is intended for. This can also be a problem if more that one script that uses this technique are running concurrently.

We still need the ability to #Include a compiled library.

Perhaps, until we are able to include the scripts, we will have to make use of (cringing) Windows Messages.

Share this post


Link to post
Share on other sites

Ive been working on a UDF called ... well it has no name right now lol, but basically it allows you to write software in AI3 that can support plugins and/or be modular, WITH binary instructions [not uncompiled code i mean]. It will support password-protected UHA archives at first [possibly ZLib in future] and can decompress any file, even mp3/png/au3; TO MEMORY and NOT the hard-disk - allowing for much better security and preventing unneccessary hard-disk usage [the above suggested encryption method prevents my Vista machine from entering sleep, wont let 'defrag on idle' kick in, and so on].

Regardless, I'm happy that there are other people as well as me trying to overcome the #include and Execute() limitations without omprimising the security of AutoIt3. Cheers!

Share this post


Link to post
Share on other sites

I noticed that Valik has been assigned to my original posting for this (Yay!!!). I would love to test this as soon as it is in beta.

As is, every time one of my clients changes their scripts that require admin passwords, I have to compile them on my thumbdrive, with my encryption UDFs, and re-do the paperwork establishing them as owners of their code, while I still own my code, and they are licensed to use the compiled version of my code for this particular script, ... etc ...

Once this is done, I can grant them rights to use the compiled version of my encryption UDFs, without having to personally do the compiling for them.

Share this post


Link to post
Share on other sites

Don't hold your breathe though, it could be years.


Broken link? PM me and I'll send you the file!

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
Sign in to follow this  
Followers 0