Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/13/2015 in all areas

  1. This is a tool I put together to size an ESX cluster based on the VM resource requirements. it's far from perfect and probably bug ridden, but I just wanted to share. Credits to @guiness for his _GUICtrlListView_CreateArray UDF and to @Melba and associated crew for the GUIListViewEx UDF. edit: v0.7 ESX Builder.zip
    2 points
  2. [New Release] - 06 April 2019 Added: Error-checking for sensible column numbers in the $aSortData array, with an additional error status. ------------------------------------------------------------------------------------------------------------------------ While answering a recent question about sorting a ListView on several columns, I developed this function to sort a 2D array on several columns and I though I might give it a wider audience. Here is the function: #include-once ;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 ; #INCLUDES# ========================================================================================================= #include <Array.au3> ; =============================================================================================================================== ; #INDEX# ======================================================================================================================= ; Title .........: ArrayMultiColSort ; AutoIt Version : v3.3.8.1 or higher ; Language ......: English ; Description ...: Sorts 2D arrays on several columns ; Note ..........: ; Author(s) .....: Melba23 ; Remarks .......: ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ; _ArrayMultiColSort : Sort 2D arrays on several columns ; =============================================================================================================================== ; #INTERNAL_USE_ONLY#================================================================================================= ; __AMCS_SortChunk : Sorts array section ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name...........: _ArrayMultiColSort ; Description ...: Sort 2D arrays on several columns ; Syntax.........: _ArrayMultiColSort(ByRef $aArray, $aSortData[, $iStart = 0[, $iEnd = 0]]) ; Parameters ....: $aArray - The 2D array to be sorted ; $aSortData - 2D array holding details of the sort format ; Format: [Column to be sorted, Sort order] ; Sort order can be either numeric (0/1 = ascending/descending) or a ordered string of items ; Any elements not matched in string are left unsorted after all sorted elements ; $iStart - Element of array at which sort starts (default = 0) ; $iEnd - Element of array at which sort endd (default = 0 - converted to end of array) ; Requirement(s).: v3.3.8.1 or higher ; Return values .: Success: No error ; Failure: @error set as follows ; @error = 1 with @extended set as follows (all refer to $sIn_Date): ; 1 = Array to be sorted not 2D ; 2 = Sort data array not 2D ; 3 = More data rows in $aSortData than columns in $aArray ; 4 = Start beyond end of array ; 5 = Start beyond End ; @error = 2 with @extended set as follows: ; 1 = Invalid string parameter in $aSortData ; 2 = Invalid sort direction parameter in $aSortData ; 3 = Invalid column index in $aSortData ; Author ........: Melba23 ; Remarks .......: Columns can be sorted in any order ; Example .......; Yes ; =============================================================================================================================== Func _ArrayMultiColSort(ByRef $aArray, $aSortData, $iStart = 0, $iEnd = 0) ; Errorchecking ; 2D array to be sorted If UBound($aArray, 2) = 0 Then Return SetError(1, 1, "") EndIf ; 2D sort data If UBound($aSortData, 2) <> 2 Then Return SetError(1, 2, "") EndIf If UBound($aSortData) > UBound($aArray) Then Return SetError(1, 3) EndIf For $i = 0 To UBound($aSortData) - 1 If $aSortData[$i][0] < 0 Or $aSortData[$i][0] > UBound($aArray, 2) -1 Then Return SetError(2, 3, "") EndIf Next ; Start element If $iStart < 0 Then $iStart = 0 EndIf If $iStart >= UBound($aArray) - 1 Then Return SetError(1, 4, "") EndIf ; End element If $iEnd <= 0 Or $iEnd >= UBound($aArray) - 1 Then $iEnd = UBound($aArray) - 1 EndIf ; Sanity check If $iEnd <= $iStart Then Return SetError(1, 5, "") EndIf Local $iCurrCol, $iChunk_Start, $iMatchCol ; Sort first column __AMCS_SortChunk($aArray, $aSortData, 0, $aSortData[0][0], $iStart, $iEnd) If @error Then Return SetError(2, @extended, "") EndIf ; Now sort within other columns For $iSortData_Row = 1 To UBound($aSortData) - 1 ; Determine column to sort $iCurrCol = $aSortData[$iSortData_Row][0] ; Create arrays to hold data from previous columns Local $aBaseValue[$iSortData_Row] ; Set base values For $i = 0 To $iSortData_Row - 1 $aBaseValue[$i] = $aArray[$iStart][$aSortData[$i][0]] Next ; Set start of this chunk $iChunk_Start = $iStart ; Now work down through array For $iRow = $iStart + 1 To $iEnd ; Match each column For $k = 0 To $iSortData_Row - 1 $iMatchCol = $aSortData[$k][0] ; See if value in each has changed If $aArray[$iRow][$iMatchCol] <> $aBaseValue[$k] Then ; If so and row has advanced If $iChunk_Start < $iRow - 1 Then ; Sort this chunk __AMCS_SortChunk($aArray, $aSortData, $iSortData_Row, $iCurrCol, $iChunk_Start, $iRow - 1) If @error Then Return SetError(2, @extended, "") EndIf EndIf ; Set new base value $aBaseValue[$k] = $aArray[$iRow][$iMatchCol] ; Set new chunk start $iChunk_Start = $iRow EndIf Next Next ; Sort final section If $iChunk_Start < $iRow - 1 Then __AMCS_SortChunk($aArray, $aSortData, $iSortData_Row, $iCurrCol, $iChunk_Start, $iRow - 1) If @error Then Return SetError(2, @extended, "") EndIf EndIf Next EndFunc ;==>_ArrayMultiColSort ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __AMCS_SortChunk ; Description ...: Sorts array section ; Author ........: Melba23 ; Remarks .......: ; =============================================================================================================================== Func __AMCS_SortChunk(ByRef $aArray, $aSortData, $iRow, $iColumn, $iChunkStart, $iChunkEnd) Local $aSortOrder ; Set default sort direction Local $iSortDirn = 1 ; Need to prefix elements? If IsString($aSortData[$iRow][1]) Then ; Split elements $aSortOrder = StringSplit($aSortData[$iRow][1], ",") If @error Then Return SetError(1, 1, "") EndIf ; Add prefix to each element For $i = $iChunkStart To $iChunkEnd For $j = 1 To $aSortOrder[0] If $aArray[$i][$iColumn] = $aSortOrder[$j] Then $aArray[$i][$iColumn] = StringFormat("%02i-", $j) & $aArray[$i][$iColumn] ExitLoop EndIf Next ; Deal with anything that does not match If $j > $aSortOrder[0] Then $aArray[$i][$iColumn] = StringFormat("%02i-", $j) & $aArray[$i][$iColumn] EndIf Next Else Switch $aSortData[$iRow][1] Case 0, 1 ; Set required sort direction if no list If $aSortData[$iRow][1] Then $iSortDirn = -1 Else $iSortDirn = 1 EndIf Case Else Return SetError(1, 2, "") EndSwitch EndIf ; Sort the chunk Local $iSubMax = UBound($aArray, 2) - 1 __ArrayQuickSort2D($aArray, $iSortDirn, $iChunkStart, $iChunkEnd, $iColumn, $iSubMax) ; Remove any prefixes If IsString($aSortData[$iRow][1]) Then For $i = $iChunkStart To $iChunkEnd $aArray[$i][$iColumn] = StringTrimLeft($aArray[$i][$iColumn], 3) Next EndIf EndFunc ;==>__AMCS_SortChunk And here is an example to show it working: #include "ArrayMultiColSort.au3" #include <String.au3> ; Only used to fill array ; Create and display array Global $aArray[100][4] For $i = 0 To 99 $aArray[$i][0] = _StringRepeat(Chr(Random(65, 68, 1)), 5) $aArray[$i][1] = _StringRepeat(Chr(Random(74, 77, 1)), 5) $aArray[$i][2] = _StringRepeat(Chr(Random(80, 83, 1)), 5) $aArray[$i][3] = _StringRepeat(Chr(Random(87, 90, 1)), 5) Next _ArrayDisplay($aArray, "Unsorted") ; Copy arrays for separate examples below $aArray_1 = $aArray $aArray_2 = $aArray ; This sorts columns in ascending order - probably the most common requirement ; Sort requirement: ; Col 0 = Decending ; Col 1 = Ascending ; Col 2 = Required order of elements (note not alphabetic PQRS nor reverse SRQP) ; Col 3 = Ascending Global $aSortData[][] = [ _ [0, 1], _ [1, 0], _ [2, "SSSSS,QQQQQ,PPPPP,RRRRR"], _ [3, 0]] ; Sort and display array _ArrayMultiColSort($aArray_1, $aSortData) ; Display any errors encountered If @error Then ConsoleWrite("Oops: " & @error & " - " & @extended & @CRLF) _ArrayDisplay($aArray_1, "Sorted in order 0-1-2-3") ; But the UDF can sort columns in any order ; Sort requirement: ; Col 2 = Decending ; Col 0 = Ascending Global $aSortData[][] = [ _ [2, 1], _ [0, 0]] ; Sort and display array _ArrayMultiColSort($aArray_2, $aSortData) ; Display any errors encountered If @error Then ConsoleWrite("Oops: " & @error & " - " & @extended & @CRLF) _ArrayDisplay($aArray_2, "Sorted in order 2-0") And here are both in zip form: ArrayMultiColSort.zip As usual all comments welcome. M23
    1 point
  3. wakillon

    FavIcons Screensaver

    A little Screensaver based on FavIcons Like this screenshot Most websites use 16x16 Icons, so for a better display i used only those who have a 32x32 format. Thanks to : Ward for his BinaryCall UDF ( for call in memory lzma.dll and titchisid.dll ) and trancexx for his ResourcesViewerAndCompiler ( for create the huge icons resource dll ) If you have some time to loose, you can get files in the Download Section Edit 1 : Config is available via right click on compiled version. Edit 2 : Last version do not use lzma.dll and icons resource dll but an ImageList from a jpg for store the 730 "icons"
    1 point
  4. Released 0.3 Stable Fixed https://github.com/minxomat/AutoIt-OOP-Extender/issues/2Fixed https://github.com/minxomat/AutoIt-OOP-Extender/issues/3Fixed https://github.com/minxomat/AutoIt-OOP-Extender/issues/4Fixed https://www.autoitscript.com/forum/topic/178542-oop-extender-real-object-oriented-programming-with-autoit/?do=findComment&comment=1281714 ( @Chimp )Fixed https://www.autoitscript.com/forum/topic/178542-oop-extender-v03-stable-real-object-oriented-programming-with-autoit/?do=findComment&comment=1281433 ( @JohnOne )Fixed a bunch of unreported issuesImplemented C-style macrosThis release is not compatible with older releases. Please read all tutorials (updated links are in the first post) to understand the changes and new features .
    1 point
  5. I would keep on beating till it works properly and returning a 1 as you have no means to check success now. You obviously can't open a filename with a wildcard, so need to use FileFindFirstFile/FileFindNextFile to retrieve the full filename first after which you can open it. Jos
    1 point
  6. alexandruc

    GuiCtrlRead issue?

    If (GuiCtrlRead($GIDTechInput)) OR (GUICtrlRead($PassInput)) = "" ThenYour script evaluates the if and since it does read the input (GuiCtrlRead($GIDTechInput)) it returns true and the popup appears. just use: $GIDTechInput = GuiCtrlRead($GIDTechInput) $PassInput = GuiCtrlRead($PassInput) If $PassInput = "" OR $GIDTechInput = "" Then ... EndIFor If (GuiCtrlRead($GIDTechInput)) = "" OR (GUICtrlRead($PassInput)) = "" Thensorry, haven't noticed Melba23 answered already...
    1 point
  7. Melba23

    GuiCtrlRead issue?

    31290, Your comparison statement is wrong - you need to check the contents of both inputs separately: If (GuiCtrlRead($GIDTechInput) = "") OR (GUICtrlRead($PassInput) = "") Then M23
    1 point
  8. You are right BrewManNH, and thanks for your advice. This is what I was starting to do yesterday, writing my own "_GetTextSize()" function (of course based on several lecture from AutoiT forum - ) -> and it works not so bad : #include <GDIPlus.au3> #include <GUIImageList.au3> #include <GUIConstants.au3> #include <FontConstants.au3> #include <GuiButton.au3> local $hgui = GUICreate("Radio Button", 600, 300) local $xleft = 10, $ytop = 20 Local $sText = "0123456789 blablaplaplaplablabla ABCDEFGH" ; Local $sFont = "Comic Sans MS" local $FontName = "Arial" local $iFontStyle = 0x00000000 ; 0 - Normal weight or thickness of the typeface ; 1 - Bold typeface ; 2 - Italic typeface ; 4 - Underline ; 8 - Strikethrough local $fFontSize = 8 ; ; Note: curiously, the "GUISetFont" and the "_GDIPlus_FontCreate" commands do not use the same logic for the "bold" type ! ; Please compare "weight"+"attribute" to "iStyle", and adapt correctly ; GUISetFont($fFontSize, $FW_NORMAL, $GUI_FONTNORMAL, $FontName) ; The weight of the font in the range 0 through 1000. For example, 400 is normal and 700 is bold. If this value is zero, a default weight is used. ; The following values are defined for convenience. ; $FW_DONTCARE = 0 (Use the default font weight) ; $FW_THIN = 100 ; $FW_EXTRALIGHT = 200 ; $FW_LIGHT = 300 ; $FW_NORMAL = 400 ; $FW_MEDIUM = 500 ; $FW_SEMIBOLD = 600 ; $FW_BOLD = 700 ; $FW_EXTRABOLD = 800 ; $FW_HEAVY = 900 Local $Button1 = GUICtrlCreateRadio($sText, $xleft, $ytop) Local $HandleButton1 = GUICtrlGetHandle($Button1) ; Local $tRectF = _GetTextSize($HandleButton1, $sText, $FontName, $iFontStyle, $fFontSize) Local $RealWidth = Ceiling(DllStructGetData($tRectF, "Width")) Local $RealHeight = Ceiling(DllStructGetData($tRectF, "Height")) ConsoleWrite("! Button1 (method 1) - Ideal width: " & $RealWidth & " height: " & $RealHeight & @CRLF) GUICtrlSetPos($Button1, $xleft, $ytop, $RealWidth, $RealHeight) GUICtrlSetBkColor(-1, $COLOR_RED) ; just to check the control rectangle expansion ! Local $aIdealSize = _GUICtrlButton_GetIdealSize($Button1) ConsoleWrite("! Button1 (method 2) - Ideal width: " & $aIdealSize[0] & " height: " & $aIdealSize[1] & @crlf) ; $ytop += 20 + $RealHeight ; $FontName = "arial" $iFontStyle = 0x00000000 $fFontSize = 12 GUISetFont($fFontSize, $FW_NORMAL, $GUI_FONTNORMAL, $FontName) Local $Button2 = GUICtrlCreateRadio($sText, $xleft, $ytop) Local $HandleButton2 = GUICtrlGetHandle($Button2) $tRectF = _GetTextSize($HandleButton2, $sText, $FontName, $iFontStyle, $fFontSize) $RealWidth = Ceiling(DllStructGetData($tRectF, "Width")) $RealHeight = Ceiling(DllStructGetData($tRectF, "Height")) ConsoleWrite("! Button2 (method 1) - Ideal width: " & $RealWidth & " height: " & $RealHeight & @CRLF) GUICtrlSetPos($Button2, $xleft, $ytop, $RealWidth, $RealHeight) GUICtrlSetBkColor(-1, $COLOR_RED) ; just to check the control rectangle expansion ! ; $ytop += 20 + $RealHeight ; $FontName = "Comic Sans MS" $fFontSize = 14 GUISetFont($fFontSize, $FW_BOLD, $GUI_FONTNORMAL, $FontName) Local $Button3 = GUICtrlCreateRadio($sText, $xleft, $ytop) ; _GUICtrlButton_SetImageList($Button3, $hImage) $aIdealSize = _GUICtrlButton_GetIdealSize($Button3) ConsoleWrite("! Button3 (method 2) - Ideal width: " & $aIdealSize[0] & " height: " & $aIdealSize[1] & @crlf) _GUICtrlButton_SetSize($Button3, $aIdealSize[0], $aIdealSize[1]) GUICtrlSetBkColor(-1, $COLOR_RED) ; just to check the control rectangle expansion ! ; GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg ; ********************************************************************** Case $GUI_EVENT_CLOSE ; Exit GUIDelete($hgui) Exit EndSwitch WEnd ; ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo Func _GetTextSize($CtrlHandle, $sText, $sFontName, $iStyle, $fSize) _GDIPlus_Startup() Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($CtrlHandle) Local $hFormat = _GDIPlus_StringFormatCreate() Local $hFamily = _GDIPlus_FontFamilyCreate($sFontName) Local $hFont = _GDIPlus_FontCreate($hFamily, $fSize, $iStyle) Local $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0) Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic , $sText, $hFont, $tLayout, $hFormat) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_GraphicsDispose($hGraphic ) _GDIPlus_Shutdown() If IsArray($aInfo ) then return $aInfo [0] else return setError(0, 0, -1) endif Endfunc ; _GetTextSize ; oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo But, finally, exploring the AutoIt help, I discover these functions which are better : "_GUICtrlButton_GetIdealSize()" and "_GUICtrlButton_SetIdealSize()". So I think that a link to them into the "GUICtrlCreateRadio" presentation (https://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateRadio.htm) would be welcome. Anyhow, thanks to everybody for your help. (This post could be closed.) Alain.
    1 point
×
×
  • Create New...