Leaderboard
Popular Content
Showing content with the highest reputation on 09/23/2018 in all areas
-
You're welcome. You should use the most current version. As it stated in my comment, as to why I changed it, I removed the "|" symbol from the set of characters that are valid in a URL. It was added in error. I just corrected it to make it match the spec, or at least to make it match the character set as closely as possible. If you look at my previous post, you will also see that I created a hyperlink to the RFC. From my previous post:1 point
-
Here is one more example that uses a RFC 3986 compliant character set. This regular expression will not handle URLs that do not start with either http://, https://, or "www.". For example, it will not find "autoitscript.com" but it will find "https://autoitscript.com". Like others have said, you have not adequately defined what, EXACTLY, you are looking for. Without a specific, all-encompassing, definition, all of our suggestions may miss certain cases. All of the suggestions are based on the data that you provided. Maybe you can help us help you by providing one of your "complex" html or text files so that we can see what you are working with. This back and forth, what-if, way of getting to your solution is a waste of time and effort . #include <Constants.au3> #include <Array.au3> example() Func example() Local $aResult[0] Local $aURLs = [ _ "-_ http://autoitscript.com---" , " https://www.autoitscript.com => ", _ "1-http://www.autoitscript.com" , "- https://autoitscript.com -", _ "- www.autoitscript.com -" , "- www.autoitscript.org - _", _ "- www.autoitscript.org... - _" , "-#$%& www.autoitscript.net -", _ "-_ http://www.international.in---" , "- https://www.communications.com => ", _ "1-http://www.networksupport.net" , "--- www.organizasion.org -", _ "- www.information.info - _" , "-#$%& www.autoitscript.com -", _ "-_ http://www.international.in.us---", "- https://www.communications.com.fr => ", _ "1-http://www.networksupport.net.us" , "--- www.organizasion.org -", _ "- www.information.info/test.html - _", _ "-#$%& www.autoitscript.com/this&20is%20a%20test.html -", _ "-#$%& https://www.autoitscript.com/this&20is%20a%20test.html -", _ "- https://www.autoit-script.com.fr/ -" _ ] ;Parse URLs using RFC 3986 Compliant Character Set $aResult = StringRegExp( _ _ArrayToString($aURLs, @CRLF), _ "(?i)\b(?:https?://|www\.)[-A-Z0-9+&@#/%=~_$?!:,.]*[A-Z0-9+&@#/%=~_$]", _ $STR_REGEXPARRAYGLOBALMATCH) If IsArray($aResult) Then _ArrayDisplay($aResult) EndFunc1 point
-
1 point
-
This looks like a one clean way of doing it For $i = 0 To UBound($aURLs) - 1 $aURLs[$i] = StringTrimLeft($aURLs[$i], _by($aURLs[$i])) $aURLs[$i] = StringTrimRight($aURLs[$i], _by(StringReverse($aURLs[$i]))) Next _ArrayDisplay($aURLs) Func _by($sValue) Local $aRet = StringRegExp($sValue, '(^.?[\W_]+)\w()', 3) If Not @error Then Return StringLen($aRet[0]) EndFunc Edit: a small fix on an extra space introduced when running TheXman's (next post) array example1 point
-
Just an non-perfect example which you can start with: ;coded by UEZ build 2018-09-22 beta #include <Array.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WinAPIRes.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> Global $__g_hGUI_MarkArea, $__g_iLabel_TL, $__g_iLabel_TM, $__g_iLabel_TR, $__g_iLabel_LM, $__g_iLabel_RM, $__g_iLabel_BL, $__g_iLabel_BM, _ $__g_iLabel_BR, $__g_iOldCursor, $__g_iW, $__g_iH, $__g_iColor_ResizeDots = 0xFFFFFF, $__g_iBorder = 4 Global $aRect = _GDIPlus_MarkArea() _ArrayDisplay($aRect, "Selection Coordinates") Func _GDIPlus_MarkArea() _GDIPlus_Startup() $__g_hGUI_MarkArea = GUICreate("", 1, 1, -1, -1, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED)) GUISetBkColor(0xABCDEF, $__g_hGUI_MarkArea) $__g_iLabel_TL = GUICtrlCreateLabel("", 0, 0, $__g_iBorder, $__g_iBorder) ;top left GUICtrlSetResizing(-1, $GUI_DOCKSIZE) GUICtrlSetBkColor(-1, $__g_iColor_ResizeDots) $__g_iLabel_TM = GUICtrlCreateLabel("", 0, 0, $__g_iBorder, $__g_iBorder) ;top mid GUICtrlSetResizing(-1, $GUI_DOCKSIZE) GUICtrlSetBkColor(-1, $__g_iColor_ResizeDots) $__g_iLabel_TR = GUICtrlCreateLabel("", 0, 0, $__g_iBorder, $__g_iBorder) ;top right GUICtrlSetResizing(-1, $GUI_DOCKSIZE) GUICtrlSetBkColor(-1, $__g_iColor_ResizeDots) $__g_iLabel_LM = GUICtrlCreateLabel("", 0, 0, $__g_iBorder, $__g_iBorder) ;left mid GUICtrlSetResizing(-1, $GUI_DOCKSIZE) GUICtrlSetBkColor(-1, $__g_iColor_ResizeDots) $__g_iLabel_RM = GUICtrlCreateLabel("", 0, 0, $__g_iBorder, $__g_iBorder) ;right mid GUICtrlSetResizing(-1, $GUI_DOCKSIZE) GUICtrlSetBkColor(-1, $__g_iColor_ResizeDots) $__g_iLabel_BL = GUICtrlCreateLabel("", 0, 0, $__g_iBorder, $__g_iBorder) ;bottom left GUICtrlSetResizing(-1, $GUI_DOCKSIZE) GUICtrlSetBkColor(-1, $__g_iColor_ResizeDots) $__g_iLabel_BM = GUICtrlCreateLabel("", 0, 0, $__g_iBorder, $__g_iBorder) ;bottom mid GUICtrlSetResizing(-1, $GUI_DOCKSIZE) GUICtrlSetBkColor(-1, $__g_iColor_ResizeDots) $__g_iLabel_BR = GUICtrlCreateLabel("", 0, 0, $__g_iBorder, $__g_iBorder) ;bottom right GUICtrlSetResizing(-1, $GUI_DOCKSIZE) GUICtrlSetBkColor(-1, $__g_iColor_ResizeDots) $__g_iOldCursor = MouseGetCursor() GUISetCursor(3, 1, $__g_hGUI_MarkArea) GUISetState(@SW_SHOW, $__g_hGUI_MarkArea) _WinAPI_SetLayeredWindowAttributes($__g_hGUI_MarkArea, 0xABCDEF, 0xF0, 3) Local $aMPos, $aPrevMPos[2] = [MouseGetPos(0) + 1, MouseGetPos(1) + 1], $iID, $aCI, $iX, $iY, $bLMPressed = False Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIRegisterMsg($WM_TIMER, "") DllCall("user32.dll", "bool", "KillTimer", "hwnd", $__g_hGUI_MarkArea, "uint_ptr", $iID) _GDIPlus_Shutdown() Local $aResult = WinGetPos($__g_hGUI_MarkArea) GUIDelete($__g_hGUI_MarkArea) Return $aResult EndSwitch $aMPos = MouseGetPos() If $aMPos[0] <> $aPrevMPos[0] Or $aMPos[1] <> $aPrevMPos[1] And Not $bLMPressed Then WinMove($__g_hGUI_MarkArea, "", $aMPos[0], $aMPos[1]) $aPrevMPos = $aMPos EndIf $aCI = GUIGetCursorInfo($__g_hGUI_MarkArea) If $bLMPressed = True Then Switch $aCI[4] Case $__g_iLabel_TL, $__g_iLabel_BR GUISetCursor(12, 1, $__g_hGUI_MarkArea) Case $__g_iLabel_TR, $__g_iLabel_BL GUISetCursor(10, 1, $__g_hGUI_MarkArea) Case $__g_iLabel_LM, $__g_iLabel_RM GUISetCursor(13, 1, $__g_hGUI_MarkArea) Case $__g_iLabel_TM, $__g_iLabel_BM GUISetCursor(11, 1, $__g_hGUI_MarkArea) Case Else GUISetCursor($__g_iOldCursor, 1, $__g_hGUI_MarkArea) EndSwitch EndIf If $aCI[2] And Not $bLMPressed Then $aGUIStartPos = WinGetPos($__g_hGUI_MarkArea) GUIRegisterMsg($WM_TIMER, "PlayAnim") $iID = DllCall("User32.dll", "uint_ptr", "SetTimer", "hwnd", $__g_hGUI_MarkArea, "uint_ptr", 1, "uint", 30, "ptr", 0)[0] While $aCI[2] $aCI = GUIGetCursorInfo($__g_hGUI_MarkArea) $aMPos = MouseGetPos() $__g_iW = Abs($aMPos[0] - $aGUIStartPos[0]) + 1 $__g_iH = Abs($aMPos[1] - $aGUIStartPos[1]) + 1 If $aMPos[0] < $aGUIStartPos[0] Then $iX = $aMPos[0] Else $iX = $aGUIStartPos[0] EndIf If $aMPos[1] < $aGUIStartPos[1] Then $iY = $aMPos[1] Else $iY = $aGUIStartPos[1] EndIf WinMove($__g_hGUI_MarkArea, "", $iX, $iY, $__g_iW, $__g_iH) ControlMove($__g_hGUI_MarkArea, "", $__g_iLabel_TM, ($__g_iW - $__g_iBorder) / 2, 0, $__g_iBorder, $__g_iBorder) ControlMove($__g_hGUI_MarkArea, "", $__g_iLabel_TR, ($__g_iW - $__g_iBorder), 0, $__g_iBorder, $__g_iBorder) ControlMove($__g_hGUI_MarkArea, "", $__g_iLabel_LM, 0, ($__g_iH - $__g_iBorder) / 2, $__g_iBorder, $__g_iBorder) ControlMove($__g_hGUI_MarkArea, "", $__g_iLabel_RM, ($__g_iW - $__g_iBorder), ($__g_iH - $__g_iBorder) / 2, $__g_iBorder, $__g_iBorder) ControlMove($__g_hGUI_MarkArea, "", $__g_iLabel_BL, 0, ($__g_iH - $__g_iBorder), $__g_iBorder, $__g_iBorder) ControlMove($__g_hGUI_MarkArea, "", $__g_iLabel_BM, ($__g_iW - $__g_iBorder) / 2, ($__g_iH - $__g_iBorder), $__g_iBorder, $__g_iBorder) ControlMove($__g_hGUI_MarkArea, "", $__g_iLabel_BR, ($__g_iW - $__g_iBorder), ($__g_iH - $__g_iBorder), $__g_iBorder, $__g_iBorder) ControlMove($__g_hGUI_MarkArea, "", $__g_iLabel_BR, ($__g_iW - $__g_iBorder), ($__g_iH - $__g_iBorder), $__g_iBorder, $__g_iBorder) WEnd $bLMPressed = True GUISetCursor($__g_iOldCursor, 1, $__g_hGUI_MarkArea) EndIf Until False EndFunc ;==>_GDIPlus_MarkArea Func PlayAnim() Local Static $fOffset = 0 Local Const $iSize = $__g_iBorder / 2 Local Const $hDC = _WinAPI_GetDC($__g_hGUI_MarkArea) Local Const $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $__g_iW, $__g_iH) Local Const $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC) Local Const $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hHBitmap) Local Const $hCanvas = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer) Local Const $hPen = _GDIPlus_PenCreate(0xFF0178D7, $iSize), $hPen2 = _GDIPlus_PenCreate(0xFFFFFFFF, $iSize), _ $hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) _GDIPlus_PenSetDashStyle($hPen, $GDIP_DASHSTYLEDASHDOTDOT) _GDIPlus_GraphicsClear($hCanvas, 0xFFABCDEF) _GDIPlus_GraphicsDrawRect($hCanvas, 1 + $iSize, 1 + $iSize, $__g_iW - 2 * $iSize - 2, $__g_iH - 2 * $iSize - 2, $hPen2) DllCall($__g_hGDIPDll, "int", "GdipSetPenDashOffset", "handle", $hPen, "float", $fOffset) _GDIPlus_GraphicsDrawRect($hCanvas, 1 + $iSize, 1 + $iSize, $__g_iW - 2 * $iSize - 2, $__g_iH - 2 * $iSize - 2, $hPen) _GDIPlus_GraphicsFillRect($hCanvas, 0, 0, $__g_iBorder + 1, $__g_iBorder + 1, $hBrush) _GDIPlus_GraphicsDrawRect($hCanvas, 0, 0, $__g_iBorder + 1, $__g_iBorder + 1) _GDIPlus_GraphicsFillRect($hCanvas, ($__g_iW - $__g_iBorder) / 2, 0, $__g_iBorder + 1, $__g_iBorder + 1, $hBrush) _GDIPlus_GraphicsDrawRect($hCanvas, ($__g_iW - $__g_iBorder) / 2, 0, $__g_iBorder + 1, $__g_iBorder + 1) _GDIPlus_GraphicsFillRect($hCanvas, ($__g_iW - $__g_iBorder) - 2, 0, $__g_iBorder + 1, $__g_iBorder + 1, $hBrush) _GDIPlus_GraphicsDrawRect($hCanvas, ($__g_iW - $__g_iBorder) - 2, 0, $__g_iBorder + 1, $__g_iBorder + 1) _GDIPlus_GraphicsFillRect($hCanvas, 0, ($__g_iH - $__g_iBorder) / 2, $__g_iBorder + 1, $__g_iBorder + 1, $hBrush) _GDIPlus_GraphicsDrawRect($hCanvas, 0, ($__g_iH - $__g_iBorder) / 2, $__g_iBorder + 1, $__g_iBorder + 1) _GDIPlus_GraphicsFillRect($hCanvas, ($__g_iW - $__g_iBorder) - 2, ($__g_iH - $__g_iBorder) / 2, $__g_iBorder + 1, $__g_iBorder + 1, $hBrush) _GDIPlus_GraphicsDrawRect($hCanvas, ($__g_iW - $__g_iBorder) - 2, ($__g_iH - $__g_iBorder) / 2, $__g_iBorder + 1, $__g_iBorder + 1) _GDIPlus_GraphicsFillRect($hCanvas, 0, ($__g_iH - $__g_iBorder) - 2, $__g_iBorder + 1, $__g_iBorder + 1, $hBrush) _GDIPlus_GraphicsDrawRect($hCanvas, 0, ($__g_iH - $__g_iBorder) - 2, $__g_iBorder + 1, $__g_iBorder + 1) _GDIPlus_GraphicsFillRect($hCanvas, ($__g_iW - $__g_iBorder) / 2, ($__g_iH - $__g_iBorder) - 2, $__g_iBorder + 1, $__g_iBorder + 1, $hBrush) _GDIPlus_GraphicsDrawRect($hCanvas, ($__g_iW - $__g_iBorder) / 2, ($__g_iH - $__g_iBorder) - 2, $__g_iBorder + 1, $__g_iBorder + 1) _GDIPlus_GraphicsFillRect($hCanvas, ($__g_iW - $__g_iBorder) - 2, ($__g_iH - $__g_iBorder) - 2, $__g_iBorder + 1, $__g_iBorder + 1, $hBrush) _GDIPlus_GraphicsDrawRect($hCanvas, ($__g_iW - $__g_iBorder) - 2, ($__g_iH - $__g_iBorder) - 2, $__g_iBorder + 1, $__g_iBorder + 1) _WinAPI_BitBlt($hDC, 0, 0, $__g_iW, $__g_iH, $hDC_backbuffer, 0, 0, $SRCCOPY) $fOffset += 0.5 _GDIPlus_GraphicsDispose($hCanvas) _WinAPI_SelectObject($hDC_backbuffer, $DC_obj) _WinAPI_DeleteDC($hDC_backbuffer) _WinAPI_DeleteObject($hHBitmap) _WinAPI_ReleaseDC($__g_hGUI_MarkArea, $hDC) _GDIPlus_PenDispose($hPen) _GDIPlus_PenDispose($hPen2) _GDIPlus_BrushDispose($hBrush) EndFunc ;==>PlayAnim Just mark an area on your desktop by holding down the left mouse button. The resize function of the marked area is not added yet. Look here for the full version:1 point
-
1 point
-
_FileFindEx Get More from File/Folder Searches (formerly _WinAPI_FileFind) Since it's always bugged me that the AutoIT implementation of 'FindFirstFile' and 'FindNextFile' only returned filenames and that extra calls had to be made to get file-size, attributes, short-names, and date/time of file creation,last-access, & last-modification which severely increased the amount of time it took to properly analyze the contents of a folder and it's files, I decided to create an alternative. This uses the same Windows calls as AutoIT, except it returns all the information that it rightfully should for each file found - including: File attributes (in numerical form, not a silly string format)Creation TimeLast-Access TimeLast-Write TimeFileSizeFilename (obviously)8.3 short name (if it is 1. different from the regular Filename and 2. if short-names haven't been turned offReparse Point info (if available)Now, the calling process is a little different, though for the most part not much is required to be altered in existing code. Basically, the attributes-check for folders is a numerical test, and when a folder is found, you *need* to test for '.' and '..' navigation (fake) folders. Also, the 'While' loop changes into a 'Do-Until' loop. Additionally, the first _FileFindExFirstFile() call returns a file, whereas FileFindFirstFile() doesn't (which never made sense to me). To convert times into a readable format, you'll need to pass the array to the _FileFindExTimeConvert() function. Optionally, you can get the _WinTimeFunctions UDF and call those functions using array index constants: $FFX_CREATION_TIME, $FFX_LAST_ACCESS_TIME, or $FFX_LAST_MODIFIED_TIME. Note all _FileFindEx* calls are done using a special array, though 'ByRef' for quicker performance. A nice application I found for this UDF was comparing files/folders - which is pretty easy using 64-bit filetime and file-size comparisons (no need for time conversion there). The ZIP includes 4 files: the _FileFindEx UDF, FileFindExTest, the license agreement (same as below), and _LinkedOutputDisplay. Please note that _LinkedOutputDisplay on its own is a mess - but its included as-is to help see a side-by-side comparison of the output from FileFindExTest. To get all the same information that _FileFindEx provides, the AutoIt functions below would need to be called: FileFindFirst/NextFileFileGetAttrib *** NOTE: This Fails to report on some attributes (Reparse Points, Sparse Files) ***FileGetTime *3 (one for each time - Creation, Last-Access, Last-Modified)FileGetSizeFileGetShortName (note: this provides a full path, rather than just a file name)Please note that for a fair time comparison, a clean boot is needed for each test due to O/S buffering after a scan. Between boots, the order of function calls in 'FileFindExTest' would need to be swapped. In first-run tests, _FileFindEx has consistently been quicker when gathering more than basic filename info. However, running the UDF in 64-bit mode on Vista+ O/S's results in slower performance, hence this note: *IMPORTANT* - Speed is severely affected on certain processors when the script is run in x64 mode. I therefore recommend running/compiling the code in both bit-modes beforehand to see what the speed difference is. On my machine I've found x86 is much faster, whereas x64 is much slower than AutoIt's search functions. Other's have so I'm guessing it must be how optimized the hardware architecture is at running x64 code. Update Log: Download the ZIP Here Ascend4nt's AutoIT Code License agreement: While I provide this source code freely, if you do use the code in your projects, all I ask is that: If you provide source, keep the header as I have put it, OR, if you expand it, then at least acknowledge me as the original author, and any other authors I creditIf the program is released, acknowledge me in your credits (it doesn't have to state which functions came from me, though again if the source is provided - see #1)The source on it's own (as opposed to part of a project) can not be posted unless a link to the page(s) where the code were retrieved from is provided and a message stating that the latest updates will be available on the page(s) linked to.Pieces of the code can however be discussed on the threads where Ascend4nt has posted the code without worrying about further linking.1 point