Jump to content
JScript

CreateFilesEmbedded.au3 - Like FileInstall...

Recommended Posts

CreateFilesEmbedded.exe

Application to embed files into their programs in the format .AU3


I present a different format to add files in your script:

So how about having our files (photos, text, executables) built?

1 - We can use the binary variables with

2 - We can test the fully functional program with F5 SciTE

4 - Use your imagination!!!

Sintax / Examples:

#include "YourFileEmbedded.au3"

; Returning the code in binary format
$bData = _YourFileEmbedded()

; Saving the code in the HDD
_YourFileEmbedded( True, @ScriptDir)

; Saving and running the code
_YourFileEmbedded( True, @ScriptDir, True)

; Finally, running the code directly
Run(_YourFileEmbedded(True))

Language file sample:

; #INDEX# =======================================================================================================================
; Title .........: CreateFilesEmbedded™
; Module ........: Language
; Author ........: Reaper HGN
; Link ..........: http://www.autoitscript.com/forum/topic/132564-createfilesembeddedau3-like-fileinstall/#entry930932
; Language ......: English (United States)
; ===============================================================================================================================

[0409]
1 = Options for the output file.
2 = Create a function based on the output name.
3 = Adding patterns of User Defined Functions (UDF).
4 = Only create the output file with the binary.
5 = Adding native LZNT Windows compression.
6 = Compression level
7 = &Open File
8 = Embedding file
9 = Test
10 = Default
11 = Progress of conversion:
12 = Exit
13 = Converted Lines
14 = Choose a file to embed
15 = The file
16 = no exist!
17 = 'The test only with the option: "Create a function based on the output name" activated!'
18 = Wait, creating the file. AU3 ->
19 = Save the file as built
20 = Compressing the file, wait...
21 = Done!
22 = The file
23 = was embedded in the format .AU3!

Supports:

; All file types!

Downloads:

Version: 2.27

CreateFilesEmbedded_(RedirectLink).html

(Previous downloads: 575)

Example using the binary return (without writing the file in HDD)

BinarySoundTest.zip

Sample:

Posted Image

Fixes:

  • 2.27.0912.2600
  • 27/09/2012 -> Some bugs fixed and added multi-language support!
  • 1.15.0911.2600b
  • 02/09/2011 -> First release!


Free Software

Redistribute and change under these terms:

1 - This program is free software: you can redistribute it and / or modify it under the terms of the GNU General Public License

As published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

2 - This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, without even the implied warranty

of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

3 - You should have received a copy of the GNU General Public License along with this program.

If not, see http://www.gnu.org/licenses.

João Carlos.

Edited by Melba23
File removed at JScript's request

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Share this post


Link to post
Share on other sites

Well, Portuguese is a lot like my native language, I was surprised when I actually understood everything in that language, I didn't know it was so similar to Spanish.

CreateFilesEmbedded.au3

Edited by THAT1ANONYMOUSEDUDE

Share this post


Link to post
Share on other sites

@THAT1ANONYMOUSEDUDE

Muchas gracias!

¡Tienes razón! És muy parecida...

Thank you very much!

You're right! Is very similar

João Carlos.


http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Share this post


Link to post
Share on other sites

@THAT1ANONYMOUSEDUDE

Muchas gracias!

¡Tienes razón! És muy parecida...

Thank you very much!

You're right! Is very similar

João Carlos.

muchas? zomg i love muchas! corn chips, salsa, melted cheese, tomato...what more could you want in a food?

Share this post


Link to post
Share on other sites

@SandelPerieanu

Very strange, see this example:

Download: Test_(Embedded&FileInstall).zip

Test_(Embedded).au3

#AutoIt3Wrapper_Compression=4           ;Compression parameter 0-4  0=Low 2=normal 4=High. Default=2
#AutoIt3Wrapper_UseUpx=y                ;(Y/N) Compress output program.  Default=Y
 
