MattHiggs Posted July 11, 2020 Posted July 11, 2020 Hello Everyone. I had a question I wanted to ask. I have a script I wrote which makes copying udfs/scripts which contained in script blocks on the web (you know, kind of like this site) locally to my machine by copying/pasting the contents of the udf/script into a gui edit control. However, I have noticed that, for udfs/scripts that are super long, I am unable to paste the entire snippet into the edit control: it gets cut off after a certain number of characters. Is there a way to remove this limitation? Thanks in advance. My script: expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_SaveSource=y #AutoIt3Wrapper_Res_Language=1033 #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator #AutoIt3Wrapper_Add_Constants=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; *** Start added by AutoIt3Wrapper *** #include <FileConstants.au3> #include <MsgBoxConstants.au3> ; *** End added by AutoIt3Wrapper *** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.15.0 (Beta) Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <Constants.au3> #include <Zip.au3> #include <File.au3> #include <Array.au3> #include <Console.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $sevfile = "" If Not FileExists("C:\Program Files\7-Zip\7z.exe") Then If Not FileExists("C:\Program Files (x86)\7-Zip\7z.exe") Then DirCreate(@AppDataDir & "\7ziptemp") $down = InetGet("http://d.7-zip.org/a/7za920.zip", @AppDataDir & "\7zip.zip") InetClose($down) _Zip_UnzipAll(@AppDataDir & "\7zip.zip", @AppDataDir & "\7ziptemp") $sevfile = @AppDataDir & "\7ziptemp\7za.exe" Else $sevfile = "C:\Program Files (x86)\7-Zip\7z.exe" EndIf Else $sevfile = "C:\Program Files\7-Zip\7z.exe" EndIf $comfile = _GetFilename($sevfile) & "." & _GetFilenameExt($sevfile) Cout("") While 1 Do Cout("Do you want to process a [f]ile or [d]irectory?" & @CRLF) $selec = Getch() Until $selec = "f" Or $selec = "d" If $selec = "d" Then $thefolder = FileSelectFolder("Select the folder", "") If $thefolder = "" Or $thefolder = Null Then ExitLoop EndIf $allfiles = _FileListToArrayRec($thefolder, "*", $FLTAR_FILES, $FLTAR_RECUR) For $i = 1 To $allfiles[0] Step 1 Cout("Copying " & _GetFilename($thefolder & "\" & $allfiles[$i]) & "." & _GetFilenameExt($thefolder & "\" & $allfiles[$i]) & @CRLF) FileCopy($thefolder & "\" & $allfiles[$i], @ProgramFilesDir & "\AutoIt3\Include\" & _GetFilename($thefolder & "\" & $allfiles[$i]) & "." & _GetFilenameExt($thefolder & "\" & $allfiles[$i]), 1) FileCopy($thefolder & "\" & $allfiles[$i], @ProgramFilesDir & "\AutoIt3\Beta\Include\" & _GetFilename($thefolder & "\" & $allfiles[$i]) & "." & _GetFilenameExt($thefolder & "\" & $allfiles[$i]), 1) Next Else $file = FileOpenDialog("Select the udf or the archive that contains it.", "", "AutoIT and Archive (*.au3;*.zip;*.rar;*.7z;*.dll)", 7) $selectedfiles = StringSplit($file, "|") If @error Then SetError(0) If _GetFilenameExt($file) = "au3" Or _GetFilenameExt($file) = "dll" Then Cout("Copying " & _GetFilename($file) & "." & _GetFilenameExt($file) & @CRLF) FileCopy($file, @ProgramFilesDir & "\AutoIt3\Include\" & _GetFilename($file) & "." & _GetFilenameExt($file), 1) FileCopy($file, @ProgramFilesDir & "\AutoIt3\Beta\Include\" & _GetFilename($file) & "." & _GetFilenameExt($file), 1) ElseIf _GetFilenameExt($file) = "zip" Then $folder = _GetFilename($file) DirCreate(@DesktopDir & "\" & $folder) Cout("Unzipping " & _GetFilename($file) & "." & _GetFilenameExt($file) & @CRLF) _Zip_UnzipAll($file, @DesktopDir & "\" & $folder, 4) $array = _FileListToArrayRec(@DesktopDir & "\" & $folder, "*", $FLTAR_FILES, $FLTAR_RECUR) For $i = 1 To $array[0] Step 1 Cout("Copying " & _GetFilename(@DesktopDir & "\" & $folder & "\" & $array[$i]) & "." & _GetFilenameExt(@DesktopDir & "\" & $folder & "\" & $array[$i]) & @CRLF) FileCopy(@DesktopDir & "\" & $folder & "\" & $array[$i], @ProgramFilesDir & "\AutoIt3\Include\" & _GetFilename(@DesktopDir & "\" & $folder & "\" & $array[$i]) & "." & _GetFilenameExt(@DesktopDir & "\" & $folder & "\" & $array[$i]), 1) FileCopy(@DesktopDir & "\" & $folder & "\" & $array[$i], @ProgramFilesDir & "\AutoIt3\Beta\Include\" & _GetFilename(@DesktopDir & "\" & $folder & "\" & $array[$i]) & "." & _GetFilenameExt(@DesktopDir & "\" & $folder & "\" & $array[$i]), 1) Next ElseIf _GetFilenameExt($file) = "rar" Then $folder2 = _GetFilename($file) DirCreate(@DesktopDir & "\" & $folder2) Cout("Unzipping " & _GetFilename($file) & "." & _GetFilenameExt($file) & @CRLF) RunWait(@ComSpec & ' /c ' & $comfile & ' x "' & $file & '" -o"' & @DesktopDir & '\' & $folder2 & '\"', _GetFilenamePath($sevfile)) $array2 = _FileListToArrayRec(@DesktopDir & "\" & $folder2, "*", $FLTAR_FILES, $FLTAR_RECUR) For $i = 1 To $array2[0] Step 1 Cout("Copying " & _GetFilename(@DesktopDir & "\" & $folder2 & "\" & $array2[$i]) & "." & _GetFilenameExt(@DesktopDir & "\" & $folder2 & "\" & $array2[$i]) & @CRLF) FileCopy(@DesktopDir & "\" & $folder2 & "\" & $array2[$i], @ProgramFilesDir & "\AutoIt3\Include\" & _GetFilename(@DesktopDir & "\" & $folder2 & "\" & $array2[$i]) & "." & _GetFilenameExt(@DesktopDir & "\" & $folder2 & "\" & $array2[$i]), 1) FileCopy(@DesktopDir & "\" & $folder2 & "\" & $array2[$i], @ProgramFilesDir & "\AutoIt3\Beta\Include\" & _GetFilename(@DesktopDir & "\" & $folder2 & "\" & $array2[$i]) & "." & _GetFilenameExt(@DesktopDir & "\" & $folder2 & "\" & $array2[$i]), 1) Next ElseIf _GetFilenameExt($file) = "7z" Then $folder3 = _GetFilename($file) DirCreate(@DesktopDir & "\" & $folder3) Cout("Unzipping " & _GetFilename($file) & "." & _GetFilenameExt($file) & @CRLF) RunWait(@ComSpec & ' /c ' & $comfile & ' x "' & $file & '" -o"' & @DesktopDir & '\' & $folder3 & '\"', _GetFilenamePath($sevfile)) $array3 = _FileListToArrayRec(@DesktopDir & "\" & $folder3, "*", $FLTAR_FILES, $FLTAR_RECUR) For $i = 1 To $array3[0] Step 1 Cout("Copying " & _GetFilename(@DesktopDir & "\" & $folder3 & "\" & $array3[$i]) & "." & _GetFilenameExt(@DesktopDir & "\" & $folder3 & "\" & $array3[$i]) & @CRLF) FileCopy(@DesktopDir & "\" & $folder3 & "\" & $array3[$i], @ProgramFilesDir & "\AutoIt3\Include\" & _GetFilename(@DesktopDir & "\" & $folder3 & "\" & $array3[$i]) & "." & _GetFilenameExt(@DesktopDir & "\" & $folder3 & "\" & $array3[$i]), 1) FileCopy(@DesktopDir & "\" & $folder3 & "\" & $array3[$i], @ProgramFilesDir & "\AutoIt3\Beta\Include\" & _GetFilename(@DesktopDir & "\" & $folder3 & "\" & $array3[$i]) & "." & _GetFilenameExt(@DesktopDir & "\" & $folder3 & "\" & $array3[$i]), 1) Next Else Cout("Unknown file type. Skipping over " & $file & @CRLF) EndIf Else For $t = 2 To $selectedfiles[0] Step 1 $file = $selectedfiles[1] & "\" & $selectedfiles[$t] If _GetFilenameExt($file) = "au3" Or _GetFilenameExt($file) = "dll" Then Cout("Copying " & _GetFilename($file) & "." & _GetFilenameExt($file) & @CRLF) FileCopy($file, @ProgramFilesDir & "\AutoIt3\Include\" & _GetFilename($file) & "." & _GetFilenameExt($file), 1) FileCopy($file, @ProgramFilesDir & "\AutoIt3\Beta\Include\" & _GetFilename($file) & "." & _GetFilenameExt($file), 1) ElseIf _GetFilenameExt($file) = "zip" Then $folder = _GetFilename($file) DirCreate(@DesktopDir & "\" & $folder) Cout("Unzipping " & _GetFilename($file) & "." & _GetFilenameExt($file) & @CRLF) _Zip_UnzipAll($file, @DesktopDir & "\" & $folder, 4) $array = _FileListToArrayRec(@DesktopDir & "\" & $folder, "*", $FLTAR_FILES, $FLTAR_RECUR) For $i = 1 To $array[0] Step 1 Cout("Copying " & _GetFilename(@DesktopDir & "\" & $folder & "\" & $array[$i]) & "." & _GetFilenameExt(@DesktopDir & "\" & $folder & "\" & $array[$i]) & @CRLF) FileCopy(@DesktopDir & "\" & $folder & "\" & $array[$i], @ProgramFilesDir & "\AutoIt3\Include\" & _GetFilename(@DesktopDir & "\" & $folder & "\" & $array[$i]) & "." & _GetFilenameExt(@DesktopDir & "\" & $folder & "\" & $array[$i]), 1) FileCopy(@DesktopDir & "\" & $folder & "\" & $array[$i], @ProgramFilesDir & "\AutoIt3\Beta\Include\" & _GetFilename(@DesktopDir & "\" & $folder & "\" & $array[$i]) & "." & _GetFilenameExt(@DesktopDir & "\" & $folder & "\" & $array[$i]), 1) Next ElseIf _GetFilenameExt($file) = "rar" Then $folder2 = _GetFilename($file) DirCreate(@DesktopDir & "\" & $folder2) Cout("Unzipping " & _GetFilename($file) & "." & _GetFilenameExt($file) & @CRLF) RunWait(@ComSpec & ' /c ' & $comfile & ' x "' & $file & '" -o"' & @DesktopDir & '\' & $folder2 & '\"', _GetFilenamePath($sevfile)) $array2 = _FileListToArrayRec(@DesktopDir & "\" & $folder2, "*", $FLTAR_FILES, $FLTAR_RECUR) For $i = 1 To $array2[0] Step 1 Cout("Copying " & _GetFilename(@DesktopDir & "\" & $folder2 & "\" & $array2[$i]) & "." & _GetFilenameExt(@DesktopDir & "\" & $folder2 & "\" & $array2[$i]) & @CRLF) FileCopy(@DesktopDir & "\" & $folder2 & "\" & $array2[$i], @ProgramFilesDir & "\AutoIt3\Include\" & _GetFilename(@DesktopDir & "\" & $folder2 & "\" & $array2[$i]) & "." & _GetFilenameExt(@DesktopDir & "\" & $folder2 & "\" & $array2[$i]), 1) FileCopy(@DesktopDir & "\" & $folder2 & "\" & $array2[$i], @ProgramFilesDir & "\AutoIt3\Beta\Include\" & _GetFilename(@DesktopDir & "\" & $folder2 & "\" & $array2[$i]) & "." & _GetFilenameExt(@DesktopDir & "\" & $folder2 & "\" & $array2[$i]), 1) Next ElseIf _GetFilenameExt($file) = "7z" Then $folder3 = _GetFilename($file) DirCreate(@DesktopDir & "\" & $folder3) Cout("Unzipping " & _GetFilename($file) & "." & _GetFilenameExt($file) & @CRLF) RunWait(@ComSpec & ' /c ' & $comfile & ' x "' & $file & '" -o"' & @DesktopDir & '\' & $folder3 & '\"', _GetFilenamePath($sevfile)) $array3 = _FileListToArrayRec(@DesktopDir & "\" & $folder3, "*", $FLTAR_FILES, $FLTAR_RECUR) For $i = 1 To $array3[0] Step 1 Cout("Copying " & _GetFilename(@DesktopDir & "\" & $folder3 & "\" & $array3[$i]) & "." & _GetFilenameExt(@DesktopDir & "\" & $folder3 & "\" & $array3[$i]) & @CRLF) FileCopy(@DesktopDir & "\" & $folder3 & "\" & $array3[$i], @ProgramFilesDir & "\AutoIt3\Include\" & _GetFilename(@DesktopDir & "\" & $folder3 & "\" & $array3[$i]) & "." & _GetFilenameExt(@DesktopDir & "\" & $folder3 & "\" & $array3[$i]), 1) FileCopy(@DesktopDir & "\" & $folder3 & "\" & $array3[$i], @ProgramFilesDir & "\AutoIt3\Beta\Include\" & _GetFilename(@DesktopDir & "\" & $folder3 & "\" & $array3[$i]) & "." & _GetFilenameExt(@DesktopDir & "\" & $folder3 & "\" & $array3[$i]), 1) Next Else Cout("Unknown file type. Leaving in folder." & @CRLF) EndIf Next EndIf EndIf Do Cout("Do you have anymore udfs to add?" & @CRLF & "[Y]es, [N]o?" & @CRLF) $resp = Getch() Cout(@CRLF) Until $resp = "y" Or $resp = "n" If $resp = "y" Then ContinueLoop Else ExitLoop EndIf WEnd Func _GetFilename($sFilePath) Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & "." & "\root\cimv2") Local $oColFiles = $oWMIService.ExecQuery("Select * From CIM_Datafile Where Name = '" & StringReplace($sFilePath, "\", "\\") & "'") If IsObj($oColFiles) Then For $oObjectFile In $oColFiles Return $oObjectFile.FileName Next EndIf Return SetError(1, 1, 0) EndFunc ;==>_GetFilename Func _GetFilenameExt($sFilePath) Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & "." & "\root\cimv2") Local $oColFiles = $oWMIService.ExecQuery("Select * From CIM_Datafile Where Name = '" & StringReplace($sFilePath, "\", "\\") & "'") If IsObj($oColFiles) Then For $oObjectFile In $oColFiles Return $oObjectFile.Extension Next EndIf Return SetError(1, 1, 0) EndFunc ;==>_GetFilenameExt Func _GetFilenameInt($sFilePath) Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & "." & "\root\cimv2") Local $oColFiles = $oWMIService.ExecQuery("Select * From CIM_Datafile Where Name = '" & StringReplace($sFilePath, "\", "\\") & "'") If IsObj($oColFiles) Then For $oObjectFile In $oColFiles Return $oObjectFile.Name Next EndIf Return SetError(1, 1, 0) EndFunc ;==>_GetFilenameInt Func _GetFilenameDrive($sFilePath) Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & "." & "\root\cimv2") Local $oColFiles = $oWMIService.ExecQuery("Select * From CIM_Datafile Where Name = '" & StringReplace($sFilePath, "\", "\\") & "'") If IsObj($oColFiles) Then For $oObjectFile In $oColFiles Return StringUpper($oObjectFile.Drive) Next EndIf Return SetError(1, 1, 0) EndFunc ;==>_GetFilenameDrive Func _GetFilenamePath($sFilePath) Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & "." & "\root\cimv2") Local $oColFiles = $oWMIService.ExecQuery("Select * From CIM_Datafile Where Name = '" & StringReplace($sFilePath, "\", "\\") & "'") If IsObj($oColFiles) Then For $oObjectFile In $oColFiles Return $oObjectFile.Path Next EndIf Return SetError(1, 1, 0) EndFunc ;==>_GetFilenamePath Func IsFile($sFilePath) Return Number(FileExists($sFilePath) And StringInStr(FileGetAttrib($sFilePath), "D", 2, 1) = 0) EndFunc ;==>IsFile
Moderators Melba23 Posted July 11, 2020 Moderators Posted July 11, 2020 MattHiggs, _GUICtrlEdit_SetLimitText. 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: Reveal hidden contents 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
Musashi Posted July 11, 2020 Posted July 11, 2020 On 7/11/2020 at 5:27 PM, MattHiggs said: However, I have noticed that, for udfs/scripts that are super long, I am unable to paste the entire snippet into the edit control: it gets cut off after a certain number of characters. Is there a way to remove this limitation? Thanks in advance. Expand Here is an example with the function _GUICtrlEdit_SetLimitText, which @Melba23 has already mentioned : #include <GUIConstantsEx.au3> #include <GuiEdit.au3> _Example() Func _Example() Local $idEdit, $sRead , $sFilename ; Example : Read GDIPlus.au3 and show the code in an Edit control : $sFilename = StringRegExpReplace(@AutoItExe, "(?i)AutoIt3.exe$", "") & "Include\GDIPlus.au3" $sRead = FileRead($sFilename) GUICreate("Test : Huge Edit Control", 1200, 600) $idEdit = GUICtrlCreateEdit("", 2, 2, 1194, 568) ; Gets the current text limit for an edit control ConsoleWrite('1. _GUICtrlEdit_GetLimitText($idEdit) = ' & _GUICtrlEdit_GetLimitText($idEdit) & @CRLF) ; Sets a new text limit _GUICtrlEdit_SetLimitText($idEdit, 1500000) ConsoleWrite('2. _GUICtrlEdit_GetLimitText($idEdit) = ' & _GUICtrlEdit_GetLimitText($idEdit) & @CRLF) GUISetState(@SW_SHOW) _GUICtrlEdit_AppendText($idEdit, $sRead) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Example "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
argumentum Posted July 11, 2020 Posted July 11, 2020 GUICtrlSetLimit() Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
mikell Posted July 13, 2020 Posted July 13, 2020 GUICtrlSetLimit($edit, StringLen(FileRead($sFilename)))
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