iamtheky Posted June 14, 2011 Share Posted June 14, 2011 (edited) takes an image and turns it into an autoit usable binary representation, and shellexecutes the au3 (because im set to bring it up in Scite, suppose it will not play nicely if you are set to execute au3s) As always please turn this into something shiny and even more useful, so i can use that. Sorry if there already scripts in abundance that do this. expandcollapse popup#include <array.au3> #include <file.au3> Global $fixarray $pic = fileopen ("C:\Program Files\AutoIt3\Examples\GUI\merlin.gif" , 16) $read = fileread($pic) fileclose ($pic) $write = fileopen (@ScriptDir & "\binaryPic.txt" , 2) filewrite ($write , string($read)) fileclose ($write) $readfile = fileread (@ScriptDir & "\binaryPic.txt") $readarray = StringSplit ($readfile, "" , 2) $testwrite = fileopen (@ScriptDir & "\BinaryPic.au3" , 2) Filewrite ($testwrite , "Global $Pic_2_Binary = ") for $L = 0 to ubound ($readarray) - 1 step 121 If $L + 120 > ubound ($readarray) - 1 Then Filewrite ($testwrite , '"') for $i = $L to ubound ($readarray) - 1 Filewrite ($testwrite , $readarray[$i]) Next Filewrite ($testwrite , '"') Else Filewrite ($testwrite , '"') for $i = $L to $L + 120 Filewrite ($testwrite , $readarray[$i]) next Filewrite ($testwrite , '"') Endif FileWrite ($testwrite , @CRLF & "$Pic_2_Binary &= ") Next fileclose ($testwrite) _FileReadToArray (@ScriptDir & "\BinaryPic.au3" , $fixarray) _ArrayDelete ($fixarray, $fixarray[0]) _ArrayDelete ($fixarray, 0) _FileWriteFromArray (@ScriptDir & "\BinaryPic.au3" , $fixarray) filedelete (@ScriptDir & "\BinaryPic.txt") ShellExecute (@ScriptDir & "\BinaryPic.au3") Edited June 14, 2011 by iamtheky ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
guinness Posted June 14, 2011 Share Posted June 14, 2011 (edited) There are Examples floating around e..g This Example was found on the Forum (initially I saw by UEZ) and then modified it myself.Functions:expandcollapse popupFunc _FileToAU3Binary($sFile, $sVariable, $sFunction) Local $iLength = 160, $sData, $sFileRead, $sFunctionData $sData = __GetFile($sFile, 16) $sFunctionData = 'Func ' & $sFunction & '()' & @CRLF & @TAB & 'Local $' & $sVariable & ' = "' & StringLeft($sData, $iLength) & '"' & @CRLF $sData = StringTrimLeft($sData, $iLength) While StringLen($sData) > $iLength $sFunctionData &= @TAB & '$' & $sVariable & ' &= "' & StringLeft($sData, $iLength) & '" ' & @CRLF $sData = StringTrimLeft($sData, $iLength) WEnd If StringLen($sData) <> 0 Then $sFunctionData &= @TAB & '$' & $sVariable & ' &= "' & $sData & '"' EndIf $sFunctionData &= @CRLF & @TAB & 'Return $' & $sVariable & @CRLF & 'EndFunc ;==>' & $sFunction ClipPut(__SetFile($sFunctionData, @ScriptDir & "\Function.au3")) Return $sFunctionData EndFunc ;==>_FileToAU3Binary Func __GetFile($sFile, $sFormat = 0) Local $hFileOpen = FileOpen($sFile, $sFormat), $sData If $hFileOpen = -1 Then Return SetError(1, 0, "") EndIf $sData = FileRead($hFileOpen) FileClose($hFileOpen) Return $sData EndFunc ;==>_GetFile Func __SetFile($sString, $sFile) Local $hFileOpen = FileOpen($sFile, 2) FileWrite($hFileOpen, $sString) FileClose($hFileOpen) If @error Then Return SetError(1, 0, $sString) EndIf Return $sString EndFunc ;==>__SetFileExample use of Function:_FileToAU3Binary("Merlin.gif", "bBinaryPic", "_ImageFile") Edited June 14, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 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