#include "Zune.au3" ; 970KB, LZNT level 2
 
_Zune(True, @TempDir)
Test_(Embedded).exe = 978KB

Test_(FileInstall).au3

#AutoIt3Wrapper_Compression=4           ;Compression parameter 0-4  0=Low 2=normal 4=High. Default=2
#AutoIt3Wrapper_UseUpx=y                ;(Y/N) Compress output program.  Default=Y
 
FileInstall(".Zune.msstyles", @TempDir) ; 12.028KB
Test_(FileInstall).exe = 1.736KB

Conclusion: Who is smaller?

João Carlos.

Edited by jscript

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Share this post


Link to post
Share on other sites

Conclusion: Who is smaller?

it depends on how "compress able" a file is.

AutoIt uses a very week compression for script and fileinstall, but it stores it better.

Your function compresses much better, but stores not efficient (Hex values not binary)

Anyway thank you very much for this script. :graduated:

Share this post


Link to post
Share on other sites

@JFX

You're right! I'll see what I can do to improve it...

Do you have any idea? I was thinking of store in resource...

João Calos.

Edited by jscript

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Share this post


Link to post
Share on other sites

hmm, store in resource would be a very good solution for complied scripts.

for not complied it could be Base64 encoded, like in some other script (ex. AutoitObject)

Share this post


Link to post
Share on other sites

Base64 encoded?!?! It's better than in Hex format?

Could you give me an example?

João Carlos.

Edited by jscript

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Share this post


Link to post
Share on other sites

@jscript

Yes Base64 is a better choice then Hex format. It just need 4 Bytes to save 3 Bytes binary data

See here or

@trancexx

Thanks. It's a pleasure to read such excellent scripts

Share this post


Link to post
Share on other sites

I wanted to try this out, but wasnt sure about what the options and text was saying. I saw that you needed some translation, so I played around with the translate in Google. I copied your text into a language file and created a select based on your OSLang return value. I only did the original Portuguese and the additional English (You may want to do it a different way). Anyway, I modified the original file slightly to use all the variables that are setup in the language file.

Now I can check it out and see if it work for me :graduated:

Attaching files

CreateFilesEmbedded.au3

language.au3

Edited by Reaper HGN

Share this post


Link to post
Share on other sites

Hi, I played around with the translation file as you will not get something on the screen to read if your system has another language set (like german).

Hopefully I will have same spare time during the next couple of days I will translate it to german also.

Greetings RW

#include ".\Include\_GetOSLangString.au3"

$SysLang = _GetOSLangString(@OSLang)
Global $a_language[24]

If StringInStr($SysLang, "Portuguese", False) Then

  $a_language[1] = "Opções do arquivo de saída."
  $a_language[2] = "Criar uma função baseada no nome de saída."
  $a_language[3] = "Adicionar padrões de Funções Definidas pelo Usuário (UDF)."
  $a_language[4] = "Apenas criar o arquivo de saída com o binário."
  $a_language[5] = "Adicionar compressão  LZNT nativa do Windows."
  $a_language[6] = "Nível de compressão:"
  $a_language[7] = "&Abrir arquivo"
  $a_language[8] = "Embutir arquivo"
  $a_language[9] = "Testar"
  $a_language[10] = "Padrão"
  $a_language[11] = "Progresso de conversão:"
  $a_language[12] = "Sair"
  $a_language[13] = "Linhas convertidas:"
  $a_language[14] = "Escolha um arquivo para embutir:"
  $a_language[15] = "O arquivo "
  $a_language[16] = " não existe!"
  $a_language[17] = 'O teste somente com a opção: "Criar uma função baseada no nome de saída" ativada!'
  $a_language[18] = "Aguarde, criando o arquivo .AU3 -> "
  $a_language[19] = "Salvar o arquivo embutido como"
  $a_language[20] = "Compactando o arquivo, aguarde..."
  $a_language[21] = " - Concluído!"
  $a_language[22] = 'O arquivo "'
  $a_language[23] = '" foi embutido para au3.'

