Leaderboard
Popular Content
Showing content with the highest reputation on 12/12/2018 in all areas
-
A bit late but FYI this could also be done using ... guess what ? $txt = "[FirstSection]" & @crlf & _ "AutoInsertBasedOnCategory = true" & @crlf & _ "DeletingSectionPart = true" & @crlf & _ "AppendTextInLine = true" & @crlf & _ "RemoveSpacing = false" & @crlf & _ @crlf & _ "[SecondSection]" & @crlf & _ "CleanUpFile = true" & @crlf & _ "HideInvalidChar = false" & @crlf & _ "ChangeSentenceCase = true" & @crlf & _ "ChangeTitleCase = fale" Msgbox(0,"", $txt) $txt = _Example3($txt, "SecondSection", "; <== Example 3 this is the new line to be inserted =>") Msgbox(0,"", $txt) Func _Example3($txt, $section, $comment) Return StringRegExpReplace($txt, '\[' & $section & '\]\h*\R\K', $comment & @crlf) EndFunc1 point
-
Opt ("MustDeclareVars", 1) Every variables must be declared Local (or Global if required). It is a good practice to have this opt... In your particular case, there is no need to split your code into 2 functions, just grab riavvio code and insert it at the end of logout. All variables are declared in logout but not in riavvio !1 point
-
For To Step 11 times But 30 Lines ?
ahmeddzcom reacted to spudw2k for a topic
Why not something simpler? #Include <Misc.au3> $FL = @DesktopDir&"\p.txt" $N = 600 $Nm = 11 For $i = 1 To 30 FileWrite($FL,$N+($Nm*$i)&@CRLF) Next or even #Include <Misc.au3> $FL = @DesktopDir&"\p.txt" $N = 600 $Step = 11 $Nm = $Step For $i = 1 To 30 FileWrite($FL,$N+$Nm&@CRLF) $Nm += $Step Next Do you need to use Step in the for loop?1 point -
AutoIT including WebHooks for Discord
SolemnStrike reacted to Puls3 for a topic
Took me a while but I figured this out for my own use, hope it helps you out as well! Also remember to switch out the Discord webhook URL for your own. This requires nothing but an up to date AutoIt, cheers! Webhook("Awesome") Func Webhook($Message) Local $Url = "https://discordapp.com/api/webhooks/sensitive-data-goes-here" Local $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") Local $Packet = '{"content": "' & $Message & '"}' $oHTTP.open('POST',$Url) $oHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded") $oHTTP.send($Packet) EndFunc WARNING! This code doesn't work as of January 2nd, 2020! Read down a bit for an updated function.1 point -
Ahem, this is 31 lines actually.1 point
-
Inserting new line in multiple section heads in text file
KickStarter15 reacted to Subz for a topic
Actually just did some testing on my system and the 32kb issue didn't appear to make a difference, I had a 7000 sections with 20 items each 2.3mb file but the code above worked fine for me, I had issues previously with Windows 7 but Windows 10 seems to handle that limitation. Anyway here are updated examples: #include <Array.au3> #include <File.au3> Local $sFilePath = @ScriptDir & "\data.ini" Local $aSectionNames = IniReadSectionNames($sFilePath) If @error Then Exit _Example1("Section1", "; <== Example 1 this is the new line to be inserted |=>", 1) _Example1("Section4", "; <== Example 1 this is the new line to be inserted |=>", 1) _Example1("Section6", "; <== Example 1 this is the new line to be inserted |=>", 1) _Example2("Section2", "; Example 2 this is the new line to be inserted") _Example2("Section3", "; Example 2 this is the new line to be inserted") _Example2("Section7", "; Example 2 this is the new line to be inserted") ;~ Example 1 Func _Example1($_sSectionName, $_sComment, $_iInsert = 1) Local $iInsert Local $aSection = IniReadSection($sFilePath, $_sSectionName) If @error Then Return Local $iInsert = $_iInsert < 1 Or $_iInsert > $aSection[0][0] ? 1 : $_iInsert _ArrayInsert($aSection, $iInsert, $_sComment) IniWriteSection($sFilePath, $_sSectionName, $aSection) EndFunc ;~ Example 2 Func _Example2($_sSectionName, $_sComment) Local $aSection _FileReadToArray($sFilePath, $aSection, $FRTA_COUNT) For $i = $aSection[0] To 1 Step - 1 If $aSection[$i] = "[" & $_sSectionName & "]" Then _FileWriteToLine($sFilePath, $i + 1, $_sComment) Next EndFunc1 point -
Can I modify the properties of an existing Windows service?
TheLug reacted to JLogan3o13 for a topic
Short answer, yes you can. Slightly longer answer - open command line, type sc config /? and hit enter. Happy reading1 point -
Reading pixel colors from few windows at same time
Earthshine reacted to Bert for a topic
Several things If you want to look at a pic as you show in the video, then why not just look at the pic and not windows explorer view? Why do you need to use pixel searching in the first place? Have you tried to ID the control in question? Using pixel searching is VERY UNSTABLE and causes many scripts to break. What is the ACTUAL application you are wanting to automate? I ask for in MANY CASES there is a script that will do it so having to reinvent the wheel is a waste of time when we can point you in the right direction.1 point -
First try simplespy.au3 and inspect.exe on calc.exe to see if all is available on your windows system. Depending on ui hierarchy it could be that techically another transparent group element is over your button. So although human visible button tools see the top most window first.1 point
-
marko001, I would read the files into arrays and then deal with it in memory. I created a 1500-line file with this code: $hFile = FileOpen("List_1.txt", 1) For $i = 1 To 1500 FileWriteLine($hFile, "<z:row First_Name='" & $i & "' Last_Name='" & $i & "' Country =' ' Age=' '") Next FileClose($hFile) I copied it to a second file and deleted a few lines to force some errors. Then I ran this code to compare the two files: #include <File.au3> #include <Array.au3> ; Declare the 2 arrays Global $aFile_1, $aFile_2 ; Start a timer $iBegin = TimerInit() ; Read the 2 files into the arrays _FileReadToArray("List_1.txt", $aFile_1) _FileReadToArray("List_2.txt", $aFile_2) ; For the lines you want For $i = 35 To $aFile_1[0] - 2 ; Does this line in the forst file exist in the second _ArraySearch($aFile_2, $aFile_1[$i]) If @error Then ; If not then add to the second _ArrayAdd($aFile_2, $aFile_1[$i]) $aFile_2[0] += 1 EndIf Next ; Write the new file = second file plus additional entries _FileWriteFromArray("List_Combined.txt", $aFile_2, 1) ; Display the time ConsoleWrite("Time taken = " & Round(TimerDiff($iBegin) / 1000, 2) & " secs" & @CRLF) Takes less than 3 secs for it to check the 1500 lines and the final file has all the missing entries added. Will that do? M231 point
-
How about this? It sorts the two arrays in ascending order. Every value of Array1 is compared to the elements in Array2 till element2 is equal or higher. Then the next element1 is used. Both arrays are only process once. #include <Array.au3> #include <Math.au3> Global $sString1 = "01,02,03,04,05,06,07,08,09,10,11,12,13,14,15" Global $sString2 = "06,07,08,09,10,11,12,13,14,15,16,17,18,19,20" Global $iCount = 0 Global $iIndex1, $iIndex2 = 1 Global $aArray1 = StringSplit($sString1, ",") Global $aArray2 = StringSplit($sString2, ",") _ArraySort($aArray1, 0, 1) _ArraySort($aArray2, 0, 1) For $iIndex1 = 1 To $aArray1[0] For $iIndex2 = $iIndex2 To $aArray2[0] If $aArray1[$iIndex1] < $aArray2[$iIndex2] Then $iIndex2 = _Max($iIndex2 - 1, 1) ExitLoop EndIf If $aArray1[$iIndex1] = $aArray2[$iIndex2] Then $iCount = $iCount + 1 ExitLoop EndIf Next Next ConsoleWrite($iCount & @CRLF) An example with 2000 random numbers takes about 2.5 seconds to run.1 point