Search the Community
Showing results for tags 'ellipsis'.
-
Hallo Members, I'm looking for a good regex to get the drive letter and the last two folders from a file path, If the path is to long for the label width then show drive + ellipses and two last folders. Drive:\(ellipses)\folder\folder ex. D:\...\folder\folder and when the folder is in the root of the drive then show D:\Folder The test GUI #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.12.0 Author: Mecano Script Function: ELLIPSIS Long path: Drive:\...\Folder\Folder if root then Drive:\Folder #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here $sFile = "F:\Just a folder\in a another folder\and another\This-dir\And-this-dir" $EllipsisPath = StringRegExpReplace($sFile, '\w[a-zA-Z \\]+\\', '') ; <- This needs another regex ;no ellipsis needed, for testing purposes only $sUSB = "K:\Just a folder" $PathforUSB = StringRegExpReplace($sUSB, '\w[a-zA-Z \\]+\\', '') #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Drive + Two last folders of path", 327, 236, 192, 124) $Button1 = GUICtrlCreateButton("Test label", 40, 168, 97, 33) $Label1 = GUICtrlCreateLabel("F:\...\This-dir\And-this-dir", 40, 12, 200, 40) ; <- Looks good but not dynamic GUICtrlSetColor($Label1, 32768) $Label2 = GUICtrlCreateLabel($sFile, 40, 40, 200, 40, $DT_END_ELLIPSIS) ; <- not the last two directorys GUICtrlSetColor($Label2, 16711680) $Label3 = GUICtrlCreateLabel("Var label1", 40, 72, 200, 40) GUICtrlSetColor($Label3, 16711680) $Label4 = GUICtrlCreateLabel("Var label", 40, 104, 200, 40) GUICtrlSetColor($Label4, 16711680) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 GUICtrlSetData($Label3, $EllipsisPath) ; $DT_END_ELLIPSIS <- works only on GUICtrlCreateLabel GUICtrlSetData($Label4, $PathforUSB) EndSwitch WEnd Thanks in advance