Else ;"English"

  $a_language[1] = "Options for the output file."
  $a_language[2] = "Create a function based on the output name."
  $a_language[3] = "Adding patterns of User Defined Functions (UDF)."
  $a_language[4] = "Only create the output file with the binary."
  $a_language[5] = "Adding compression LZNT native Windows."
  $a_language[6] = "Compression level"
  $a_language[7] = "&Open File"
  $a_language[8] = "Embedding file"
  $a_language[9] = "Test"
  $a_language[10] = "Standard"
  $a_language[11] = "Progress of conversion:"
  $a_language[12] = "Exit"
  $a_language[13] = "Converted Lines"
  $a_language[14] = "Choose a file to embed"
  $a_language[15] = "File"
  $a_language[16] = "No!"
  $a_language[17] = 'The test only with the option: "Create a function based on the output name" activated!'
  $a_language[18] = "Wait, creating the file. AU3 equipment ->"
  $a_language[19] = "Save the file as built"
  $a_language[20] = "Compressing the file, wait ..."
  $a_language[21] = "- Done!"
  $a_language[22] = 'File" '
  $a_language[23] = '"AU3 equipment was built for."'

EndIf

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

Hi @Belini

I'm doing a few more changes and then post here and in the Brazilian forum, thank you very much!

Regards,

João Carlos.


