Leaderboard
Popular Content
Showing content with the highest reputation on 06/09/2024 in all areas
-
This script allows you to 'browse' an array and view it's content. It's similar to the _ArrayDisplay() command, but this one has no limit on the number of dimensions. Nested array (array of arrays) are also allowed. (I'm been inspired by this @JohnOne's Post) Since multidimensional arrays can be considered as many bidimensional arrays grouped toghether, with this script you can view any of the many 2d arrays by selecting the dimension (the sheet number) you want to see through the ComboBoxes located at the top of the viewed sheet. regarding the arrays of array, if are present, those are listed on the treeview on the left side, where you can see their locations within the tree, and easily selected to be as well browsed by a click. I'm aware that there is a wide margin of aesthetic improvement, anyway the basic functionality works quite well. I hope it can be usefull ; Func _ArrayView() ; Will display content of arrays of any dimension, and even nested arrays if any ; #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <GUITreeView.au3> #include <GUIScrollBars.au3> #include <ScrollBarConstants.au3> #include <ComboConstants.au3> #include <GuiStatusBar.au3> ; -- build an example array (somewhat chaotic.. just to show something) -- ; 4D array (main array) Local $aA[10][5][6][3] For $d1 = 0 To 9 For $d2 = 0 To 4 For $d3 = 0 To 5 For $d4 = 0 To 2 $aA[$d1][$d2][$d3][$d4] = $d1 & "." & $d2 & "." & $d3 & "." & $d4 Next Next Next Next ; some 1D arrays with multi nested arrays Local $aMonths1 = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] Local $aMonths2 = ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember", $aMonths1] Local $aMonths3 = ["Sijecanj", "veljaca", "ožujka", "travanj", "Svibanj", "lipanj", "srpanj", "kolovoz", "rujan", "listopad", "studeni", "prosinac", $aMonths2] Local $aMonths4 = ["Janvier", "Février", "Mars", "Avril", "mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre", $aMonths3] Local $aMonths5 = ['Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'giu', 'Luglio', 'Agosto', 'Settembre', 'ottobre', 'Novembre', 'Dicembre', $aMonths4] Local $aMonths = ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember", $aMonths5] ; a simple 2D array Local $aWeekdays = [['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'], _ ['Lunedì', 'martedì', 'mercoledì', 'giovedì', 'venerdì', 'sabato', 'domenica'], _ ['Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche'], _ ['Måndag', 'tisdag', 'onsdag', 'torsdag', 'fredag', 'lördag', 'söndag'], _ ['Poniedziałek', 'Wtorek', 'Środa', 'Czwartek', 'Piątek', 'Sobota', 'Niedziela'], _ ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag']] ; array $aMonths goes in cell [5][3] dimension [0][0] of main array $aA[5][3][0][0] = $aMonths ; array $aWeekdays goes in cell [6][3] dimension [0][0] of main array $aA[6][3][0][0] = $aWeekdays $aWeekdays[1][1] = $aWeekdays ; self nest $aWeekdays in cell [1][1] $aA[9][4][0][1] = $aWeekdays ; new $aWeekdays goes in cel [9][4] dimension [0][1] of main array _ArrayView($aA) ; show main array ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ArrayView ; Description ...: Allows to view content of amono or multidimensional array. Array of arrays are also allowed ; Syntax ........: _ArrayView(Byref $_aInput) ; Parameters ....: $_aInput - The array that you want to 'Browse' ; Return values .: on success returns 1 ; on faillure returns 0 and set @Error to 1 (passed argument is not an array) ; Author ........: @Chimp ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _ArrayView(ByRef $_aInput) If Not IsArray($_aInput) Then Return SetError(1, 0, 0) ; if error set @Error and return 0 Local $iGUIwidth = 900 Local $iGUIheight = 600 Local $iTreeWidth = 150 Local $iCombosZone = 60 Local $hGui = GUICreate("Array viewer", $iGUIwidth, $iGUIheight) Local $StatusBar = _GUICtrlStatusBar_Create($hGui), $iStatusBarheight = 23 Local $aSubscripts[64][4] ; It holds IDs of controls ; - creates all ComboBox in an embedded window. All controls are hidden at startup. ; - Only the necessary combo will be shown at run time. One combo for each dimension Local $hSubscriptSelectors = GUICreate('', $iGUIwidth - $iTreeWidth - 6, $iCombosZone - 2, $iTreeWidth + 4, 2, BitOR($WS_CHILD, $WS_HSCROLL), -1, $hGui) ; GUISetBkColor(0xEEFFEE) For $i = 0 To 63 ; Create the labels $aSubscripts[$i][0] = GUICtrlCreateLabel('D' & $i + 1, ($i * 60) + 8, 1) GUICtrlSetFont(-1, 10, 0, 0, "Courier new") GUICtrlSetState(-1, $GUI_HIDE) ; Labels will be hidden at startup. $aSubscripts[$i][1] = GUICtrlCreateLabel('[', ($i * 60), 18) GUICtrlSetFont(-1, 13, 800) GUICtrlSetState(-1, $GUI_HIDE) $aSubscripts[$i][3] = GUICtrlCreateLabel(']', ($i * 60) + 50, 18) GUICtrlSetFont(-1, 13, 800) GUICtrlSetState(-1, $GUI_HIDE) Next For $i = 0 To 63 ; Create the ComboBox (creates separatelly from labels so that ControlIDs of ComboBaxes has it's own sequence) GUICtrlSetState(-1, $GUI_HIDE) ; ComboBox will be hidden at startup. If $i < 2 Then ; all the content of the first 2 dimensions is already shown in the listview (no need of ComboBox) $aSubscripts[$i][2] = GUICtrlCreateCombo("---", ($i * 60) + 8, 17, 40, -1, $CBS_DROPDOWNLIST) GUICtrlSetState(-1, $GUI_DISABLE) Else $aSubscripts[$i][2] = GUICtrlCreateCombo("0", ($i * 60) + 8, 17, 40, -1, $CBS_DROPDOWNLIST) EndIf GUICtrlSetFont(-1, 8, 800) GUICtrlSetState(-1, $GUI_HIDE) ; ComboBox hidden at startup. Next GUISwitch($hGui) ; back to main window ; Create the TreeView structure $hTree = GUICtrlCreateTreeView(2, 2, $iTreeWidth - 2, $iGUIheight - 4 - $iStatusBarheight, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE) Local $hRoot = _GUICtrlTreeView_Add($hTree, 0, "Root") ; first insert the root key in treeview _ArrayTraverse($_aInput, $hTree, $hRoot) ; Search for SubArrays (array in array) ; Create the ListView Local $idListview = GUICtrlCreateListView('', $iTreeWidth + 2, $iCombosZone + 2, $iGUIwidth - $iTreeWidth - 4, $iGUIheight - $iCombosZone - 4 - $iStatusBarheight, Default, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_GRIDLINES)) ; If Array has many dimensions, and so all ComboBoxes doesn't fit in window, this allows to scroll GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL") _GUIScrollBars_Init($hSubscriptSelectors, 60 * UBound($_aInput, 0), 0) GUISetState(@SW_SHOW, $hGui) GUISetState(@SW_SHOW, $hSubscriptSelectors) ; Main Loop until the user exits. ; ------------------------------- Local $sLastWholeKey, $sWholeKey, $vContent, $bRebuild While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE GUIDelete($hGui) ExitLoop Case $aSubscripts[2][2] To $aSubscripts[63][2] ; some ComboBox has changed _ArrayDisplayByLayer($vContent, $idListview, $aSubscripts, False) EndSwitch ; $sWholeKey = _GUICtrlTreeView_GetTree($hTree, _GUICtrlTreeView_GetSelection($hTree)) If $sLastWholeKey <> $sWholeKey Then ; clicked on a new KeyPath or (again) on the one already selected? GUISetCursor(15, 1) ; set cursor to "wait" ; Adapt the TreePath to the array access syntax $sElement = _TreePathParser($sWholeKey) ; address of main array or subarray to peek _GUICtrlStatusBar_SetText($StatusBar, StringReplace($sWholeKey, '|', '->') & ' --> ' & $sElement) ; show the 'address' of selected element on statusbar $vContent = Execute(_TreePathParser($sWholeKey)) _ArrayDisplayByLayer($vContent, $idListview, $aSubscripts, True) _GUICtrlTreeView_ClickItem($hTree, _GUICtrlTreeView_GetSelection($hTree)) $sLastWholeKey = $sWholeKey ; keep track of already clicked KeyPath so we will not redraw the same Array if clicked again GUISetCursor() ; cursor back to default EndIf ; WEnd Return SetError(0, 0, 1) ; if no errors return 1 EndFunc ;==>_ArrayView Func _ArrayDisplayByLayer(ByRef $_aInput, ByRef $idListview, ByRef $aSubscripts, $bRebuild = False) Opt('GUIOnEventMode', 1) ; Disable GUIGetMsg() so is not fired while redrawing ComboBoxes. Local $sTarghet = '$_aInput[$y]' Local $iDimensions = UBound($_aInput, 0) Local $iRows = UBound($_aInput, 1) Local $iColumnsCount, $iColumns = UBound($_aInput, 2) Local $sSubscripts = '' ; Clear the ListView _GUICtrlListView_DeleteAllItems($idListview) If $bRebuild Then ; (Re)Create the ListView $iColumnsCount = _GUICtrlListView_GetColumnCount($idListview) If $iColumnsCount Then For $i = $iColumnsCount To 1 Step -1 _GUICtrlListView_DeleteColumn($idListview, $i - 1) Next EndIf ; Hide and clear all ComboBox For $i = 0 To 63 GUICtrlSetState($aSubscripts[$i][0], $GUI_HIDE) ; Header GUICtrlSetState($aSubscripts[$i][1], $GUI_HIDE) ; '[' GUICtrlSetState($aSubscripts[$i][2], $GUI_HIDE) ; ComboBox Handle GUICtrlSetData($aSubscripts[$i][2], '') ; clear ComboBox items GUICtrlSetState($aSubscripts[$i][3], $GUI_HIDE) ; ']' Next ; (Re)Build the ListView's frame If $iDimensions = 1 Then $iColumns = 1 Else $iColumns = UBound($_aInput, 2) ; nr. of columns in the ListView (second dimension) $sTarghet &= '[$x]' EndIf _GUICtrlListView_AddColumn($idListview, 'Row') For $i = 1 To $iColumns _GUICtrlListView_AddColumn($idListview, 'Col ' & $i - 1, 100) Next For $i = 0 To $iDimensions - 1 ; Show only necessary ComboBox (one for each dimension) GUICtrlSetState($aSubscripts[$i][0], $GUI_SHOW) ; Header GUICtrlSetState($aSubscripts[$i][1], $GUI_SHOW) ; '[' GUICtrlSetState($aSubscripts[$i][2], $GUI_SHOW) ; ComboBox Handle GUICtrlSetState($aSubscripts[$i][3], $GUI_SHOW) ; ']' If $i > 1 Then $sTarghet &= '[0]' ; dimensions over the second all setting to 0 (begin showing first lyer) $sSubscripts = "" For $iSubscript = 0 To UBound($_aInput, $i + 1) - 1 $sSubscripts &= $iSubscript & '|' Next GUICtrlSetData($aSubscripts[$i][2], StringTrimRight($sSubscripts, 1)) ControlFocus('', '', $aSubscripts[$i][2]) ControlSend('', '', $aSubscripts[$i][2], 0) EndIf Next Else ; Just refill the listview with data from the Array dimension selected by ComboBoxes ; Create the 'dimension' string $sTarghet &= '[$x]' For $i = 2 To $iDimensions - 1 $sTarghet &= '[' & GUICtrlRead($aSubscripts[$i][2]) & ']' Next $iColumns = UBound($_aInput, 2) EndIf For $y = 0 To $iRows - 1 GUICtrlCreateListViewItem('', $idListview) _GUICtrlListView_SetItemText($idListview, $y, '[' & $y & ']', 0) ; row number For $x = 0 To $iColumns - 1 $vCellContent = Execute($sTarghet) If IsArray($vCellContent) Then _GUICtrlListView_SetItemText($idListview, $y, '{array}', $x + 1) Else _GUICtrlListView_SetItemText($idListview, $y, $vCellContent, $x + 1) EndIf Next Next Opt('GUIOnEventMode', 0) ; reenable GUIGetMsg() EndFunc ;==>_ArrayDisplayByLayer Func _ArrayTraverse(ByRef $aMyArray, ByRef $hTree, $hParent) #cs since this is a recursive Function, the same Func runs many times, self called from within itself. The variables declared as Global at the top of the script are able to be accessed from any instance of the function, whereas the variable declared (as Local) within the function may be different for each instance of the function. #ce If Not IsArray($aMyArray) Then Return SetError(1, 0, -1) ; we have to know how many nested for-next loops we need ; that is one loop for each dimension Local $iDimensions = UBound($aMyArray, 0) ; number of nested for-next loops Local $sArrayPointer = "$aMyArray", $sElement For $i = 0 To $iDimensions - 1 $sArrayPointer &= '[$aLoops[' & $i & '][2]]' Next ; ----------------------------------------------------------------------------------- ; This is a nested For-Next loops simulator with variable depth of nested loops ; pass a 2D zero based array[n][3] ; with as many records as nested loops needed ; as following: ; ; Example; For $i = start To end ; ----- --- ; [n][0] = Start value ; [n][1] = End value ; [n][2] = actual loop counter (at startup is = to Start value [n][0]) ; ; --- Initializes custom nested For-Next loops -------------------------------------- Local $aLoops[$iDimensions][3] ; nr of nested loops is $iDimensions For $i = 0 To $iDimensions - 1 $aLoops[$i][0] = 0 ; Start value $aLoops[$i][1] = UBound($aMyArray, $i + 1) - 1 ; End value $aLoops[$i][2] = $aLoops[$i][0] ; actual loop counter Next ; ----------------------------------------------------------------------------------- Local $x, $vContent Do $vContent = Execute($sArrayPointer) If IsArray($vContent) Then ; here there is a Nested array, populate the TreeView with a child element $sElement = "" For $i = 0 To $iDimensions - 1 $sElement &= '[' & $aLoops[$i][2] & ']' Next Local $hNode = _GUICtrlTreeView_AddChild($hTree, $hParent, $sElement) ; recursive call for this nested array to search if there are any further nested arrays _ArrayTraverse($vContent, $hTree, $hNode) ; <-- recursive call EndIf ; ------------------------------------------------------------------------------- $x = UBound($aLoops) - 1 $aLoops[$x][2] += 1 While ($aLoops[$x][2] > $aLoops[$x][1]) ; check if and which nested loops are out of bound $aLoops[$x][2] = $aLoops[$x][0] ; reset the counter of this loop ($x) $x -= 1 ; check next outer nest If $x < 0 Then ExitLoop ; if we have finished all nested loops then Exit $aLoops[$x][2] += 1 ; when a deeper loop complete, increment the outer one WEnd Until $x < 0 ; If no more nested loops then exit EndFunc ;==>_ArrayTraverse ; Tree Path to Subscript Func _TreePathParser($Input) Local $sReturn = '$_aInput' Local $aSubArrays = StringSplit($Input, '|', 3) If UBound($aSubArrays) > 1 Then For $i = 1 To UBound($aSubArrays) - 1 $sReturn &= $aSubArrays[$i] If $i < UBound($aSubArrays) - 1 Then $sReturn = '(' & $sReturn & ')' Next EndIf Return $sReturn EndFunc ;==>_TreePathParser ; this will allow the scrolling of window containing ComboBoxes (if number of Combo doesn't fit in window) ; see _GUIScrollBars_Init() in the Help of AutoIt Func WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $iScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $iCharX, $iPosX Local $iMin, $iMax, $iPage, $iPos, $iTrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $iCharX = $__g_aSB_WindowInfo[$iIndex][2] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 ; ; Get all the horizontal scroll bar information Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $iMin = DllStructGetData($tSCROLLINFO, "nMin") $iMax = DllStructGetData($tSCROLLINFO, "nMax") $iPage = DllStructGetData($tSCROLLINFO, "nPage") ; Save the position for comparison later on $iPosX = DllStructGetData($tSCROLLINFO, "nPos") $iPos = $iPosX $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") #forceref $iMin, $iMax Switch $iScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos) EndSwitch ; // Set the position and then retrieve it. Due to adjustments ; // by Windows it may not be the same as the value set. DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) ;// If the position has changed, scroll the window and update it $iPos = DllStructGetData($tSCROLLINFO, "nPos") If ($iPos <> $iPosX) Then _GUIScrollBars_ScrollWindow($hWnd, $iCharX * ($iPosX - $iPos), 0) Return $GUI_RUNDEFMSG EndFunc ;==>WM_HSCROLL3 points
-
Here one solution, maybe ? #include <GuiEdit.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPIGdi.au3> #include <FontConstants.au3> #include <WinAPIShPath.au3> Opt("GUIOnEventMode", 1) Local $sLongString = _ 'One after one, by the star-dogged Moon, ' & _ 'Too quick for groan or sigh, ' & _ 'Each turned his face with a ghastly pang, ' & _ 'And cursed me with his eye. ' & _ 'Four times fifty living men, ' & _ '(And I heard nor sigh nor groan) ' & _ 'With heavy thump, a lifeless lump, ' & _ 'They dropped down one by one.' Local $sLongString1 = _ 'https://sso.microsoft.com/adfs/ls/idpinitiatedsignon.aspx?' & _ 'LoginToRP=https://www.microsoft.com/en-gb/microsoft-365/' & _ 'small-business-resource-center&client-request-id=5648b446' & _ '-4e0b-4116-7e37-0080000000e5&pullStatus=0||4' Local $sLongString2 = _ ; fits perfect 'STARTOFSTRINGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' & _ 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' & _ 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' & _ 'XXXXXXXXXXXXXXXXXXXXXXENDOFSTRING' Local $h_GUI = GUICreate("Compact String Example", 350, 150) Local $idString_lbl = GUICtrlCreateLabel('', 10, 10, 327, 21, -1, $WS_EX_CLIENTEDGE) GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif") GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetState() GUICtrlSetData($idString_lbl, _GetLabelMaxString($idString_lbl, $sLongString)) While 1 Sleep(100) WEnd Func _Exit() Exit EndFunc ;==>_Exit Func _GetControlFontSettings($idLabel) Local $aiFont[3] = [0, 0, 0] Local $hFont = GUICtrlSendMsg($idLabel, $WM_GETFONT, 0, 0) ; handle for control retrieved If Not $hFont Then Return SetError(1, @error, $aiFont) Local $tFont = DllStructCreate("int;int;int;int;int;byte;byte;byte;byte;byte;byte;byte;byte;char[32]") If @error Then Return SetError(2, @error, $aiFont) If Not _WinAPI_GetObject($hFont, DllStructGetSize($tFont), DllStructGetPtr($tFont)) Then Return SetError(3, @error, $aiFont) $aiFont[0] = DllStructGetData($tFont, 1) ; lfHeight $aiFont[1] = DllStructGetData($tFont, 5) ; lfWeight $aiFont[2] = DllStructGetData($tFont, 14) ; lfFaceName Return $aiFont EndFunc ;==>_GetControlFontSettings Func _GetLabelMaxString($idLabel, $sString) Local $aiFont = _GetControlFontSettings($idLabel) Local $hDC = _WinAPI_GetDC(GUICtrlGetHandle($idLabel)) Local $hFont = _WinAPI_CreateFont($aiFont[0], 0, 0, 0, $aiFont[1], False, False, False, $DEFAULT_CHARSET, _ $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, $DEFAULT_PITCH, $aiFont[2]) _WinAPI_SelectObject($hDC, $hFont) Local $aPos = ControlGetPos(WinGetHandle("[ACTIVE]"), '', $idLabel), $tSize For $i = 1 To StringLen($sString) $tSize = _WinAPI_GetTextExtentPoint32($hDC, StringLeft($sString, $i) & "..." & StringRight($sString, $i)) If $tSize.X > $aPos[2] Then ExitLoop Next If $i < stringlen($sString) then $sString = StringLeft($sString, $i-2) & "..." & StringRight($sString, $i-2) _WinAPI_ReleaseDC(0, $hDC) _WinAPI_DeleteObject($hFont) Return $sString EndFunc ;==>_GetLabelMaxChars2 points
-
Drag and drop items (labels) vertically among themselves
argumentum and one other reacted to ioa747 for a topic
Here is the better and smaller version ; https://www.autoitscript.com/forum/topic/211959-drag-and-drop-items-labels-vertically-among-themselves/?do=findComment&comment=1534576 #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <StaticConstants.au3> #include <WinAPIGdi.au3> #include <Array.au3> Global $iStart = 70, $iSpace = 5, $iLeft = 20, $iLabelHeight = 50 Global $hGUI = GUICreate('Dragging items vertically (this is a draft)', 500, ($iLabelHeight + $iSpace) * 12) GUISetBkColor(0x00FF00) ; background color is green Global $aLabel[10][2] $aLabel[0][0] = 9 ;NumOfLabels For $i = 1 To $aLabel[0][0] ;Creating test items (labels) $aLabel[$i][1] = (($iLabelHeight + $iSpace) * ($i - 1)) + $iStart $aLabel[$i][0] = GUICtrlCreateLabel("Label " & $i, $iLeft, $aLabel[$i][1], 460, $iLabelHeight, BitOR($SS_SUNKEN, $SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFF0000) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetFont(-1, 14, 700, 'Tahoma') Next GUISetState(@SW_SHOW, $hGUI) ;********************************** While 1 Switch GUIGetMsg() Case -3 ;$GUI_EVENT_CLOSE ExitLoop EndSwitch _IsDragging() Sleep(10) WEnd ;********************************** Exit ;-------------------------------------------------------------------------------------------------------------------------------- Func _IsDragging() Local Static $iOffset = Int($iLabelHeight / 2) If Not WinActive($hGUI) Then Return SetError(1, 0, False) Local $aCtrl = GUIGetCursorInfo($hGUI) If Not $aCtrl[2] Then Return SetError(2, 0, False) Local $ActiveCtrl = Null For $i = 1 To $aLabel[0][0] If $aLabel[$i][0] = $aCtrl[4] Then $ActiveCtrl = $aCtrl[4] EndIf Next If $ActiveCtrl = Null Then Return SetError(3, 0, False) Opt("MouseCoordMode", 2) ;1=absolute, 0=relative, 2=client Local $iCursorId = MouseGetCursor() GUISetCursor(11, 1, $hGUI) GUICtrlSetBkColor($ActiveCtrl, 0xCC0000) ;0xFF0000 Do $aCtrl = GUIGetCursorInfo($hGUI) ControlMove($hGUI, '', $ActiveCtrl, Default, MouseGetPos(1) - $iOffset) ;Reposition of Labels _ArraySort($aLabel, 0, 1, 0, 1) For $i = 1 To $aLabel[0][0] If $aLabel[$i][0] = $ActiveCtrl Then $aLabel[$i][1] = MouseGetPos(1) - $iOffset ContinueLoop EndIf $aLabel[$i][1] = (($iLabelHeight + $iSpace) * ($i - 1)) + $iStart GUICtrlSetPos($aLabel[$i][0], $iLeft, $aLabel[$i][1]) Next Sleep(10) Until Not $aCtrl[2] Opt("MouseCoordMode", 1) ;1=absolute, 0=relative, 2=client GUISetCursor($iCursorId, 1, $hGUI) GUICtrlSetBkColor($ActiveCtrl, 0xFF0000) For $i = 1 To $aLabel[0][0] $aLabel[$i][1] = (($iLabelHeight + $iSpace) * ($i - 1)) + $iStart GUICtrlSetPos($aLabel[$i][0], $iLeft, $aLabel[$i][1]) Next _WinAPI_RedrawWindow($hGUI) EndFunc ;==>_IsDragging ;--------------------------------------------------------------------------------------------------------------------------------2 points -
Control Viewer (mod.)
robertocm reacted to argumentum for a file
Version 0.2024.9.16
5,357 downloads
This is @Yashied's most excellent control viewer, modified by me, based on the code @boomingranny posted. There are 2 forum entries, one shows active and the other depreciated, and not seen @Yashied since March 2016, so I feel is OK to post this, tho, i'd take it down upon request. PS: Do run as Admin if available, as it may not do what you need without the rights.1 point -
That works a lot more consistently than mine. Nice . There's still a minor issue with certain strings and font properties but I'll take it (see code below). Thanks. I combined the two remaining functions into 1 as well. #include <GuiEdit.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPIGdi.au3> #include <FontConstants.au3> Opt("GUIOnEventMode", 1) Local $sLongString = _ 'One after one, by the star-dogged Moon, ' & _ 'Too quick for groan or sigh, ' & _ 'Each turned his face with a ghastly pang, ' & _ 'And cursed me with his eye. ' & _ 'Four times fifty living men, ' & _ '(And I heard nor sigh nor groan) ' & _ 'With heavy thump, a lifeless lump, ' & _ 'They dropped down one by one.' Local $sLongString1 = _ 'https://sso.microsoft.com/adfs/ls/idpinitiatedsignon.aspx?' & _ 'LoginToRP=https://www.microsoft.com/en-gb/microsoft-365/' & _ 'small-business-resource-center&client-request-id=5648b446' & _ '-4e0b-4116-7e37-0080000000e5&pullStatus=0||4' Local $sLongString2 = _ ; fits perfect 'STARTOFSTRINGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' & _ 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' & _ 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' & _ 'XXXXXXXXXXXXXXXXXXXXXXENDOFSTRING' Local $h_GUI = GUICreate("Compact String Example", 350, 150) Local $idString_lbl = GUICtrlCreateLabel('', 10, 10, 327, 21, -1, $WS_EX_CLIENTEDGE) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetState() GUICtrlSetData($idString_lbl, _StringFitToLabel($idString_lbl, $sLongString2)) While 1 Sleep(100) WEnd Func _Exit() Exit EndFunc ;==>_Exit Func _StringFitToLabel($idLabel, $sString, $hGui) Local Enum _ $FONTHIEGHT, _ $FONTWEIGHT, _ $FONTFACENAME Local $aiFont[3] = _ [1, _ ;_ lfHeight 5, _ ;_ lfWeight 14] ;_ lfFaceName Local $hFont = GUICtrlSendMsg($idLabel, $WM_GETFONT, 0, 0) ; handle for control retrieved If Not $hFont Then Return SetError(1, @error, $sString) Local $tFont = DllStructCreate("int;int;int;int;int;byte;byte;byte;byte;byte;byte;byte;byte;char[32]") If @error Then Return SetError(2, @error, $sString) If Not _WinAPI_GetObject($hFont, DllStructGetSize($tFont), DllStructGetPtr($tFont)) Then Return SetError(3, 0, $sString) ; load the array For $i = 0 To UBound($aiFont) - 1 $aiFont[$i] = DllStructGetData($tFont, $aiFont[$i]) Next Local $hDC = _WinAPI_GetDC(GUICtrlGetHandle($idLabel)) If Not $hDC Then Return SetError(4, 0, $sString) Local $hFont = _WinAPI_CreateFont($aiFont[$FONTHIEGHT], 0, 0, 0, $aiFont[$FONTWEIGHT], False, False, False, $DEFAULT_CHARSET, _ $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, $DEFAULT_PITCH, $aiFont[$FONTFACENAME]) If Not $hFont Then Return SetError(5, 0, $sString) If _WinAPI_SelectObject($hDC, $hFont) <= 0 Then Return SetError(6, 0, $sString) Local $aPos = ControlGetPos(hGui, '', $idLabel), $tSize For $i = 1 To StringLen($sString) $tSize = _WinAPI_GetTextExtentPoint32($hDC, StringLeft($sString, $i) & "..." & StringRight($sString, $i)) If $tSize.X > $aPos[2] Then ExitLoop Next If $i < StringLen($sString) Then $sString = StringLeft($sString, $i - 2) & "..." & StringRight($sString, $i - 2) _WinAPI_ReleaseDC(0, $hDC) _WinAPI_DeleteObject($hFont) Return $sString EndFunc ;==>_StringFitToLabel1 point
-
WOW, thank you very much, this app is great. With this app I have everything I need to find the buttons. sincerely1 point
-
neither am I, I'm a carpenter. I just love these challenges Check again how Chrome move open tabs . Once you're halfway through, it instantly goes to the other side My attempt to make it "smoothly positioned" probably had the opposite result. Here are the results ; https://www.autoitscript.com/forum/topic/211959-drag-and-drop-items-labels-vertically-among-themselves/?do=findComment&comment=1534586 #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <StaticConstants.au3> #include <WinAPIGdi.au3> #include <Array.au3> Global $iStart = 70, $iSpace = 5, $iLeft = 20, $iLabelHeight = 50 Global $hGUI = GUICreate('Dragging items vertically (this is a draft)', 500, ($iLabelHeight + $iSpace) * 12) GUISetBkColor(0x00FF00) ; background color is green Global $aLabel[10][2] $aLabel[0][0] = 9 ;NumOfLabels For $i = 1 To $aLabel[0][0] ;Creating test items (labels) $aLabel[$i][1] = (($iLabelHeight + $iSpace) * ($i - 1)) + $iStart $aLabel[$i][0] = GUICtrlCreateLabel("Label " & $i, $iLeft, $aLabel[$i][1], 460, $iLabelHeight, BitOR($SS_SUNKEN, $SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, 0xFF0000) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetFont(-1, 14, 700, 'Tahoma') Next GUISetState(@SW_SHOW, $hGUI) ;********************************** While 1 Switch GUIGetMsg() Case -3 ;$GUI_EVENT_CLOSE ExitLoop EndSwitch _IsDragging() Sleep(10) WEnd ;********************************** Exit ;-------------------------------------------------------------------------------------------------------------------------------- Func _IsDragging() Local Static $iOffset = Int($iLabelHeight / 2) If Not WinActive($hGUI) Then Return SetError(1, 0, False) Local $aCtrl = GUIGetCursorInfo($hGUI) If Not $aCtrl[2] Then Return SetError(2, 0, False) Local $ActiveCtrl = Null For $i = 1 To $aLabel[0][0] If $aLabel[$i][0] = $aCtrl[4] Then $ActiveCtrl = $aCtrl[4] EndIf Next If $ActiveCtrl = Null Then Return SetError(3, 0, False) Opt("MouseCoordMode", 2) ;1=absolute, 0=relative, 2=client Local $iCursorId = MouseGetCursor() GUISetCursor(11, 1, $hGUI) GUICtrlSetBkColor($ActiveCtrl, 0xCC0000) ;0xFF0000 Local $iOldPos, $iStp Do $aCtrl = GUIGetCursorInfo($hGUI) ControlMove($hGUI, '', $ActiveCtrl, Default, MouseGetPos(1) - $iOffset) ;Reposition of Labels _ArraySort($aLabel, 0, 1, 0, 1) For $i = 1 To $aLabel[0][0] If $aLabel[$i][0] = $ActiveCtrl Then $aLabel[$i][1] = MouseGetPos(1) - $iOffset ContinueLoop EndIf $aLabel[$i][1] = (($iLabelHeight + $iSpace) * ($i - 1)) + $iStart $iOldPos = ControlGetPos($hGUI, '', $aLabel[$i][0])[1] $iStp = ($iOldPos > $aLabel[$i][1] ? -5 : 5) For $Y = $iOldPos To $aLabel[$i][1] Step $iStp GUICtrlSetPos($aLabel[$i][0], $iLeft, $Y) Sleep(10) Next Next ;~ Sleep(10) Until Not $aCtrl[2] Opt("MouseCoordMode", 1) ;1=absolute, 0=relative, 2=client GUISetCursor($iCursorId, 1, $hGUI) GUICtrlSetBkColor($ActiveCtrl, 0xFF0000) For $i = 1 To $aLabel[0][0] $aLabel[$i][1] = (($iLabelHeight + $iSpace) * ($i - 1)) + $iStart ;ConsoleWrite(GUICtrlRead($aLabel[$i][0]) & " " & $aLabel[$i][1] & @CRLF) GUICtrlSetPos($aLabel[$i][0], $iLeft, $aLabel[$i][1]) Next ConsoleWrite("" & @CRLF) _WinAPI_RedrawWindow($hGUI) EndFunc ;==>_IsDragging ;--------------------------------------------------------------------------------------------------------------------------------1 point
-
Yeah I just adjusted the colours to make them lighter or darker. Some I changed for more contrast and easier reading for my eyes. Play away...!1 point
-
Recursive _ArrayDisplay and _DebugArrayDisplay
pixelsearch reacted to Gianni for a topic
... if you prefer to view the contents of nested arrays within the same window rather than opening different windows for each subarray you can also try this other array viewer: https://www.autoitscript.com/forum/topic/182856-array-viewer1 point -
Something like this? #include <WinAPISysWin.au3> #include <Array.au3> Global $hGUI, $iNumOfLabels = 10, $iLabelHeight = 30 Global $aLabel[$iNumOfLabels] $hGUI = GUICreate('Test', 400, 500) For $Index = 0 To $iNumOfLabels - 1 $aLabel[$Index] = GUICtrlCreateLabel('Label ' & $Index + 1, 10, 10 + $Index * 40, 300, $iLabelHeight, 0x1200) Next GUISetState(@SW_SHOW) Do DragEvent() Until GUIGetMsg() = -3 ; GUI_EVENT_CLOSE Func DragEvent() Local Static $iAdjPos = Int($iLabelHeight / 2) Local $iCtrl = Null Local $aInfo = GUIGetCursorInfo($hGUI) If Not $aInfo[2] Then Return SetError(1, 0, False) For $Index = 0 To $iNumOfLabels - 1 If $aLabel[$Index] = $aInfo[4] Then $iCtrl = $aInfo[4] ExitLoop EndIf Next If $iCtrl = Null Then Return SetError(2, 0, False) Do $aInfo = GUIGetCursorInfo($hGUI) ControlMove($hGUI, '', $iCtrl, 10, $aInfo[1] - $iAdjPos) Sleep(10) Until Not $aInfo[2] Local $aPos[$iNumOfLabels][2] For $Index = 0 To $iNumOfLabels - 1 $aPos[$Index][0] = $aLabel[$Index] $aPos[$Index][1] = ControlGetPos($hGUI, '', $aLabel[$Index])[1] Next _ArraySort($aPos, Default, Default, Default, 1) For $Index = 0 To $iNumOfLabels - 1 ControlMove($hGUI, '', $aPos[$Index][0], 10, 10 + $Index * 40) Next _WinAPI_InvalidateRect($hGUI) EndFunc1 point
-
#include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <EditConstants.au3> #include <ButtonConstants.au3> Global $hGUI = GUICreate('Form1', 250, 100, 303, 543) Global $idInput = GUICtrlCreateInput("Password", 10, 10, 200, 20, BitOR($GUI_SS_DEFAULT_INPUT, $ES_PASSWORD)) Global $idButton = GUICtrlCreateButton("👁", 212, 9, 25, 21) GUICtrlSetFont(-1, 14, 400, 0) GUISetState(@SW_SHOW) ; Prep The Password Control Global $sDefaultPassChar = GUICtrlSendMsg($idInput, $EM_GETPASSWORDCHAR, 0, 0) While 1 ; Process the standard messages $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch _Reveal() WEnd Func _Reveal() Local Static $bPress Local $a = GUIGetCursorInfo($hGUI) If $a[2] = 1 And $a[4] = $idButton Then If $bPress = True Then Return GUICtrlSendMsg($idInput, $EM_SETPASSWORDCHAR, 0, 0) _WinAPI_RedrawWindow(GUICtrlGetHandle($idInput)) $bPress = True Else If $bPress = True Then $bPress = False GUICtrlSendMsg($idInput, $EM_SETPASSWORDCHAR, $sDefaultPassChar, 0) _WinAPI_RedrawWindow(GUICtrlGetHandle($idInput)) GUICtrlSetState($idInput, $GUI_FOCUS) Send("{RIGHT}") Sleep(100) EndIf EndIf EndFunc ;==>_Reveal Look at: https://www.autoitscript.com/forum/topic/211400-autoit-password-style1 point
-
https://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/Scitedoc/SciTEDoc.html in your SciTE4AutoIt3 in the menu Help -> SciTE Help1 point