-
Posts
912 -
Joined
-
Days Won
1
Everything posted by Deye
-
For fun, a case sensitive search example #include <Array.au3> $file = "InstallSoftware.txt" _Read($file, 'Acrobat') _Read($file, 'Silverlight') _Read($file, 'Kaspersky') _Read($file, 'AnyConnect') _Read($file, 'Microsoft Visual C') Func _Read($file, $sString) $a = StringSplit(StringRegExpReplace(StringRegExp(FileRead($file), "(?i)[\w ]+\Q" & $sString & "\E.*", 1)[0], '\s{3,}', "|"), "|", 2) $a[0] = StringRegExpReplace($a[0], "(\d{4})(\d{2})(\d{2})(.*)", "$1/$2/$3") _ArrayDisplay($a, $sString) EndFunc
-
detect if csv data source or layout has changed
Deye replied to gcue's topic in AutoIt General Help and Support
Please post a sample data output here where the columns are separated by a delimiter so that we can take a look. that is sampling the old and the new output -
$sPattern first formed by @mikell Now I need it to work just the same but also to skip lines that contain " = GUICtrlCreateDummy()" #include <Array.au3> $sPattern = '(?ims)^\h*(?|(?:local|Global)\h+(\N+)|((?|\$|GUI[cs])\N+))(?=.*GUISetState)' _Read("GUICtrlCreateDummy.au3") _Read("_WinAPI_CallWindowProc.au3") _Read("GUICtrlCreateContextMenu[2].au3") Func _Read($file) Local $sPath = @ProgramFilesDir & "\AutoIt3\Examples\Helpfile\" _ArrayDisplay(StringRegExp(FileRead($sPath & $file), $sPattern, 3)) EndFunc TIA Edit: was a bit impatient posting this: so i just added this to the pattern and it works : .*[= ]\QGUICtrlCreateDummy()\E.*\R?(*SKIP)(?!)|
-
Thanks @TheXman Thank you all and the pastime hobby drill exercise
-
Thanks @jguinch with my test, in one occasion your cols function stripped out a header so so far this is what i have saved : Func _2DHeadersToArray($sVar = "") Local $cols = StringRegExpReplace(StringRegExpReplace($sVar, "(\w+)(.{2,})(\R)", "|$1"), "(?m)\R\R|\R\|.*", "") Local $values = StringRegExpReplace(StringRegExpReplace($sVar, "(\w+)(.{2,})(\R)", "$2"), "[\h]+\:[\h]", "|") Local $s = StringStripWS($cols, 2) & @CRLF & StringStripWS($values, 3) $s = StringRegExpReplace($s, "(?m)^\|", "") ConsoleWrite($s & @LF & @LF) StringReplace($cols, "|", "|") Local $a[0][@extended] _ArrayAdd($a, $s) Return $a EndFunc
-
Disable Desktop Context Menu
Deye replied to BackHomeAgain's topic in AutoIt General Help and Support
You can probably close them menus on the fly before you continue "things" ControlSend("Program Manager", "", "[CLASS:SysListView32; INSTANCE:1]", "{RCTRL}{ALT}") -
Thanks mikell, I've noticed now that there are more various adjustments involved Here is the more authentic data input for this exercise : #include <Array.au3> _ArrayDisplay(_pInfoProc("scite.exe")) _ArrayDisplay(_pInfoProc()) Func _pInfoProc($iPID = "") ; from name or pid $iPID = (IsInt($iPID) ? "-id " : $iPID ? "-name " : "") & StringRegExpReplace($iPID, "\..{3}", "") Local $sCommand = "Get-Process " & $iPID & "|Select-Object MainWindowHandle,Id,ProcessName,MainWindowTitle,Handles|Select -First 4" $iPID = Run(@ComSpec & " /c " & 'powershell -Command "' & $sCommand & '|Format-List"', "", @SW_HIDE, $stdout_child) ProcessWaitClose($iPID) Local $s = StdoutRead($iPID) Return _2DHeadersToArray($s) EndFunc ;==>_pInfoProc Func _2DHeadersToArray($sVar = "", $sDelim = ':') Local $s = StringRegExpReplace(StringStripWS($sVar, 1), "(\w+)(.{2,})(\R)", "$1|") $s = StringSplit(StringStripWS($s, 3), @CR)[1] Local $s1 = StringRegExpReplace(StringStripWS($sVar, 1), '(\w+)(.{2,})(\R)', "$2|") $s &= @CRLF & $s1 $s = StringRegExpReplace($s, "\|\R", @CRLF) Return _VarTo2D($s, "|", ":") EndFunc ;==>_2DHeadersToArray ; Thanks Chimp Func _VarTo2D($var, $sSeparator = @TAB, $sDelim = ":") $var = StringStripWS($var, 3) Local $aRows = StringSplit(StringStripCR($var), @LF), $aColumns, $aResult[$aRows[0]][1] For $iRow = 1 To $aRows[0] $aColumns = StringSplit($aRows[$iRow], $sSeparator) If $aColumns[0] > UBound($aResult, 2) Then ReDim $aResult[$aRows[0]][$aColumns[0]] For $iColumn = 1 To $aColumns[0] $aResult[$iRow - 1][$iColumn - 1] = StringRegExpReplace(StringStripWS($aColumns[$iColumn], 3), $sDelim, "") Next Next Return $aResult EndFunc ;==>_VarTo2D
-
Hey Chimp its StringRegExpReplace right you are, added one above
-
Every new paragraph ( from the second col - everything reading after ": " ) must be converted into a new row. $sVar = @LF & @CRLF _ & 'MainWindowHandle : 132730' _ & @LF & 'Id : 8808' _ & @LF & 'ProcessName : SciTE' _ & @LF & 'CPU : 112.15625' _ & @LF & 'Handles : 512' & @LF & @CRLF $sVar &= 'MainWindowHandle : 656932' _ & @LF & 'Id : 4268' _ & @LF & 'ProcessName : iexplore' _ & @LF & 'CPU : 0.15625' _ & @LF & 'Handles : 400' & @LF & @CRLF $sVar &= 'MainWindowHandle : 1182078' _ & @LF & 'Id : 6748' _ & @LF & 'ProcessName : explorer' _ & @LF & 'CPU : 12.09375' _ & @LF & 'Handles : 1230' & @LF & @CRLF $sVar &= 'MainWindowHandle : 1837220' _ & @LF & 'Id : 6868' _ & @LF & 'ProcessName : explorer' _ & @LF & 'CPU : 6.171875' _ & @LF & 'Handles : 552' & @LF & @CRLF the total outcome after processing, the data should look like so: $s = '' _ & 'MainWindowHandle|Id|ProcessName|CPU|Handles' _ & @LF & '132730|8808|SciTE|112.15625|512' _ & @LF & '656932|4268|iexplore|0.15625|400' _ & @LF & '1182078|6748|explorer|12.09375|1230' _ & @LF & '1837220|6868|explorer|6.171875|552' ConsoleWrite($s & @LF) at looking for fewer lines of code as possible to do this right $s = StringRegExpReplace($sVar, "(\w+)(.{2,})(\R)", "$1|") $s = StringRegExpReplace($s, "(.*\R)+(.*$)", "$1") ;~ ConsoleWrite($s & @LF) $s &= StringRegExpReplace($sVar, "(.{2,}\: )(.{2,})(\R)", "$2|") $s = StringRegExpReplace($s, "\R\R", "") $s = StringRegExpReplace($s, "\|\R", @CRLF) ConsoleWrite($s & @LF) TIA
-
Thanks mLipok, More or less of the workarounds I know of The point mainly referred to the natural idea that the function "should" be able to accept a variable (in the main case of our interest - coding Etc.)
-
Thanks Danp2, This is just a point made in order to illustrate the limitation.
-
#include <File.au3> $iPID = "scite.exe" _ArrayDisplay(ProcessList($iPID)) $iPID = "" _ArrayDisplay(ProcessList($iPID), "Won't Do") ; to put "ProcessList()" _ArrayDisplay(ProcessList(), "Does")
-
One more inspired by @jguinch #include <File.au3> Local $a[0][5], $stxt = "NewText.txt" _ArrayAdd($a, StringRegExpReplace(StringRegExpReplace(FileRead($stxt), "(?m)^\s+", ""), ' ', "|")) For $i = 0 To UBound($a) - 1 $a[$i][2] = Number($a[$i][2]) Next _ArraySort($a, 1, Default, Default, 2) ConsoleWrite(_ArrayToString($a, " ") & @LF)
-
Try and let us know how did it work for you #include <File.au3> Local $a[0][5], $stxt = "NewText.txt" _ArrayAdd($a, StringRegExpReplace(StringRegExpReplace(FileRead($stxt), "(?m)^\s+", ""), ' ', "|")) For $i = 0 To UBound($a) - 1 _ArraySwap($a, $i, _ArrayMaxIndex($a, 1, $i, -1, 2)) Next ConsoleWrite(_ArrayToString($a, " ") & @LF)
-
Simple mouse down and up script
Deye replied to MarkLeung's topic in AutoIt General Help and Support
No edit button for me ? edit : ok got it .. a little rusty .. -
Simple mouse down and up script
Deye replied to MarkLeung's topic in AutoIt General Help and Support
* Click to select the start of the drag and a second click to finish it. * Double click to select and highlight a word .etc Here's a way to start you off: #include <Misc.au3> Global $hDLL = DllOpen("user32.dll") HotKeySet("{F1} ", "HotKeyPressed") HotKeySet("{ESC}", "Close") ; Set ESC as a hotkey to exit the script. While 1 Sleep(100) WEnd Func __dragStartStop() While _IsPressed("70", $hDLL) Sleep(10) WEnd If _IsPressed("01", $hDLL) Then MouseUp("left") Else MouseDown("left") EndIf EndFunc ;==>__IsPressed Func HotKeyPressed() Local Static $hTimer = "881808965525" Local $fDiff = TimerDiff($hTimer) If Int($fDiff) > 200 Then __dragStartStop() $hTimer = TimerInit() Return EndIf ;double click determined $hTimer = TimerInit() MouseClick("left", Default, Default, 1) EndFunc ;==>HotKeyPressed Func Close() MouseUp("left") Exit EndFunc ;==>Close -
If True = "stringvalue" Then says it matches.
Deye replied to BigDaddyO's topic in AutoIt General Help and Support
Used alot In autoit code as we know it = the rule is that anything that is not equal to "0" or "" (empty string) automatically turns out to be true -
Mixed Base Conversion (coding challenge)
Deye replied to Gianni's topic in AutoIt General Help and Support
What you got ready to start testing ? ,if yet- 5 replies
-
- challenge
- coding challenges
-
(and 1 more)
Tagged with:
-
was sure i tried that ^^ , And again got ahead of myself , Sorry
-
What will do it ? Thanks #include <Array.au3> Local $arr[1][3] $arr[0][2] = 9 $arr[0][1] = "/" ;operator $arr[0][0] = 3 _ArrayDisplay($arr) MsgBox("", "", $arr[0][2] & $arr[0][1] & $arr[0][0]) MsgBox("", "", $arr[0][2] & Execute($arr[0][1]) & $arr[0][0])