Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/03/2022 in all areas

  1. The short answer is "most likely yes". Without more information, there's really no better answer that doesn't include a bunch of speculation and assumptions. If you want better answers, then learn how to ask better questions. The more detailed and specific your questions and/or requests are, the more accurate the responses will most likely be. You appear to be asking whether there is a way to speed up the code that you have written. Seriously, how do you expect anyone to be able to answer that question without seeing your script or a script that accurately shows the logic that you are using, some sample JSON data, and a detailed description of the expected results you are trying to gather from that sample data? JSMN, which is the JSON parsing engine that the json.au3 UDF lib is built around, is one of the fastest parsing engines around. So I seriously doubt that any performance issues with your script are related to the functions in the UDF lib. The most likely cause of your performance issues is the logic you are using to get the data or information that you want from the JSON. As you've read, there are multiple tools & UDF's available for parsing (and processing) JSON. If you are primarily wanting to pluck (parse) out data values, then I'm sure that the json.au3 UDF can do it as fast and efficiently as most any other JSON parsing engine. If you need to gather more than just data, meaning you need to gather information (like sums, averages, counts/stats, etc.), add/delete/modify JSON values or objects, or reformat/splice/extract JSON structures, then I would suggest a tool like jq. Some might even suggest parsing JSON using regular expressions, which may be very fast but (in my opinion) not as reliable, unless you have full control over the JSON being used as input (the order of the JSON data AND and its formatting). I'm not sure what you meant by this. If you are referring to the latest version of the json.au3 UDF library, then it is 2021.11.20 not 2021.11.06. You can find it near the bottom of the 1st post in this topic.
    2 points
  2. 5.2.3. is the latest version of the SciTE standard editor. However, you need a version adapted by @Jos for AutoIt, e.g. : SciTE4Autoit3
    1 point
  3. ByteRipper, Some simple error-checking gives the answer to your script problem - a pity no-one ever seems to bother to do this as all my UDFs have comprehensive error returns to explain why they might have failed. In this case, calling the _FindMaxSize function on the second text with a large font size produces an error from StringSize: So you need to add a check to see if this is the case: Func _FindMaxSize($sTxt, $iWidth, $iHeight, $iWeight, $iAttribute, $sFontName) ; Set an initial font size $iFontSize = 120 While 1 ; Size the label needed to fit the string into a label of the correct width $aRet = _StringSize($sTxt, $iFontSize, $iWeight, $iAttribute, $sFontName, $iWidth) If @error = 3 Then $iFontSize -= 1 ContinueLoop EndIf ; Now check if the height will fit If $aRet[3] < $iHeight Then ; If it does return the font size ExitLoop Else ; If not then reduce the font size and try again $iFontSize -= 1 EndIf WEnd Return $iFontSize EndFunc With that addition, your script runs perfectly for me. M23
    1 point
  4. There are 65 Variables that start with $a out of the total variable count of 12446. The total is different for each file as there are a different number of Local Variables and you have 12381 Standard Global Const variables. Nope ... those are the 3 options in the properties for debugging and "timing.debug=1" is something I made for myself that I shared with you ... so please stop being a nitpick and lets focus on the bigger picture which is the proper functioning of this feature! You have used all you assign allotment of questions for today so this was my last answer for today.
    1 point
  5. Please use the latest version of lua.zip I just uploaded as that gives a bit better stats summary which now include the Include files/UDFs GlobalConst count info: !-> Get_Std_UDFs time: 1.02 GlobalConstFiles:67 GlobalConstVars:13173 UDFIncludeFiles:16 UDFs:369 Debugging:0-0-0 --> GetCFileUDFs time: 0.13 IncludeFiles:3 UDFs:79 Debugging:0-0-0 C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3 ><- PerfDynUDFs time: 1.15 Debugging:0-0-0 open C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3 --> GetCFileUDFs time: 0.15 IncludeFiles:9 UDFs:61 Debugging:0-0-0 C:\Program Files (x86)\AutoIt3\SciTE\SciTEConfig\SciteConfig.au3 ><- PerfDynUDFs time: 0.15 Debugging:0-0-0 open C:\Program Files (x86)\AutoIt3\SciTE\SciTEConfig\SciteConfig.au3 --> GetCFileUDFs time: 0.21 IncludeFiles:8 UDFs:37 Debugging:0-0-0 C:\Program Files (x86)\AutoIt3\SciTE\SciTEConfig\AbbrevMan.au3 ><- PerfDynUDFs time: 0.21 Debugging:0-0-0 open C:\Program Files (x86)\AutoIt3\SciTE\SciTEConfig\AbbrevMan.au3 ... but as said: This is the last update until I have made the fix for the issue I mentioned earlier and have done some code cleanup..... and tested that.
    1 point
  6. Please slow down a little with these rapid posts containing questions and lets go back to the way we agreed a while ago... One question at a time and wait for the answer before asking the next thing. As stated: The log tells you everything and I have explained in Email and now also here what the issue is: 15:23:32 ->PerfDynUDFs ->GetCFileUDFs Skipping over 31-25 include file=z:\!!!_svn_au3\udf_forum\mlipok\\ADO.au3 Skipping over 31-25 include file means => more than the current set 25 limit so skipping it!
    1 point
  7. See my answer I just send in the Email, but for everybody else: The description in the properties describes: #> Max number of includes files to read from each directory in the list. This doesn't including the standard AutoIt3 includes. dynamic.max.includes=25 #> Max number total UDFs in the Userlist. This doesn't including the standard AutoIt3 includes. dynamic.max.funcs=1000 So when you have more Includes that contain UDFs you need to up those properties to whatever you feel need to be your limit.... but there probably is a price to pay each time SciTE is Started and the first au3 file is opened as at that time ALL those files need to be scanned.
    1 point
  8. As the picture is re-encoded, JPG is not lossless and you can not determine the initial quality setting of a JPG, the quality will always be reduced. #include <GDIPlus.au3> #include <WinAPIHObj.au3> #include <Array.au3> ; Initialize GDI+ library _GDIPlus_Startup() Local $sfile_input = FileOpenDialog("Please select file", "", "JPEG files (*.jpg;*.jpeg)") If @error Then Exit Local $sfile_output = StringReplace($sfile_input, ".", "_Out.") _Clone_MetaData($sfile_input, $sfile_output, Default, 500) If FileExists($sfile_output) Then ShellExecute($sfile_output) ; Shut down GDI+ library _GDIPlus_Shutdown() Func _Clone_MetaData($sfile_input, $sfile_output, $iWidth = Default, $iHeight = Default, $i_JPG_Quality = 95) If Not FileExists($sfile_input) Then Return 0 Local $a_DateTimeOriginal = FileGetTime($sfile_input) Local $s_DateTimeOriginal = $a_DateTimeOriginal[0] & ":" & $a_DateTimeOriginal[1] & ":" & $a_DateTimeOriginal[2] & " " & $a_DateTimeOriginal[3] & ":" & $a_DateTimeOriginal[4] & ":" & $a_DateTimeOriginal[5] Local $hImage = _GDIPlus_ImageLoadFromFile($sfile_input) Local $aDim = _GDIPlus_ImageGetDimension($hImage) Local $a_Local_Input_EXIF_Properties = cGDIPlus_ImageGetAllPropertyItems($hImage) Local $i_Local_Input_EXIF_Properties_Orientation = 1 For $i = 0 To UBound($a_Local_Input_EXIF_Properties) - 1 If $a_Local_Input_EXIF_Properties[$i][0] = 0x0112 Then ; Orientation $i_Local_Input_EXIF_Properties_Orientation = $a_Local_Input_EXIF_Properties[$i][3] $i_Local_Input_EXIF_Properties_Orientation = $i_Local_Input_EXIF_Properties_Orientation[0] ExitLoop EndIf Next Switch $i_Local_Input_EXIF_Properties_Orientation Case 5 To 9 ConsoleWrite("! Exif orientation applied" & @CRLF) Local $iBuffer = $aDim[0] $aDim[0] = $aDim[1] $aDim[1] = $iBuffer EndSwitch Local $iRatio = $aDim[0] / $aDim[1] If $iWidth <> Default Or $iHeight <> Default Then If $iWidth = Default Then $iWidth = $iHeight / $iRatio EndIf If $iHeight = Default Then $iHeight = $iWidth * $iRatio EndIf Local $hBitmap_Scaled = _GDIPlus_ImageResize($hImage, $iWidth, $iHeight) ConsoleWrite($aDim[0] & @TAB & $aDim[1] & @TAB & $aDim[0] / $aDim[1] & @TAB & $iWidth & @TAB & $iHeight & @TAB & $hBitmap_Scaled & @CRLF) _GDIPlus_ImageDispose($hImage) $hImage = $hBitmap_Scaled EndIf If IsArray($a_Local_Input_EXIF_Properties) Then _GDIPlus_ImageSetPropertyItem_Array($hImage, $a_Local_Input_EXIF_Properties) Local $sString = "Code ripped from BIC, https://funk.eu" Local $iRes = _GDIPlus_ImageSetPropertyItem_Ex($hImage, 0x0131, $sString, 2, StringLen($sString) + 1) ; Software > 2=ASCII $iRes = _GDIPlus_ImageSetPropertyItem_Ex($hImage, 0x0100, $iWidth, 4, -1) ; ImageWidth > 4=UINT $iRes = _GDIPlus_ImageSetPropertyItem_Ex($hImage, 0x0101, $iHeight, 4, -1) ; ImageHeight > 4=UINT $sString = @YEAR & ":" & @MON & ":" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC $iRes = _GDIPlus_ImageSetPropertyItem_Ex($hImage, 0x0132, $sString, 2, StringLen($sString) + 1) ; 0x0132 ModifyDate > 2=ASCII $sString = "Original Image Dimensions = " & $aDim[0] & "x" & $aDim[1] $iRes = _GDIPlus_ImageSetPropertyItem_Ex($hImage, 0x9286, $sString, 2, StringLen($sString) + 1) ; 0x9286 UserComment > 2=ASCII If $s_DateTimeOriginal Then $iRes = _GDIPlus_ImageSetPropertyItem_Ex($hImage, 0x9003, $s_DateTimeOriginal, 2, StringLen($s_DateTimeOriginal) + 1) ; 0x9003 DateTimeOriginal > 2=ASCII Local $sCLSID = _GDIPlus_EncodersGetCLSID("JPG") Local $tParams = _GDIPlus_ParamInit(1) Local $tData = DllStructCreate("int Quality") DllStructSetData($tData, "Quality", $i_JPG_Quality) Local $pData = DllStructGetPtr($tData) _GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData) Local $pParams = DllStructGetPtr($tParams) _GDIPlus_ImageSaveToFileEx($hImage, $sfile_output, $sCLSID, $pParams) ; Clean up resources _GDIPlus_ImageDispose($hImage) EndFunc ;==>_Clone_MetaData Func _GDIPlus_ImageSetPropertyItem_Array($hClone, $a_Local_Input_EXIF_Properties) For $i = 0 To UBound($a_Local_Input_EXIF_Properties) - 1 Local $aInput = [$a_Local_Input_EXIF_Properties[$i][0], $a_Local_Input_EXIF_Properties[$i][1], $a_Local_Input_EXIF_Properties[$i][2], $a_Local_Input_EXIF_Properties[$i][3]] cGDIPlus_ImageSetPropertyItem($hClone, $aInput) Next EndFunc ;==>_GDIPlus_ImageSetPropertyItem_Array Func _GDIPlus_ImageSetPropertyItem_Ex($hImage, $i_PropertyItem_Number, $s_PropertyItem_Value, $iType, $iLength) ; https://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html #cs 0x0131 > Software 0x010e > ImageDescription 0x9286 > UserComment 0x0132 > ModifyDate 0x9003 > DateTimeOriginal string ExifIFD (date/time when original image was taken) #ce Local $a_PropertyValue = [$s_PropertyItem_Value] Local $a_PropertyItem = [$i_PropertyItem_Number, $iLength, $iType, $a_PropertyValue] Local $iRes = cGDIPlus_ImageSetPropertyItem($hImage, $a_PropertyItem) Return SetError(@error, @extended, $iRes) EndFunc ;==>_GDIPlus_ImageSetPropertyItem_Ex ; #FUNCTION# ==================================================================================================================== ; Name ..........: cGDIPlus_ImageSetPropertyItem ; Description ...: Sets a specified property item (piece of meta data) for an Image object ; Syntax ........: cGDIPlus_ImageSetPropertyItem($hImage, $a1PropertyItem) ; Parameters ....: $hImage - Pointer to an image object ; $a1PropertyItem - Array containing the values of the property item ; [0] - identifier ; [1] - size of the value array ; positive: in bytes ; negative: for numeric types: in number of values ; [2] - type of value(s) in the value array ; [3] - value array ; Return values .: Success: True and @error = 0 ; Failure: sets the @error flag to: ; 1: DllCall failed. Common cause: _GIDPlus_Startup() has not been called ; 2: $a1PropertyItem is not a 4-element 1-d array ; 10: @extended may contain GPSTATUS error code ($GPID_ERR* see GDIPlusConstants.au3). ; 101: identifier is not an integer ; 201: size is not an integer ; 202: size cannot be number of values for ASCII string and undefined types ; 202: size is zero ; 301: type is illegal ; 401: value array is either not a 1-d array or has no elements ; 402: size is incompatible with type ; 403: size cannot be negative for ASCII string and undefined types ; 404: Numerator and denominator are required for rational types ; 405: size and number of elements in value array differ ; Author ........: Eukalyptus ; Modified ......: c.haslam, UEZ ; Remarks .......: If size parameter is negative, calculates size in bytes from type. ; Convenient when setting a few property items ;+ ; types: unsigned byte = 1, ASCII string = 2, unsigned short = 3, unsigned long = 4, ; unsinged rational = 5, undefined = 7, signed long = 9, signed rational = 10 ;+ ; For list of EXIF property items, see https://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html ; + and https://www.media.mit.edu/pia/Research/deepview/exif.html ; Related .......: _GDIPlus_ImageGetPropertyIdList, cGDIPlus_ImageGetPropertyItem ; Link ..........: https://msdn.microsoft.com/en-us/library/windows/desktop/ms535390(v=vs.85).aspx, ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms534493(v=vs.85).aspx, ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms534414(v=vs.85).aspx ; Example .......: Yes ; =============================================================================================================================== Func cGDIPlus_ImageSetPropertyItem($hImage, $a1PropertyItem) ;--------- should be moved to GDIPlusConstants.au3 Local Const $GDIP_PROPERTYTAGTYPEBYTE = 1, $GDIP_PROPERTYTAGTYPEASCII = 2, $GDIP_PROPERTYTAGTYPESHORT = 3, $GDIP_PROPERTYTAGTYPELONG = 4, _ $GDIP_PROPERTYTAGTYPERATIONAL = 5, $GDIP_PROPERTYTAGTYPEUNDEFINED = 7, $GDIP_PROPERTYTAGTYPESLONG = 9, _ $GDIP_PROPERTYTAGTYPESRATIONAL = 10 ;------------------------------------------------- If (Not IsArray($a1PropertyItem)) Or UBound($a1PropertyItem, 0) <> 1 Or UBound($a1PropertyItem) <> 4 Then Return SetError(2, 0, False) EndIf Local $iId = $a1PropertyItem[0] Local $iLength = $a1PropertyItem[1] Local $iType = $a1PropertyItem[2] Local $a1values = $a1PropertyItem[3] If Not IsInt($iId) Then Return SetError(101, 0, False) EndIf If Not IsInt($iLength) Then Return SetError(201, 0, False) EndIf If $iLength = 0 Then Return SetError(202, 0, False) EndIf Switch $iType Case $GDIP_PROPERTYTAGTYPEBYTE, $GDIP_PROPERTYTAGTYPEASCII, $GDIP_PROPERTYTAGTYPESHORT, _ $GDIP_PROPERTYTAGTYPELONG, $GDIP_PROPERTYTAGTYPERATIONAL, $GDIP_PROPERTYTAGTYPEUNDEFINED, _ $GDIP_PROPERTYTAGTYPESLONG, $GDIP_PROPERTYTAGTYPESRATIONAL ; do nothing Case Else Return SetError(301, 0, False) EndSwitch If (Not IsArray($a1values)) Or UBound($a1values, 0) <> 1 Or UBound($a1values) = 0 Then Return SetError(401, 0, False) EndIf Local $iBytes, $iqValues If $iLength > 0 Then ; useful when copying all property items $iBytes = $iLength Switch $iType Case $GDIP_PROPERTYTAGTYPEASCII ;ASCII String $iqValues = 1 Case $GDIP_PROPERTYTAGTYPESHORT ;Array of UShort If BitAND($iLength, 1) <> 0 Then Return SetError(402, 0, False) EndIf $iqValues = Int($iLength / 2) Case $GDIP_PROPERTYTAGTYPELONG, $GDIP_PROPERTYTAGTYPERATIONAL, $GDIP_PROPERTYTAGTYPESLONG, _ $GDIP_PROPERTYTAGTYPESRATIONAL ;Array of UInt / Fraction If BitAND($iLength, 3) <> 0 Then Return SetError(402, 0, False) EndIf $iqValues = Int($iLength / 4) Case Else ; Array of Bytes, undefined $iqValues = 1 EndSwitch ElseIf $iLength < 0 Then ; convenient when setting a few property items Switch $iType Case $GDIP_PROPERTYTAGTYPEASCII, $GDIP_PROPERTYTAGTYPEUNDEFINED ;ASCII String, undefined Return SetError(403, 0, False) Case $GDIP_PROPERTYTAGTYPESHORT ;Array of UShort $iBytes = -$iLength * 2 Case $GDIP_PROPERTYTAGTYPELONG, $GDIP_PROPERTYTAGTYPERATIONAL, $GDIP_PROPERTYTAGTYPESLONG, _ $GDIP_PROPERTYTAGTYPESRATIONAL ;Array of UInt / Fraction $iBytes = -$iLength * 4 Case Else ;Array of Bytes $iBytes = -$iLength EndSwitch $iqValues = -$iLength EndIf If $iType = $GDIP_PROPERTYTAGTYPERATIONAL Or $iType = $GDIP_PROPERTYTAGTYPERATIONAL Then If BitAND($iqValues, 1) <> 0 Then Return SetError(404, 0, False) EndIf EndIf Switch $iType Case $GDIP_PROPERTYTAGTYPESHORT, $GDIP_PROPERTYTAGTYPELONG, $GDIP_PROPERTYTAGTYPERATIONAL, _ $GDIP_PROPERTYTAGTYPESLONG, $GDIP_PROPERTYTAGTYPESRATIONAL If UBound($a1values) <> $iqValues Then Return SetError(405, 0, False) EndIf EndSwitch Local $tPropItem = DllStructCreate("int id; int length; short type; ptr pValue;") DllStructSetData($tPropItem, 'id', $iId) DllStructSetData($tPropItem, 'length', $iBytes) DllStructSetData($tPropItem, 'type', $iType) ; _ConsoleWrite($iId & @TAB & $iType & @CRLF) Local $tValues Switch $iType Case $GDIP_PROPERTYTAGTYPEASCII ;ASCII String $tValues = DllStructCreate("char[" & $iBytes & "];") Case $GDIP_PROPERTYTAGTYPESHORT ;Array of UShort $tValues = DllStructCreate("ushort[" & $iqValues & "];") Case $GDIP_PROPERTYTAGTYPELONG, $GDIP_PROPERTYTAGTYPERATIONAL ;Array of UInt / Fraction $tValues = DllStructCreate("uint[" & $iqValues & "];") Case $GDIP_PROPERTYTAGTYPESLONG, $GDIP_PROPERTYTAGTYPESRATIONAL ;Array of Int / Fraction $tValues = DllStructCreate("int[" & $iqValues & "];") Case Else ;Array of Bytes $tValues = DllStructCreate("byte[" & $iBytes & "];") EndSwitch If $iType = $GDIP_PROPERTYTAGTYPEASCII Or $iType = $GDIP_PROPERTYTAGTYPEUNDEFINED Then ; ASCII string or undefined DllStructSetData($tValues, 1, $a1values[0]) Else For $i = 0 To $iqValues - 1 DllStructSetData($tValues, 1, $a1values[$i], $i + 1) Next EndIf DllStructSetData($tPropItem, 'pValue', DllStructGetPtr($tValues)) Local $aResult = DllCall($__g_hGDIPDll, "uint", "GdipSetPropertyItem", "handle", $hImage, "struct*", $tPropItem) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return True EndFunc ;==>cGDIPlus_ImageSetPropertyItem ; #FUNCTION# ==================================================================================================================== ; Name ..........: cGDIPlus_ImageGetAllPropertyItems ; Description ...: Gets all property item (piece of meta data) from an Image object ; Syntax ........: cGDIPlus_ImageGetAllPropertyItems($hImage) ; Parameters ....: $hImage - Pointer to an image object ; Return values .: Success: Array in which each row contains these columns: ; [0] - identifier ; [1] - size, in bytes, of the value array ; [2] - type of value(s) in the value array ; [3] - value array ; Failure: sets the @error flag to: ; 1: DllCall failed. Common cause: _GIDPlus_Startup() has not been called ; 10: @extended may contain GPSTATUS error code ($GPID_ERR* see GDIPlusConstants.au3). ; @extended=2; no property items found ; Author ........: c.haslam ; Modified ......: ; Remarks .......: types: unsigned byte = 1, ASCII string = 2, unsigned short = 3, unsigned long = 4, ; unsinged rational = 5, signed byte = 6, undefined = 7, signed long = 9, ; signed rational = 10 ;+ ; For list of EXIF property items, see https://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html ; + and https://www.media.mit.edu/pia/Research/deepview/exif.html ; Related .......: cGDIPlus_ImageGetPropertyItem, _GDIPlus_ImageGetPropertyIdList, cGDIPlus_ImageSetPropertyItem ; Link ..........: https://msdn.microsoft.com/en-us/library/windows/desktop/ms535390(v=vs.85).aspx, ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms534493(v=vs.85).aspx, ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms534414(v=vs.85).aspx, ; https://msdn.microsoft.com/en-us/library/ms534416.aspx#_gdiplus_constant_propertytaggpsver ; Example .......: Yes ; =============================================================================================================================== Func cGDIPlus_ImageGetAllPropertyItems($hImage) Local $aResult = DllCall($__g_hGDIPDll, "uint", "GdipGetPropertySize", "handle", $hImage, "uint*", 0, "uint*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Local $iTotalBufferSize = $aResult[2] Local $iNumProperties = $aResult[3] Local $tBuffer = DllStructCreate("byte[" & $iTotalBufferSize & "]") Local $pBuffer = DllStructGetPtr($tBuffer) $aResult = DllCall($__g_hGDIPDll, "uint", "GdipGetAllPropertyItems", "handle", $hImage, _ "uint", $iTotalBufferSize, "uint", $iNumProperties, "ptr", $pBuffer) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Local $aPropertyItems[$iNumProperties][4] Local $a1 Local $tPropertyItem = DllStructCreate("int id; int length; short type; ptr value;") For $iI = 0 To $iNumProperties - 1 $a1 = __GDIPlus_ImageGetPropertyItemValues($pBuffer) For $j = 0 To 3 $aPropertyItems[$iI][$j] = $a1[$j] Next $pBuffer += DllStructGetSize($tPropertyItem) Next Return $aPropertyItems EndFunc ;==>cGDIPlus_ImageGetAllPropertyItems ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name ..........: __GDIPlus_ImageGetPropertyItemValues($pBuffer) ; Description ...: Converts a project item from structured to equivalent nested arrays ; Syntax ........: __GDIPlus_ImageGetPropertyItemValues($pBuffer) ; Parameters ....: $bBuffer - Pointer to start of Property Item sructure ; Return values .: [0] - identifier ; [1] - size, in bytes, of the value array ; [2] - type of value(s) in the value array ; [3] - value array ; Author ........: c.haslam ; Modified ......: UEZ ; Remarks .......: types: unsigned byte = 1, ASCII string = 2, unsigned short = 3, unsigned long = 4, ; unsigned rational = 5, signed byte = 6, undefined = 7, signed long = 9, ; signed rational = 10 ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func __GDIPlus_ImageGetPropertyItemValues($pBuffer) Local $tPropertyItem = DllStructCreate("int id; int length; short type; ptr value;", $pBuffer) Local $iBytes = DllStructGetData($tPropertyItem, "length") Local $pValue = DllStructGetData($tPropertyItem, "value") ;--------- should be moved to GDIPlusConstants.au3 Local Const $GDIP_PROPERTYTAGTYPEBYTE = 1, $GDIP_PROPERTYTAGTYPEASCII = 2, $GDIP_PROPERTYTAGTYPESHORT = 3, $GDIP_PROPERTYTAGTYPELONG = 4, _ $GDIP_PROPERTYTAGTYPERATIONAL = 5, $GDIP_PROPERTYTAGTYPEUNDEFINED = 7, $GDIP_PROPERTYTAGTYPESLONG = 9, _ $GDIP_PROPERTYTAGTYPESRATIONAL = 10 ;------------------------------------------------- Local $aRet[4] Local $type = DllStructGetData($tPropertyItem, 'type') Local $tValues, $iValues Switch $type Case $GDIP_PROPERTYTAGTYPEASCII ;ASCII String $iValues = 1 $tValues = DllStructCreate("char[" & $iBytes & "];", $pValue) Case $GDIP_PROPERTYTAGTYPESHORT ;Array of UShort $iValues = Int($iBytes / 2) $tValues = DllStructCreate("ushort[" & $iValues & "];", $pValue) Case $GDIP_PROPERTYTAGTYPELONG, $GDIP_PROPERTYTAGTYPERATIONAL ;Array of UInt / Fraction $iValues = Int($iBytes / 4) $tValues = DllStructCreate("uint[" & $iValues & "];", $pValue) Case $GDIP_PROPERTYTAGTYPESLONG, $GDIP_PROPERTYTAGTYPESRATIONAL ;Array of Int / Fraction $iValues = Int($iBytes / 4) $tValues = DllStructCreate("int[" & $iValues & "];", $pValue) Case Else ;Array of Bytes $iValues = 1 $tValues = DllStructCreate("byte[" & $iBytes & "];", $pValue) EndSwitch $aRet[0] = DllStructGetData($tPropertyItem, 'id') $aRet[1] = $iBytes $aRet[2] = $type Local $a1values[$iValues] If $type = $GDIP_PROPERTYTAGTYPEASCII Or $type = $GDIP_PROPERTYTAGTYPEUNDEFINED Then ; ASCII string or undefined $a1values[0] = DllStructGetData($tValues, 1) Else For $i = 0 To $iValues - 1 $a1values[$i] = DllStructGetData($tValues, 1, $i + 1) Next EndIf $aRet[3] = $a1values Return $aRet EndFunc ;==>__GDIPlus_ImageGetPropertyItemValues
    1 point
  9. ByteRipper, You can use StringSize - just iterate through the font sizes until you find the larges one that fits. Here is an example of what I mean: I hope that helps. M23
    1 point
  10. @jugador You seem offended, sorry. But I wasn't suggesting that your UDF is malicious, I was simply pointing out the fact that it is not secure. As per my understanding, you use Microsoft's JScript engine to parse JSON by passing it as input to your own function, but the input is not sanitized to protect against arbitrary code, am I right? A malicious JSON payload might contain code within the JSON or even outside it which is executed without the user's or script author's knowledge. It is important that the JSON input is sanitized because it is directly being injected as code which is run.
    1 point
  11. Thanks for debugging that! I understand now and fixed it in the current lua.zip version.
    1 point
  12. You can use PowerShell commands: Mount-DiskImage (Storage) | Microsoft Docs Dismount-DiskImage (Storage) | Microsoft Docs
    1 point
  13. If @TheDcoder said it "This UDF looks dangerous" then it has to be dangerous Mr @TheDcoder as you have decoded the malicious intent then why not do a favour to Autoit community and report the Mod to delete Json2 thread. To those who still want to use it even after @TheDcoder warning 1) json2.js => github link given 2) link to Danyfirex thread given from where Base64 String taken 3) or use Base64 decoder to check the Base64 String
    1 point
  14. Hello, I am not the best person to answer your questions, but I have been using AutoIt for years. I have read over the best practices guidelines, but that has only been recently (in the past 6 months or so). I have posted many scripts in the past and no one has ever mentioned that I wasn't adhering to the best practices. They are good rules to follow and can save some headaches, because the rules have pointed out some things that can break a script and leave you scratching your head. Your questions about variables are taken from Best Coding Practices and UDF Specific are talking about different things. In Best Coding Practices, I think it simply means not to initialize all variables at the beginning of your script, meaning if you have functions that will have local variables that won't be used anywhere else, declare them inside those functions. As for the UDF Specific, it is talking about the best consistency for writing a UDF so other people will not get confused. I think UDF guidelines are important because other people may need to modify your UDF for their own needs or may continue or fix a UDF if it is abandoned and never updated. The UDF guide simply states the order and structure in which things should be listed. The best example of a UDF is at the bottom of that page called Template UDF. As for your question about the +, | and - in UDF headers, the Template UDF shows examples of the - and | being used in the tables for Parameters and Return values: ; Parameters ....: $avAnArray - [byref] An array of anything. The value of anything is changed and passed out using this ; parameter. The array should only have one dimension ; $iAnInt - An integer that does very little. ; $hAHandle - [optional] A handle. Default is zero. ; $nSomeNumber - [optional] A number of some kind. Default is 42. ; Return values .: Success - A MYSTRUCT structure. ; Failure - Returns zero and sets the @error flag: ; |1 - The $avAnArray is invalid. As for your third question about the order of things listed in an UDF, look at the Template UDF again and it is consistent with the statements that #Index# comes first, then other sections, which includes the listing of functions and structures immediately after #Index#. The guide probably should have put that section at the top of of the Other Sections, but they did get it correct in the Template UDF. Personally, I wouldn't worry about the UDF stuff until you are good at coding and are ready to write and share UDFs with other people. The best practices are great if you plan to share your code on the forum or if you plan to use your scripts professionally (i.e., at your job), but if you are just scripting for your own use, as Jos said, just code for yourself. For myself, I think the best advice I can give is to write code that isn't sloppy and to make good comments to remind yourself why you did something or what a piece of code does. I have spent a lot of time trying to figure out what my old code did. Just like the help file is an incredible piece of documentation, your comments are also great documentation. I hope this helps. If anything is still unclear, I will try to explain further. Cheers!
    1 point
  15. Just code like you prefer and don't worry about opinions of others.
    1 point
  16. Jos

    A Non-Strict JSON UDF (JSMN)

    Let me know when you are done and we will implement your version.
    1 point
  17. @TheDcoder, Isn't the same true for Compiled script by definition with the encoded script being in the PE header
    0 points
×
×
  • Create New...