Leaderboard
Popular Content
Showing content with the highest reputation on 04/19/2021 in all areas
-
Ahhh. Always had a hard time with languages. One of my prof told me once, that I speak better Fortran that I speak french.3 points
-
Retrieve file list based on file modified time
seadoggie01 and 2 others reacted to GeorgeP for a topic
Hi All, I would like to thank everyone who has contributed to this topic, it has enlightened me in several ways - alternative ways to achieve similar things that I didn't think of. I had toyed with the idea to get the file names into an array and rename the month portion to digits, re-sort the array and then change the digits back to alphas but thought there may be other ways. Thought it would take a while to code but turned out very simple. I was also working with over 51,000 files so I thought it would take a decent amount of time to process but turned out to be just a few seconds. So good to have such great people offering advice. Regards George3 points -
extract a sentence containing word in text file
Musashi and one other reacted to JockoDundee for a topic
Yes. We say “An hour”, but “A history”. Or “An unsigned integer”, but “A Ulimit”. It depends on whether there is a consonant sound that starts the word after the a or not.2 points -
Improving _ArrayDisplay speed
FrancescoDiMuro and one other reacted to LarsJ for a topic
I haven't reviewed the current ArrayDisplay code. I don't think that automatic sizing of columns works in a virtual listview. Automatic sizing of columns is based on the column widths being calculated when item/subitem texts are inserted into listview structures. But in a virtual listview, the texts aren't inserted into any structures. Therefore, the column widths cannot be calculated. Of course, all code based on item/subitem texts being stored in listview structures doesn't work immediately in a virtual listview. Depending on how much you want to make out of it, you can perform many of the calculations yourself directly on the basis of the data source. Since these calculations may be time consuming, they must be performed before the ArrayDisplay function is called. Also note that the code in the post at top of the previous page are simple examples, which was what I could find time for on the last day of the Easter holiday.2 points -
This "cow" seems funny to me, At this link (https://dodona.ugent.be/en/activities/1605325419/#) a brief rough description of what this script can do (sorry for the laziness, but that description may be fine). You can use the _CowSayWin() function to display a message formatted in a comic along with an ascii art figure in a standalone window, or you can use _String_CowSay() function to format a plain string in a comic along with an ascii art figure and have it returned in a string for your own purposes, you will probably use it in Consolewrite () or whatever ... The script makes use of the _StringSize() function written by @Melba23 (thanks Melba) of the StringSize.au3 udf that you can extract from the zip file located at this link: https://www.autoitscript.com/forum/topic/114034-stringsize-m23-new-version-16-aug-11/. You have to save that udf file in the same directory along with this script. It also makes use of the _WinSetClientSize() function written by @KaFu. (thanks kafu) This function is already built into the main script. I hope you have fun #include <FontConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <WinAPISys.au3> #include <array.au3> #include <String.au3> #include "StringSize.au3" ; <-- https://www.autoitscript.com/forum/topic/114034-stringsize-m23-new-version-16-aug-11/ _Example() Func _Example() SRandom(@SEC) Local $hCowWin, $aMsg = 0 Local $sMessage, $iWidth, $iClipart, $iTextAlig Local $aMessages[] = ["Bottled water companies don’t produce water, they produce plastic bottles.", _ "The greatest glory in living lies not in never falling, but in rising every time we fall.", _ "Your time is limited, so don't waste it living someone else's life. " & _ "Don't be trapped by dogma which is living with the results of other people's thinking.", _ "Insanity is doing the same thing over and over again and expecting different results", _ "The way to get started is to quit talking and begin doing."] For $i = 1 To 6 $sMessage = $aMessages[Random(0, UBound($aMessages) - 1, 1)] $iWidth = Random(21, 90, 1) $iClipart = Random(0, 3, 1) $iTextAlign = 1 ; Random(0, 2, 1) Left and right alignments are a bit ugly. ; they are allowed however if you need them ; ; You can use the _CowSayWin() function to create the "cowsay" message in a window $hCowWin = _CowSayWin($sMessage, $iWidth, $iClipart, $iTextAlign) ; ; or you can use the _String_CowSay() function to get a string of the "cowsay ascii clipart" ; so that you can use it however you like, probably in a Consolewrite () for example ... ConsoleWrite(_String_CowSay($sMessage, $iWidth, $iClipart, $iTextAlign) & @CRLF) While 1 $aMsg = GUIGetMsg($GUI_EVENT_ARRAY) Switch $aMsg[1] Case $hCowWin Switch $aMsg[0] Case -3 ; $GUI_EVENT_CLOSE ExitLoop EndSwitch EndSwitch WEnd GUIDelete(HWnd($hCowWin)) Next EndFunc ;==>_Example ; #FUNCTION# ==================================================================================================================== ; Name ..........: _CowSayWin ; Description ...: Display a message in a standalone windows formatted in a balloon along with an ascii art figure ; Syntax ........: _CowSayWin($sMsg[, $iBoxLen = 21[, $iShape = 0[, $iAlign = 1]]]) ; Parameters ....: $sMsg - a string value. The message to display (in a single line without @cr and or @lf) ; $iBoxLen - [optional] an integer value. Default is 21. ; The wanted width of the Box contining the message ; $iShape - [optional] an integer value. Default is 0. ; The index of the ascii art figure to be displayed along with the message. ; Available values are: ; 0 -> a cow ; 1 -> a sandwich-man ; 2 -> the penguin Tux ; 3 -> a hanging monkey ; ..... to be continued (maybe) ; $iAlign - [optional] an integer value. Default is 1. ; How to justify the string within the frame, that is: ; 0 -> left justified ; 1 -> center justified (default) ; 2 -> right justified ; Return values .: The handle of the created window ; Author ........: Gianni Addiego (Chimp) ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _CowSayWin($sMsg, $iBoxLen = 21, $iShape = 0, $iAlign = 1) If $iBoxLen < 21 Then $iBoxLen = 21 Local $iSize = 12 Local $iWeight = $FW_NORMAL Local $iAttrib = $GUI_FONTNORMAL Local $sFont = "Courier new" Local $sSay = _String_CowSay($sMsg, $iBoxLen, $iShape, $iAlign) Local $aMsgReturn = _StringSize($sSay, $iSize, $iWeight, $iAttrib, $sFont) Local $iXpos = (@DesktopWidth - $aMsgReturn[2]) / 2 If $iXpos < 0 Then $iXpos = 0 Local $iYpos = (@DesktopHeight - $aMsgReturn[3]) / 2 If $iYpos < 0 Then $iYpos = 0 Local $hCow = GUICreate("Cowsay", -1, -1, $iXpos, $iYpos, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) ;0x94C803C5, 0x00010101) ; , $WS_EX_DLGMODALFRAME) ;0x94C803C5, 0x00010101) ; Style & ExStyle same as msgbox GUISetFont($iSize, $FW_NORMAL, $GUI_FONTNORMAL, $sFont) _WinSetClientSize($hCow, $aMsgReturn[2], $aMsgReturn[3]) GUICtrlCreateLabel($sSay, 0, 0, $aMsgReturn[2], $aMsgReturn[3]) GUISetState(@SW_SHOW, $hCow) #cs While 1 Switch GUIGetMsg() Case -3 ; $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd #ce Return $hCow EndFunc ;==>_CowSayWin ; By kafu ; https://www.autoitscript.com/forum/topic/201524-guicreate-and-wingetclientsize-mismatch/?do=findComment&comment=1446141 Func _WinSetClientSize($hWnd, $iW, $iH) Local $aWinPos = WinGetPos($hWnd) Local $sRect = DllStructCreate("int;int;int;int;") DllStructSetData($sRect, 3, $iW) DllStructSetData($sRect, 4, $iH) _WinAPI_AdjustWindowRectEx($sRect, _WinAPI_GetWindowLong($hWnd, $GWL_STYLE), _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE)) WinMove($hWnd, "", $aWinPos[0], $aWinPos[1], $aWinPos[2] + (DllStructGetData($sRect, 3) - $aWinPos[2]) - DllStructGetData($sRect, 1), $aWinPos[3] + (DllStructGetData($sRect, 4) - $aWinPos[3]) - DllStructGetData($sRect, 2)) EndFunc ;==>_WinSetClientSize ; #FUNCTION# ==================================================================================================================== ; Name ..........: _StringToColumn ; Description ...: passing a (long) string and a value, it returns that same string ; formatted in a column as wide as the value (string is split by @CRs). ; Whenever possible, it tries not to break the words but to split ; lines in between two words ; Syntax ........: _StringToColumn($sString[, $x = 21]) ; Parameters ....: $sString - a string value. The string to format ; $iColumnWidth - [optional] an integer value. Default is 21. ; The wanted width of the text column ; Return values .: The string formatted as required ; Author ........: Gianni Addiego (Chimp) ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _StringToColumn($sString, $iColumnWidth = 21) If $iColumnWidth < 1 Then $iColumnWidth = 1 Local $iPreviousSplit = 1 Local $i = $iColumnWidth While $i <= StringLen($sString) $iSplitPoint = StringInStr($sString, " ", 0, -1, $i + 1) If $iSplitPoint = 0 Or $iSplitPoint <= $iPreviousSplit Then $iSplitPoint = $i $sString = StringLeft($sString, $iSplitPoint) & @CR & StringMid($sString, $iSplitPoint + 1) $i = $iSplitPoint + 1 Else $sString = StringReplace($sString, $iSplitPoint, @CR) $i = $iSplitPoint EndIf $iPreviousSplit = $iSplitPoint $i += $iColumnWidth WEnd If StringRight($sString, 1) = @CR Then $sString = StringTrimRight($sString, 1) Return $sString EndFunc ;==>_StringToColumn ; #FUNCTION# ==================================================================================================================== ; Name ..........: _StringToFrame ; Description ...: places borders only to the left and to the right of the passed string block ; Syntax ........: _StringToFrame($sStr, $iFrameWidth[, $iAlign = 1[, $sV = "|"]]) ; Parameters ....: $sStr - The string to format; multiline string must be splitted by a @cr. ; $iFrameWidth - wanted Width of the frame ; If the desired width is less than the length of the string, the exceeding part is cut off ; If the desired width is wider than the length of the string, spaces are added ; $iAlign - [optional] an integer value. Default is 1. ; The string is justified within the frame based on the value of the $iAlign variable, that is: ; 0 -> left justified ; 1 -> center justified (default) ; 2 -> right justified ; $sV - [optional] a string value. Default is "|". ; This is the character used to draw the two vertical edges ; Return values .: The formatted string ; Author ........: Gianni Addiego (Chimp) ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _StringToFrame($sStr, $iFrameWidth, $iAlign = 1, $sV = "|") ; $iAlign: 0=Left; 1=Center; 2=Right If $iFrameWidth < 1 Then $iFrameWidth = 1 Local $a = StringSplit($sStr, @CR, 2) ; 2 = $STR_NOCOUNT For $i = 0 To UBound($a) - 1 Switch $iAlign Case 1 ; Center string $a[$i] = $sV & _StringSetLen(_StringCenter($a[$i], $iFrameWidth), $iFrameWidth) & $sV Case 2 ; Align to right $a[$i] = $sV & _StringSetLen($a[$i], $iFrameWidth * -1) & $sV Case Else ; otherwise Align to left $a[$i] = $sV & _StringSetLen($a[$i], $iFrameWidth) & $sV EndSwitch Next Return _ArrayToString($a, @CR) EndFunc ;==>_StringToFrame ; passing a string and a value it returns that string with a len as required ; By Gianni Addiego Func _StringSetLen($sString, $iWantedLen = 1, $sFillChr = " ") If $iWantedLen = 0 Then Return "" Local $iLen = StringLen($sString) Local $iKeepLeft = $iWantedLen > 0 ; else keep the right side of the string $iWantedLen = Abs($iWantedLen) If $iLen >= $iWantedLen Then ; reduce the string length If $iKeepLeft Then Return StringLeft($sString, $iWantedLen) Else Return StringRight($sString, $iWantedLen) EndIf Else ; add chars to the string to reach the wanted len If $iKeepLeft Then Return $sString & _StringRepeat($sFillChr, $iWantedLen - $iLen) Else Return _StringRepeat($sFillChr, $iWantedLen - $iLen) & $sString EndIf EndIf EndFunc ;==>_StringSetLen ; place a string in the middle of a given space ; By Gianni Addiego Func _StringCenter($sString, $iSpace) Local $iLen = StringLen($sString) $iHloc = Int($iSpace / 2) - Int($iLen / 2) If $iHloc < 0 Then Return StringMid($sString, Abs($iHloc) + 1, $iSpace) Else Return _StringRepeat(" ", $iHloc) & $sString EndIf EndFunc ;==>_StringCenter ; #FUNCTION# ==================================================================================================================== ; Name ..........: _String_CowSay ; Description ...: Formats a string in a balloon along with an ascii art figure ; Syntax ........: _String_CowSay($sMsg[, $iBoxLen = 21[, $iShape = 0[, $iAlign = 1]]]) ; Parameters ....: $sMsg - a string value. The String to format (in a single line without @cr and or @lf) ; $iBoxLen - [optional] an integer value. Default is 21. ; The wanted width of the Box contining the message ; $iShape - [optional] an integer value. Default is 0. ; The index of the ascii art figure to be displayed along with the message. ; Available values are: ; 0 -> a cow ; 1 -> a sandwich-man ; 2 -> the penguin Tux ; 3 -> a hanging monkey ; ..... to be continued (maybe) ; $iAlign - [optional] an integer value. Default is 1. ; How to justify the string within the frame, that is: ; 0 -> left justified ; 1 -> center justified (default) ; 2 -> right justified ; Return values .: The passed string formatted in the required format. ; Author ........: Gianni Addiego (Chimp) ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _String_CowSay($sMsg, $iBoxLen = 21, $iShape = 0, $iAlign = 1) ; minimum $iBoxLen is 21 If $iBoxLen / 2 = Int($iBoxLen / 2) Then $iBoxLen += 1 If $iBoxLen < 22 Then $x = 0 Else $x = Ceiling(($iBoxLen - 21) / 2) EndIf Local $sS = _StringRepeat(" ", $x), $sT = _StringRepeat("~", $x) Local $sHeader, $sFooter Switch $iShape Case 1 $sHeader = _ $sS & " \|||/" & @CRLF & _ $sS & " (o o)" & @CRLF & _ "," & $sT & "oo0~~~~~~(_)~~~~~~~~~" & $sT & "," & @CRLF ; header $sFooter = _ "'" & $sT & "~~~~~~~~~~~~~~~~~~oo0" & $sT & "'" & @CRLF & _ ; footer $sS & " |__|__|" & @CRLF & _ $sS & " || ||" & @CRLF & _ $sS & " oo0 0oo" Case 2 $sHeader = _ "," & $sT & "~~~~~~~~~~~~~~~~~~~~~" & $sT & "," & @CRLF ; header $sFooter = _ "'~~~~~~~~~~~~~~~~~~~~~" & $sT & $sT & "'" & @CRLF & _ " \ .--." & @CRLF & _ " \ |o_o |" & @CRLF & _ " |:_/ |" & @CRLF & _ " // \ \" & @CRLF & _ " (| | )" & @CRLF & _ " /'\_ _/`\" & @CRLF & _ " \___)=(___/" Case 3 $sHeader = _ "," & $sT & "~~~~~~~~~~~~~~~~~~~~~" & $sT & "," & @CRLF ; header $sFooter = _ "'" & $sT & "oo0~~~~~~~~~~~~~~~0oo" & $sT & "'" & @CRLF & _ ; footer $sS & " \\ //" & @CRLF & _ $sS & " > \ \\|||// / <" & @CRLF & _ $sS & " > \ _ _ / <" & @CRLF & _ $sS & " > \ / \ / \ / <" & @CRLF & _ $sS & " > \\_o_o_// <" & @CRLF & _ $sS & " > ( (_) ) <" & @CRLF & _ $sS & " >| |<" & @CRLF & _ $sS & " / |\___/| \" & @CRLF & _ $sS & " / (_____) \" & @CRLF & _ $sS & " / o \" & @CRLF & _ $sS & " ) ___ (" & @CRLF & _ $sS & " / / \ \" & @CRLF & _ $sS & " ( / \ )" & @CRLF & _ $sS & " >< ><" & @CRLF & _ $sS & " ///\ /\\\" & @CRLF & _ $sS & " ''' '''" Case Else $sHeader = _ "," & $sT & "~~~~~~~~~~~~~~~~~~~~~" & $sT & "," & @CRLF ; header $sFooter = _ "'~~~~~~~~~~~~~~~~~~~~~" & $sT & $sT & "'" & @CRLF & _ " \ ^__^" & @CRLF & _ " \ (oo)\_______" & @CRLF & _ " (__)\ )\/\" & @CRLF & _ " ||----w |" & @CRLF & _ " || ||" EndSwitch Return $sHeader & _StringToFrame(_StringToColumn($sMsg, $iBoxLen), $iBoxLen, $iAlign) & @CRLF & $sFooter EndFunc ;==>_String_CowSay2 points
-
... but some are passionate guys who create something similar themselves so this allows a first try #Include <Array.au3> $p = "word 1|word 2|word 3" $txt = " Sentence 1 without the searched term. Sentence 2 is word 1 sentence. " & @crlf & "Sentence 3 without the searched term. Sentence 4 without the searched term. Sentence 5, is word 2 sentence. " & @crlf & "Sentence 6 is word 3 sentence. Sentence 7 is otherword 3 sentence. Sentence 8 without the searched term. " $res = StringRegExp($txt, '(?s)\s*([^.]+\b(?|' & $p & ')\b[^.]+\.)', 3) _ArrayDisplay($res) Edit Waiting now for new requirements to come2 points
-
About dialog with credits area
t0nZ reacted to Professor_Bernd for a topic
An about dialog is a nice little thing, often hardly bigger than a message box and usually just a minor thing. But almost every program has an about dialog, if only to put its "stamp" on it, insert a contact address or a copyright. Then there are the thank you notes, which in the 00's liked to be spiced up with some great effects, like vertical ticker, like in the credits of a movie. But who likes to watch the credits of a movie? I think it's nicer if you can scroll the credits yourself, as fast and as slow as you want. So that's what it should be: An about dialog, where you can nicely display the name of the program with your own name, maybe show a version number, and with buttons and link labels you can click on, which will then open the web or email address. Oh yeah, and an area where you can express your thanks to everyone involved. So I searched the DE forum here and the EN forum for example codes for an about dialog with credits area. You would think that there should be a lot of them, because about dialogs already existed in the computer stone age. But far from it: I found only 2 code examples. Both dialogs lacked a credits area, but - yay! - there were LinkLabels. So I was one step further. Here in the forum I created a thread asking if someone could provide me with a nice About dialog. Even the first reply was promising and suggested using a RichEdit and loading an RTF file into it. Nice stuff. Unfortunately I had probably put my request too vague, because instead of the code for the about dialog I was only provided with a picture of the dialog. Based on the tips and suggestions I developed my own code and provide it here. The About dialog is relatively large and consists of a RichEdit that takes up the left and middle areas of the dialog. In the right area there are labels and buttons. In the RichEdit you can show an about text as well as the credits, which you can scroll through manually. Preview Settings I tried to keep the configuration simple. Probably it would have become rather complex to gather all configuration options in one place. Now it became 3 different places, which I marked with double lines well visibly and the code remained clear. To set your own settings, it is sufficient to make changes in these areas. So settings for the title bar and the right area with the labels and buttons can be made. Settings for the text in RichEdit are made in the RTF file, also links for web and e-mail addresses are set up in the RTF file. The finished file is then simply loaded into RichEdit. The path to the RTF file can be customized in the code in the first settings area. Relative paths are possible, e.g. "..\..\About.rtf". I have added an example RTF file: "About.rtf". My example RTF file was created with "LibreOffice Writer". Probably you can open it with any higher office program and design it according to your own ideas. Unfortunately, I don't have MS Office available at the moment to check this. Important: With MS WordPad you cannot edit the existing example RTF file! (The data will be unreadable). But you can create your own RTF file with MS WordPad and use it in the about dialog. The same applies to MS Office: If the existing RTF file cannot be edited, simply create a new one and design it according to your own wishes. Feedback is welcome. Version 0.0.12.2 First published Version. Version 0.0.12.5 Added: Ability to display the RichEdit with or without borders. Bugfix: When you scrolled the RichEdit with the scrollbar, the text and the scrollbar flickered. - Thanks to UEZ for finding this issue. 👍 Version 0.0.12.6 Added: Hide caret when the RichEdit is scrolled with the scrollbar. Nevertheless, the caret sometimes flashes a little when scrolling. Bugfix: Converted the background color value for the RichEdit from RGB to BGR. About Dialog 0.0.12.6 (Professor Bernd).zip1 point -
extract a sentence containing word in text file
FrancescoDiMuro reacted to JockoDundee for a topic
No, you’re actually correct. Because of your Demain comme jamais tag, whenever I read your posts, I can’t help but hear them (in my mind’s ear) in a thick French accent. So I heard “An eye-brid solution”, which is perfect.1 point -
[Solved] How to run Powershell with AutoIt and use Get-RDUserSession command?
DannyJ reacted to argumentum for a topic
...I don't marry to a tool. I use what I find functional. Good luck.1 point -
As so far we found that this was somehow related to AcrobatReader update. On some computers, this problem appeared and disappeared by itself. On some others when we uninstall them all starts works fine. I will back, if I will have any other information related to this issue.1 point
-
It's really hard to know what's the issue. Could you confirm you get the same issue using vbs. StartTime = Timer() dim objShell dim objShellWindows set objShell = CreateObject("shell.application") set objShellWindows = objShell.Windows EndTime = Timer() WScript.Echo "Windows Count: " & objShellWindows.Count & vbCrlf & "Time Elapsed: " & (EndTime - StartTime) Saludos1 point
-
Variable declarations.... for example: Local $sMessage, $iWidth, $iClipart, $iTextAlign instead: Local $sMessage, $iWidth, $iClipart, $iTextAlig and few others. Check your script with: #AutoIt3Wrapper_Run_AU3Check=Y #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 And you will see.1 point
-
Improving _ArrayDisplay speed
pixelsearch reacted to jpm for a topic
Hi, it is I have a very hard time to have behavior similar to current release colum sizing was the main problem. so it is first created and modify on the first focus as you notice Your analyse of what it is going is exactly what I face to have an almost successfull display. I was not able to do a better sizing when columns arer seletec with the array range Perhaps LarsJ will find a better implementation ... For the display timing I try to display a ToolTip is the time can take a while. Not sur it was taking much more as in the previous implementation. If you run with scite you get consoleWrite of the different timings Thanks for the feedback1 point -
SciTE4AutoIt3 Issue in Dual Monitor Environment
argumentum reacted to Subz for a topic
@argumentum - Never even saw that before, I remember using the check.if.already.open years ago (showing my age).1 point -
SciTE4AutoIt3 Issue in Dual Monitor Environment
Subz reacted to argumentum for a topic
actually, there is a menu: just deselect "Open Files Here" and that is sufficient. No need to "check.if.already.open=0" unless you want to make the behavior default. As far as I can see, it will open in the x,y,w,h it had last time you closed it. If that is not so for some darn reason, we can code around it with AutoIt1 point -
Nice idea to recurse the menu tree to find a leaf. FWIW : 1- It is kind of strange to see those prefixes to your variable names, consider using Best Coding Practices. 2- I think you should use _SendMessage instead of _WinAPI_PostMessage as it "returns without waiting for the thread to process the message". SendMessage waits until the thread has processes the request. It is more in line with the objective of the click menu IMO.1 point
-
Dynamic Variables from an Array
PnD reacted to JockoDundee for a topic
Good point. Though it was already getting clobbered performance-wise by the reg-ex1 point -
Unless you have Ave. or Ave, and having a loop to search for every possibilities will be costly (compare to the 1 liner SRE).1 point
-
Dynamic Variables from an Array
PnD reacted to JockoDundee for a topic
Perhaps searching for “ AVE “ would alleviate the problem.1 point -
[solved] StringFormat(), where is the StringFormatBuilder() ?
seadoggie01 reacted to jchd for a topic
That's simply because regexes (not only PCRE) are tools to match pieces of text but have no internal support for replacement, nor any other text processing. StringRegexReplace and similar features allow you to grab matched pieces from a subject and allow you to glue them verbatim at will, but there is no regex primitive to perform any transformation of the text pieces. Furthermore, even if PCRE offers built-in If-Then-Else and even recursive constructs, none of them is available in the "replace pattern": it isn't a regular regex pattern, just a string with interpolation of sequences similar to regex back-references: $1,$2,... or \1,\2,... or ...$(17),$(18),... This implies that applying any transformation to any piece of text output by the match phase has to be done by external code and --for a character translation-- a translation table in an external container, just as @mikell said. In Perl regex have support for Perl interpolation, that is invoke Perl code when certain matching condition occurs, but it's still code external to regex which will be acting then.1 point -
Retrieve file list based on file modified time
JockoDundee reacted to seadoggie01 for a topic
I'm pretty sure it wasn't folders giving me an issue, I looped through each file to check if it had been modified and copied if it had. Early on, I certainly had the idea to check the folder's LMD, but found that completely failed. When running the LMD comparison on files, I pretty consistently received both false positives and negatives iirc. Later, I found that the LMD is also based on each device's internal time, crippling the effectiveness of the program when backing up to a network drive. (In my case, our router never had the time set and the LMDs were off by a few years). I'm still not entirely sure how a backup program could be implemented better without hashing everything.1 point -
1. A small note (you probably just forgot ) : Use #include <FileConstants.au3> [...] ;Collect file list Local $aFileList = _FileListToArray($sSourceDir, default, $FLTA_FILES) instead of ;Collect file list Local $aFileList = _FileListToArray($sSourceDir) Otherwise the folders will also be listed. 2. Regarding LastModified date, I would like to quote a post written by @seadoggie01 : (I agree with that !) As far as I understand it, the date within the file name is the controlling element. The problem is just the sorting, since the month name is given as a shortened string. I would therefore modify @spudw2k approach a bit. Instead of a date, replace the month part in the original filename with a numeric value (Jan=01 ... Dec=12) and insert it into the additional column. The suggestions of @pseakins and @pixelsearch would also be a solution, of course .1 point
-
Imagesearch multiple founds
USSSR reacted to seadoggie01 for a topic
Are you sure you need to be using ImageSearch? This would probably be a lot easier with Controls or even UI Automation As for using _ImageSearch multiple times, I'm sure you can, but I'm unsure which ImageSearch UDF you're using. Change the parameters of the image search so you're avoiding the section of screen you've already searched. You'll need to know how your image search works (top to bottom, left to right, etc) to be able to cut out sections.1 point -
Hey guys, the code that I've written/borrowed below is mostly an example of using the commUDF listed at the bottom, just applied to an Arduino with accompanying Arduino code. Uses Serial communication to turn on a LED, then reads a response from the arduino and prints it in the console. I hope it helps Autoit Code: #include <CommMG.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $CMPort = 3 Global $CmBoBaud = 9600 Global $sportSetError = '' Global $CmboDataBits = 8 Global $CmBoParity = "none" Global $CmBoStop = 1 Global $setflow = 2 _CommSetPort($CMPort, $sportSetError, $CmBoBaud, $CmboDataBits, $CmBoParity, $CmBoStop, $setflow) If @error Then MsgBox(16, "Error!", "Can't connect to Arduino on port - " & $CMPort) Exit EndIf _CommSetRTS(0) _CommSetDTR(0) While 1 ; Just use to call function, doesn't need to be a loop. LED_ON() Sleep(100) LED_OFF() Sleep(100) WEnd Func LED_ON() _CommSendString("1") ;Sends the Arduino a string of "1" to turn on LED Local $ret = _CommGetLine(@CR, 100, 100) ; Waits for up to 100 for a carriage return response from Arduino. ConsoleWrite($ret & @CRLF) ;Print to Console. EndFunc ;==>LED_ON_OFF Func LED_OFF() _CommSendString("0") ;Sends Arduino string of "0" to turn off the LED Local $ret = _CommGetLine(@CR, 100, 100) ; Waits for up to 100 for a carriage return response from Arduino. ConsoleWrite($ret & @CRLF) ;Print to Console. EndFunc ;==>LED_BLINK_10 Arduino Code: int led = 12; void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(led, OUTPUT); } void loop() { // put your main code here, to run repeatedly: if (Serial.available()) { int data = Serial.read(); if (data == '1') //On { digitalWrite(led, HIGH); //writeslow(); Serial.print("The LED is on!"); } if (data == '0') //Off { digitalWrite(led, LOW); Serial.print("The LED is OFF!"); } } } Serial/Com port UDF this is all based on1 point