Leaderboard
Popular Content
Showing content with the highest reputation on 12/04/2018 in all areas
-
must be easier way for getting the count and locations of occurence in strings ?
FrancescoDiMuro and 2 others reacted to mikell for a topic
A regex way... $s1 = "C:\user\xxx\bbb\aaa" $s2 = "C:\user\xxx\bbb\aaa\" $pattern = '[^\\]+\\?$' Msgbox(0,"", StringRegExpReplace($s1, $pattern, "")) Msgbox(0,"", StringRegExpReplace($s2, $pattern, "")) means : replace "one or more non-backslash and a backslash if exists, at the end of the string" with nothing3 points -
Here's one of many ways that it can be done: Example() Func Example() Local $sBefore = _ "Company name: galaxy-1" & @CRLF & _ "Address: 1st. sq, - build 1" & @CRLF & _ "Tel: 011-2333 - 055-2213" & @CRLF & _ "Fax: 033-11124423" & @CRLF Local $sAfter = StringRegExpReplace($sBefore, "\b(\d+)-(\d+)\b", "\1\2") ConsoleWrite("Before:" & @CRLF & $sBefore) ConsoleWrite(@CRLF) ConsoleWrite("After:" & @CRLF & $sAfter) EndFunc Output: Before: Company name: galaxy-1 Address: 1st. sq, - build 1 Tel: 011-2333 - 055-2213 Fax: 033-11124423 After: Company name: galaxy-1 Address: 1st. sq, - build 1 Tel: 0112333 - 0552213 Fax: 033111244232 points
-
Help spilitting string.
FrancescoDiMuro reacted to iamtheky for a topic
caveat: i dont know if this explanation helps, or makes it worse you only want to split on spaces preceded by double quotes, however spaces exist elsewhere. Replacing those spaces with a character that does not exist elsewhere in the string solves the problem by having a unique character to split on. *You could also stringsplit on more than one character '" ' and require the full match, but then you have to put stuff back at the end.1 point -
How to avoid copying arrays?
pixelsearch reacted to Melba23 for a topic
jasty, If you are looking to pass the array as a parameter to a function, AutoIt does not make a copy of the array unless you alter the array in some fashion - even then you should be able to use ByRef to prevent this. Can you explain in more detail just what you are trying to do? M231 point -
RegExp problem with * quantifier
FrancescoDiMuro reacted to mikell for a topic
FrancescoDiMuro is right. These are incompatible : (?<=<h3 class="clBlue marginTop">Poprzednie numery.*</h3>) You might try something like this instead (?:<h3 class="clBlue marginTop">Poprzednie numery.*</h3>)1 point -
must be easier way for getting the count and locations of occurence in strings ?
FrancescoDiMuro reacted to water for a topic
This works as long as there is no trailing backslash: #include <File.au3> Global $sFilePath = "C:\user\xxx\bbb\aaa", $sDrive, $sDir, $sFilename, $sExtension _PathSplit($sFilePath, $sDrive, $sDir, $sFilename, $sExtension) MsgBox(0, "Result", $sDrive & $sDir)1 point -
RegExp problem with * quantifier
pixelsearch reacted to FrancescoDiMuro for a topic
@mLipok Pasting your pattern in regex101, you'll see this: So, I don't think that's some PCRE "bug"1 point -
Help spilitting string.
FrancescoDiMuro reacted to Marc for a topic
@bourny Glad it helped.- In general, this Regex does the following: (?isU) ; setting the options for thr regex enine - Ignore case, interpret the string as one line and always use the shortest possible match when searching (.*) ; search for literally everything... and keep the matching text in the array = ; which is followed by an = ("[^"]*") ; which is followed by an ", followed by anything which is NOT a ", which is followed by an " - and keep the matching text in the array @FrancescoDiMuro Clever idea, I like it. Especially avoiding my clumsy reformatting of the array.1 point -
Help spilitting string.
Marc reacted to FrancescoDiMuro for a topic
@bourny You could use StringRegExpReplace() at your advantage as well Global $strTestString = 'CPU="AMD 64" OSType="64 bit" OS="Windows server 2012 R2" bootfirmware="Bios"', _ $strPattern = '(\w+)(?:=")([^"]+)(?:")(?:\s?)', _ $arrResult[1][2] _ArrayAdd($arrResult, StringRegExpReplace($strTestString, $strPattern, '\1|\2' & @CRLF)) If @error Then ConsoleWrite("Error while adding the array in the $arrResult. Error: " & @error & @CRLF) Exit Else _ArrayDelete($arrResult, 0) ; Deleting the first blank element _ArrayDelete($arrResult, UBound($arrResult) - 1) ; Deleting the last blank element _ArrayDisplay($arrResult) EndIf By the way, nice SRE @Marc1 point -
Help spilitting string.
FrancescoDiMuro reacted to Marc for a topic
Funny Problem First idea was "why isn't he splitting at the = marks?". Well, doh! Does not work... So one way to do it is using RegEx: #include <Array.au3> $String = 'CPU="AMD 64" OSType="64 bit" OS="Windows server 2012 R2" bootfirmware="Bios"' $aArrayOfEntries = StringRegExp($String, '(?isU)(.*)=("[^"]*")', 3) _ArrayDisplay($aArrayOfEntries) Global $aFinal[4][2] $line = 0 for $i= 0 to UBound($aArrayOfEntries)-2 Step 2 $aFinal[$line][0] = $aArrayOfEntries[$i] $aFinal[$line][1] = $aArrayOfEntries[$i+1] $line +=1 Next _ArrayDisplay($aFinal) best regards Marc1 point -
UIASpy - UI Automation Spy Tool
argumentum reacted to LarsJ for a topic
argumentum, This is exactly the information I'm looking for, thank you very much. There was one thing I forgot to tell. Calculation of the DPI scale factor is not performed dynamically. It's only performed once when UIASpy starts up. If the scale setting is changed on the display, UIASpy must be restarted to calculate the new DPI scale factor. I'll try to review the code once more during the day and maybe return with a new test later this evening.1 point -
complex issue in dos
boy15 reacted to JLogan3o13 for a topic
No idea what this is supposed to mean, care to elaborate?1 point -
UIASpy - UI Automation Spy Tool
LarsJ reacted to argumentum for a topic
Yes I did. I don't understand much, but it runs. If there is anything in particular you'd want me to try out, let me know. PS: I put one of my monitors at 100% and the other at 150%. Your code behaved well. No complains. PS2: pressing F4 while in the 150% monitor it gave me this: ..so a picture is like 1000 words. ..if this is what you're looking to test out. It does behave as expected at 100%.1 point -
I would go this way: ;... Global $hLabel = GUICtrlCreateLabel("", 245, 245, 100, 20) ;... Local Const $sFormat = "hh:mm:ss tt" Local $iLenStr = StringLen($sFormat) + 1 ; Allocate enough memory with PAGE_EXECUTE_READWRITE for code to run $aCall = DllCall("kernel32.dll", "ptr", "VirtualAlloc", _ "ptr", 0, _ "dword", 2 * $iLenStr + 512, _ "dword", 4096, _ ; MEM_COMMIT "dword", 64) ; PAGE_EXECUTE_READWRITE If @error Or Not $aCall[0] Then Return SetError(6, 0, 0) EndIf Local $pRemoteCode = $aCall[0] ; Make structure in reserved space Local $CodeBuffer = DllStructCreate("byte[512]", $pRemoteCode) ; Arrange strings in reserved space Local $tSpace = DllStructCreate("wchar Format[" & $iLenStr & "];wchar Result[" & $iLenStr & "]", $pRemoteCode + 512) DllStructSetData($tSpace, "Format", $sFormat) ; Write assembly If @AutoItX64 Then DllStructSetData($CodeBuffer, 1, _ "0x" & _ "4883EC" & SwapEndian(72, 1) & _ "C7442428" & SwapEndian($iLenStr, 4) & _ "48BF" & SwapEndian(DllStructGetPtr($tSpace, "Result")) & _ "48897C2420" & _ "49B9" & SwapEndian(DllStructGetPtr($tSpace, "Format")) & _ "49C7C0" & SwapEndian(0, 4) & _ "BA" & SwapEndian(0, 4) & _ "B9" & SwapEndian(1033, 4) & _ "48B8" & SwapEndian($pGetTimeFormatW) & _ "FFD0" & _ "49B9" & SwapEndian(DllStructGetPtr($tSpace, "Result")) & _ "49C7C0" & SwapEndian(0, 4) & _ "BA" & SwapEndian(12, 4) & _ "48B9" & SwapEndian(GUICtrlGetHandle($hControl)) & _ "48B8" & SwapEndian($pSendMessageW) & _ "FFD0" & _ "B9" & SwapEndian(491, 4) & _ "48B8" & SwapEndian($pSleep) & _ "FFD0" & _ "4883C4" & SwapEndian(72, 1) & _ "E9" & SwapEndian(-136) & _ "C3" _ ) Else DllStructSetData($CodeBuffer, 1, _ "0x" & _ "68" & SwapEndian($iLenStr) & _ ; push output size "68" & SwapEndian(DllStructGetPtr($tSpace, "Result")) & _ ; push pointer to output container "68" & SwapEndian(DllStructGetPtr($tSpace, "Format")) & _ ; push pointer to format string "68" & SwapEndian(0) & _ ; push NULL "68" & SwapEndian(0) & _ ; push 0 "68" & SwapEndian(1033) & _ ; push en-us Locale "B8" & SwapEndian($pGetTimeFormatW) & _ ; mov eax, [$pGetTimeFormatW] "FFD0" & _ ; call eax "68" & SwapEndian(DllStructGetPtr($tSpace, "Result")) & _ ; push pointer to the result "68" & SwapEndian(0) & _ ; push wParam "68" & SwapEndian(12) & _ ; push WM_SETTEXT "68" & SwapEndian(GUICtrlGetHandle($hControl)) & _ ; push HANDLE "B8" & SwapEndian($pSendMessageW) & _ ; mov eax, [$pSendMessageW] "FFD0" & _ ; call eax "68" & SwapEndian(491) & _ ; push Milliseconds "B8" & SwapEndian($pSleep) & _ ; mov eax, [$pSleep] "FFD0" & _ ; call eax "E9" & SwapEndian(-81) & _ ; jump back 81 bytes (start address) "C3" _ ; Ret ) EndIf ;...1 point