http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

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

    • By NHD
      Hi,
      I'm developing CefAu3 project, it embed Chromium browser to your AutoIt program.
      I'm busy and can stop it. If you want to contribute, you can fork my project and build it yourself.
       


      Some Features:
      - Easy create CEF window
      - Multi-message loop
      - Interaction between AutoIt and JavaScript
      - Supports AutoIt binding
      - Supports user events...

      Github: https://github.com/wy3/cefau3
      MiniBrowser: https://github.com/small-autoit/mb
      CEF project: https://bitbucket.org/chromiumembedded/cef
      Learn more: http://magpcss.org/ceforum/
    • By TheDcoder
      Hello everyone,
      I encountered this strange issue while working on a freelance project, I cannot give you the webpage/website on which this is happening because it is an internal site which is inaccessible externally. I am attempting to create a GUI with an IE control embedded in it, but when I navigate to the desired address, it shows a blank white page.
      The webpage does load if I use a different browser or normal (non-embedded) IE instance.
      I managed to get my hands on the source of the blank page:
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <link rel="stylesheet" type="text/css" href="res://ieframe.dll/ErrorPageTemplate.css" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Navigationen blev annulleret</title> <script src="res://ieframe.dll/errorPageStrings.js" language="javascript" type="text/javascript"> </script> <script src="res://ieframe.dll/httpErrorPagesScripts.js" language="javascript" type="text/javascript"> </script> </head> <body onLoad="javascript:navCancelInit(); "> <table width="730" cellpadding="0" cellspacing="0" border="0"> <!-- Error title --> <tr> <td id="infoIconAlign" width="60" align="left" valign="top" rowspan="2"> <img src="res://ieframe.dll/info_48.png" id="infoIcon" alt="Oplysningsikon"> </td> <td id="mainTitleAlign" valign="middle" align="left" width="*"> <h1 id="mainTitle">Navigationen til websiden blev annulleret</h1> </td> </tr> <tr> <!-- This row is for HTTP status code, as well as the divider--> <td id="errorCodeAlign" class="errorCodeAndDivider" align="right">&nbsp; <div class="divider"></div> </td> </tr> <!-- Error Body --> <!-- What you can do --> <tr> <td> &nbsp; </td> <td id="whatToTryAlign" valign="top" align="left"> <h2 id="whatToTry">Prøv at:</h2> </td> </tr> <!-- refresh page --> <tr> <td > &nbsp; </td> <td id="refreshPageAlign" align="left" valign="middle"> <h4> <table> <tr> <td valign="top"> <img src="res://ieframe.dll/bullet.png" border="0" alt="" class="actionIcon"> </td> <td valign="top"> <span id="navCancelContainer"></span><noscript id="refreshPage">Opdatere siden.</noscript> </td> </tr> </table> </h4> </td> </tr> </table> </body> </html> The ieframe.dll resources are a point of interest. I am not sure how the server is able to detect the embedded instance of IE ...
      Any suggestions? Here is a basic outline of the script:
      #include <IE.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Main() While True Sleep(1000) WEnd Func Main() ; Create GUI $hGUI = GUICreate("", $GUI_WIDTH, $GUI_HEIGHT, $iLeft, $iTop, $WS_POPUP) $oIE = _IECreateEmbedded() ;$oIE = _IECreate() ; This works, but it is not embedded in the GUI GUICtrlCreateObj($oIE, 0, 0, $GUI_WIDTH, $GUI_HEIGHT) GUISetState() ; Navigate to the URL and authenticate _IENavigate($oIE, $URL) EndFunc Thank you for the advice in advance!
    • By Viszna
      Hello.
      I create a function that saves the log to an html file.
      File html are included picture (conversion to Base64)
      Everything works OK.
      But I do the actions:
      screenshot to the png file (smaller than bmp) per disk (  _ScreenCapture_Capture(@ScriptDir & "\screenshot.png")  ) convert image from disk to base64 I need help to optimize the script:
      - screenshot to memory (do not save to disk) - convert this object to png in memory - invoking the conversion of png image from memory to base64 The first step _ScreenCapture_Capture("") create handle to an HBITMAP in memory
      How to convert image in memory to png?
      How to use Func _ConvertToBase64
      I attach my code
      #include <ScreenCapture.au3> #include <Date.au3> Global $RaportFileName = @YEAR & "-" & @MON & "-" & @MDAY & "_" & @HOUR & "_" & @MIN & "_" & @SEC & ".html" $text = "This is first line text" & @CRLF &"and this is next line" _Raport($text, 1) FileWrite(@ScriptDir & "\" & $RaportFileName, "</pre></html>") ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Raport ; Description ...: ; Syntax ........: _Raport($sText1[, $Screen = 0]) ; Parameters ....: $sText1 - a string value. ; $Screen - [optional] an unknown value. Default is 0. ; 0 - Default - do not screenshot ; 1 - added screenshot full desktop ; Return values .: None ; Author ........: Your Name ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Raport($sText1, $Screen=0) Local $sText = "" Local $sHead = "" ; Define HTML file header and style $sHead = '<html>' & @CRLF & '<head><meta charset="utf-8"></head>' & @CRLF $sHead = $sHead & '<style>img{border:3px solid #FF0000;}</style>' & @CRLF $sHead = $sHead & '<style>pre{font-family: monospace;}</style>' & @CRLF $sHead = $sHead & '<style>pre{font-size: large;}</style>' & @CRLF $sHead = $sHead & '<pre>' & @CRLF If NOT FileExists(@ScriptDir & "\" & $RaportFileName) Then ; If file Raport not exist then create FileOpen(@ScriptDir & "\" & $RaportFileName, 258) FileWrite(@ScriptDir & "\" & $RaportFileName, $sHead) EndIf If StringInStr($sText1, @CRLF) > 0 Then ; @CRLF (ENTER) change the @CRLF and 11 space (indentation on width "[GG:MM:SS] ") $sText1 = StringReplace($sText1, @CRLF, @CRLF & '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;') EndIf $sText = $sText & $sText1 If $Screen <> 0 Then _ScreenCapture_Capture(@ScriptDir & "\screenshot.png") $sText = $sText & @CRLF & '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' & '<img src="data:image/png;base64,' & _ConvertToBase64(@ScriptDir & "\screenshot.png") & '"/>' EndIf FileWrite(@ScriptDir & "\" & $RaportFileName, "[" & _NowTime(5) & "]&nbsp;" & $sText & "<br><br>"&@CRLF) ; write to file Raport EndFunc Func _ConvertToBase64($fFile) ;Xroot 2011 ;ClipPut("") ;$FN=@ScriptDir & "\screenshot.png" $FN=$fFile $dat=FileRead(FileOpen($FN,16)) $objXML=ObjCreate("MSXML2.DOMDocument") $objNode=$objXML.createElement("b64") $objNode.dataType="bin.base64" $objNode.nodeTypedValue=$dat ClipPut("") $Wynik = "" ;ClipPut($objNode.Text) $Wynik = $objNode.Text Return $Wynik EndFunc P.S.
      Excuse me my not good English.
    • By lonardd
      Hi,
      I have a source Script where I inserted the following code lines to be able to extract the script source code anytime later if I run it with the /ExtractSourceCode:
      #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
      #AutoIt3Wrapper_UseX64=n
      #AutoIt3Wrapper_Change2CUI=y
      #AutoIt3Wrapper_Res_SaveSource=Y
      #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
      If StringInStr($cmdlineRaw, "/ExtractSourceCode") Then
          FileInstall(@ScriptFullPath, @ScriptDir & "\" & @ScriptName & ".txt", 1)  
          ;FileInstall("C:\Test.txt", @ScriptDir & "\Test.txt")
          Exit
      EndIf
      I used to be able to compile it on another computer some years ago without problems.
      Now I wanted to modify the code, so I extracted it, renamed the file *.au3, performd my little modification and rebuild.
      Strangely, I get this popup with Caption: Aut2Exe Error and Invalid FileInstall() function.
      BEfore I hit the OK button on the Popup, I can see the file is actually Built as I can see that an EXE file is created, but as I hit OK in that error dialog, the EXE disappears.
      Any advice?
      Thanks
      David
      I can't remember if I did it with Autoit 2 
      EPP_NF_Replacer_UBI.au3
    • By Blueman
      Hey Guys,
      Hope that you can help me with something, maybe this is a bug in the new version of AUTOIT but first i will check it with you to know for sure.
      I have made a simple GUI with a Embedded IE Object, then i would like to read the HTML with _IEBodyReadHTML(), easy right?
      When i use the old IE.au3 include from a year back or so, it is working fine!
      When i use the new IE.au3 include came with the new installation that is currently available on autoitscript.com it isnt working (i get a result that says; 0).
      Let me show you.
       
      Working Example
      #include <GUIConstantsEx.au3> #include <IE_EmbeddedVersioning.au3> #include <IE_PreVersion.au3> ;Older Version Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example", 1000, 1000) Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25) Global $oIE_1 = _IECreateEmbedded() ; CREATE IE OBJECT(S) GUICtrlCreateObj($oIE_1, 355, 5, 600, 360) _IENavigate($oIE_1, "https://www.google.nl", 1) Local $CheckHTML_T = _IEBodyReadHTML($oIE_1) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) MsgBox(48,"",$CheckHTML_T) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK ExitLoop EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>Example  
      Failing Example
      #include <GUIConstantsEx.au3> #include <IE_EmbeddedVersioning.au3> #include <IE.au3> ;New Version Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example", 1000, 1000) Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25) Global $oIE_1 = _IECreateEmbedded() ; CREATE IE OBJECT(S) GUICtrlCreateObj($oIE_1, 355, 5, 600, 360) _IENavigate($oIE_1, "https://www.google.nl", 1) Local $CheckHTML_T = _IEBodyReadHTML($oIE_1) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) MsgBox(48,"",$CheckHTML_T) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK ExitLoop EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>Example  
      I have attachted all files and i am testing on Windows 10 with the latest SciTe Program (Not compiled). 
      When i compile the script it is showing the same result.
      Thanks guys!
      IE_PreVersion.au3
      IE.au3
      IE_EmbeddedVersioning.au3
×
×
  • Create New...