firsttimer Posted March 13, 2009 Share Posted March 13, 2009 Anyone could kindly provide the links or methods hows its done. I wanted to the jpg/txt/etc files as variables in my script so that I dont have to use fileinstall or include them during exe compilation. I know its possible but the thing is how to convert it into a variable first? I have no idea how its done. Thanks for the help. Link to comment Share on other sites More sharing options...
KaFu Posted March 13, 2009 Share Posted March 13, 2009 Something like this? $picture = @SystemDir & "\oobe\images\mslogo.jpg" $n = GUICtrlCreatePic($picture, 50, 50, 200, 50) OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Varian Posted March 13, 2009 Share Posted March 13, 2009 (edited) Use this UDF from Szhlopp:http://www.autoitscript.com/forum/index.ph...mp;#entry556000It reads your file in binary and makes a function that you will need to include to build your file. Obviously not good for really big files, but it should serve your purpose Edited March 13, 2009 by Varian Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 13, 2009 Moderators Share Posted March 13, 2009 firsttimer,If you want to refer to files that exist on your computer then do this:$picture = "C:\path\file.jpg"Then use the variable $picture.If you want to store the actual file contents in your script, then it is a lot easier to use Fileinstall or Zedna's Resources.au3! However, if you want to go that way.......Text files can be stored as strings like this:$sString = "This is the first line." & @CRLF $sString &= "This is the start of the second " $sString &= "and this is the rest of it."If you want to store images, you have to get them into hex format first and then store them as strings in much the same way. But to use them, you need something like this code from ProgAndy and Zedna. I have used this to show very small images as part of an include file - a small 15x15 .jpg took about 1500 data characters to store (remember each byte needs 2 characters!) and you have to add the implementation code as well. It is not the most efficient way to do business.Sure you want to do it this way? As I said earlier - FileInstall or the Resources.au3 include is a lot simpler.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
firsttimer Posted March 15, 2009 Author Share Posted March 15, 2009 (edited) firsttimer, If you want to refer to files that exist on your computer then do this:$picture = "C:\path\file.jpg" Then use the variable $picture. If you want to store the actual file contents in your script, then it is a lot easier to use Fileinstall or Zedna's Resources.au3! However, if you want to go that way....... Text files can be stored as strings like this:$sString = "This is the first line." & @CRLF $sString &= "This is the start of the second " $sString &= "and this is the rest of it." If you want to store images, you have to get them into hex format first and then store them as strings in much the same way. But to use them, you need something like this code from ProgAndy and Zedna. I have used this to show very small images as part of an include file - a small 15x15 .jpg took about 1500 data characters to store (remember each byte needs 2 characters!) and you have to add the implementation code as well. It is not the most efficient way to do business. Sure you want to do it this way? As I said earlier - FileInstall or the Resources.au3 include is a lot simpler. M23 Thanks but sample provided didnt work when I try to compile it. http://www.autoitscript.com/forum/index.ph...mp;#entry519858 Any ideas why? And also how to convert a jpeg file into hexadecimal string? This is what I get so far 00000000: FF D8 FF E0 00 10 4A 46 - 49 46 00 01 01 01 00 60 00000010: 00 60 00 00 FF DB 00 43 - 00 08 06 06 07 06 05 08 00000020: 07 07 07 09 09 08 0A 0C - 14 0D 0C 0B 0B 0C 19 12 00000030: 13 0F 14 1D 1A 1F 1E 1D - 1A 1C 1C 20 24 2E 27 20 00000040: 22 2C 23 1C 1C 28 37 29 - 2C 30 31 34 34 34 1F 27 00000050: 39 3D 38 32 3C 2E 33 34 - 32 FF DB 00 43 01 09 09 00000060: 09 0C 0B 0C 18 0D 0D 18 - 32 21 1C 21 32 32 32 32 00000070: 32 32 32 32 32 32 32 32 - 32 32 32 32 32 32 32 32 00000080: 32 32 32 32 32 32 32 32 - 32 32 32 32 32 32 32 32 00000090: 32 32 32 32 32 32 32 32 - 32 32 32 32 32 32 FF C0 000000A0: 00 11 08 03 00 04 00 03 - 01 22 00 02 11 01 03 11 000000B0: 01 FF C4 00 1F 00 00 01 - 05 01 01 01 01 01 01 00 000000C0: 00 00 00 00 00 00 00 01 - 02 03 04 05 06 07 08 09 000000D0: 0A 0B FF C4 00 B5 10 00 - 02 01 03 03 02 04 03 05 000000E0: 05 04 04 00 00 01 7D 01 - 02 03 00 04 11 05 12 21 000000F0: 31 41 06 13 51 61 07 22 - 71 14 32 81 91 A1 08 23 00000100: 42 B1 C1 15 52 D1 F0 24 - 33 62 72 82 09 0A 16 17 00000110: 18 19 1A 25 26 27 28 29 - 2A 34 35 36 37 38 39 3A 00000120: 43 44 45 46 47 48 49 4A - 53 54 55 56 57 58 59 5A 00000130: 63 64 65 66 67 68 69 6A - 73 74 75 76 77 78 79 7A 00000140: 83 84 85 86 87 88 89 8A - 92 93 94 95 96 97 98 99 00000150: 9A A2 A3 A4 A5 A6 A7 A8 - A9 AA B2 B3 B4 B5 B6 B7 00000160: B8 B9 BA C2 C3 C4 C5 C6 - C7 C8 C9 CA D2 D3 D4 D5 00000170: D6 D7 D8 D9 DA E1 E2 E3 - E4 E5 E6 E7 E8 E9 EA F1 00000180: F2 F3 F4 F5 F6 F7 F8 F9 - FA FF C4 00 1F 01 00 03 sorry cant post the whole thing coz its 300Kb+ file Edited March 15, 2009 by firsttimer Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 15, 2009 Moderators Share Posted March 15, 2009 firsttimer,That was an old(ish) script and you now need additional include files to make it work - at a quick look you should use:#include <GUIConstantsEx.au3> #incluse <WindowsConstants.au3> #include "BinaryImage.au3"You need to convert your hex dump from this:00000000: FF D8 FF E0 00 10 4A 46 - 49 46 00 01 01 01 00 60 00000010: 00 60 00 00 FF DB 00 43 - 00 08 06 06 07 06 05 08to look like this:$JPG_File = "FFD8FFE000104A464946000101010060" $JPG_File &= "00600000FFDB00430008060607060508"For a 300k file that will take a bit of doing - unless you write a script to do it for you, of course. ;-)Are you sure you want to go this way? As I stated before, the other options are much easier!M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Szhlopp Posted March 16, 2009 Share Posted March 16, 2009 firsttimer, That was an old(ish) script and you now need additional include files to make it work - at a quick look you should use:#include <GUIConstantsEx.au3> #incluse <WindowsConstants.au3> #include "BinaryImage.au3" You need to convert your hex dump from this:00000000: FF D8 FF E0 00 10 4A 46 - 49 46 00 01 01 01 00 60 00000010: 00 60 00 00 FF DB 00 43 - 00 08 06 06 07 06 05 08to look like this:$JPG_File = "FFD8FFE000104A464946000101010060" $JPG_File &= "00600000FFDB00430008060607060508" For a 300k file that will take a bit of doing - unless you write a script to do it for you, of course. ;-) Are you sure you want to go this way? As I stated before, the other options are much easier! M23 lol As Varian pointed out, I already have a script that does this. RegEx/RegExRep Tester!Nerd Olympics - Community App!Login UDFMemory UDF - "Game.exe+753EC" - CE pointer to AU3Password Manager W/ SourceDataFiler - Include files in your au3!--- Was I helpful? Click the little green '+' Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 16, 2009 Moderators Share Posted March 16, 2009 Szhlopp,I can see 3 different requirements for "stored" data in a script:1. You are quite happy to write the "stored" data to a temporary file on disk so that it can be used by "classical" AutoIt code. As I understand your UDF, it uses this method - as does the built-in FileInstall function. The data in this case is stored via code in the script itself.2. You do not want to write the data to disk. This is where Zedna's Resources.au3 comes into its own, once you have used Autoit3Wrapper or Reshacker to get the data into the compiled .exe as a resource.3. You are writing a UDF which could be used by others who will obviously not have the original data. So the previous methods will not work as there is no data to "store" either via the code or as a resource. In this case, if you require images as part of the UDF you have to use the streaming code from ProgAndy and Zedna that I linked to above and store the data as a "hexdump" variable within the UDF. I have used this method very successfully in the past.I have been telling firsttimer all the way through this thread that the 3rd method is not the easiest way to go - I am sure he would find either of the other methods perfectly satisfactory - but this is what he wants to do.If I have misunderstood your UDF, by the way, my apologies in advance. :-); -----firsttimerYou might like to look at Szhlopp's UDF. The "file to hex" part of his code should save you a lot of work!M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Szhlopp Posted March 16, 2009 Share Posted March 16, 2009 (edited) Szhlopp,I can see 3 different requirements for "stored" data in a script:1. You are quite happy to write the "stored" data to a temporary file on disk so that it can be used by "classical" AutoIt code. As I understand your UDF, it uses this method - as does the built-in FileInstall function. The data in this case is stored via code in the script itself.2. You do not want to write the data to disk. This is where Zedna's Resources.au3 comes into its own, once you have used Autoit3Wrapper or Reshacker to get the data into the compiled .exe as a resource.3. You are writing a UDF which could be used by others who will obviously not have the original data. So the previous methods will not work as there is no data to "store" either via the code or as a resource. In this case, if you require images as part of the UDF you have to use the streaming code from ProgAndy and Zedna that I linked to above and store the data as a "hexdump" variable within the UDF. I have used this method very successfully in the past.I have been telling firsttimer all the way through this thread that the 3rd method is not the easiest way to go - I am sure he would find either of the other methods perfectly satisfactory - but this is what he wants to do.If I have misunderstood your UDF, by the way, my apologies in advance. :-); -----firsttimerYou might like to look at Szhlopp's UDF. The "file to hex" part of his code should save you a lot of work!M23FYI I'm not one of those idiots who thinks my stuff has to be the best. Zedna and ProgAndy have done a great job with their programs.The point you're missing is that he wants the data inside a non-compiled EXE. Which is exactly what that thing I wrote does. After it creates the code lines, you can copy/paste it into your script. It also creates the function to write it to the disk.Normally you don't want to store a large image file inside a non-compiled EXE. As was shown in my example, even that works. This was created for those who want to store a small file inside a script so that the script is still distributable without addition files (xml, txt, ini, ect).Given the fact that he wants to store a jpg, I would suggest that he compiles it in which case FileInstall does the trick =) Edited March 16, 2009 by Szhlopp RegEx/RegExRep Tester!Nerd Olympics - Community App!Login UDFMemory UDF - "Game.exe+753EC" - CE pointer to AU3Password Manager W/ SourceDataFiler - Include files in your au3!--- Was I helpful? Click the little green '+' Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 16, 2009 Moderators Share Posted March 16, 2009 Szhlopp,Where did I accuse you of being an idiot? All I did was set out the 3 scenarios I could envisage for "storing" data in a script. At no point did I suggest any way was "best" and I certainly made no disparaging comments about your code at all.I do not believe I am missing any point at all. The OP asked if he could have "the jpg/txt/etc files as variables in my script so that I dont have to use fileinstall or include them during exe compilation". I suggested a way to do this - he has also been directed to your UDF, of which I was completely unaware. I have also constantly told the OP that he should not excluse the easier methods of including the data - much as you conclude in your post. But is his choice which way he goes - although I hope that having explained the 3 scenarios in more detail, he may reach the same conclusion.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
firsttimer Posted March 16, 2009 Author Share Posted March 16, 2009 Use this UDF from Szhlopp:http://www.autoitscript.com/forum/index.ph...mp;#entry556000It reads your file in binary and makes a function that you will need to include to build your file. Obviously not good for really big files, but it should serve your purposeOoohs, I missed reading this post. Calm now, everyone. This is the thing I have been wanting to learn and do since last year or is it the year before? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 16, 2009 Moderators Share Posted March 16, 2009 firsttimer, Glad you found what you were looking for. Out of interest, which of the 3 scenarios I outlined is closest to yours? I only ask so I can offer better advice to the one who posts a similar question! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now