Leaderboard
Popular Content
Showing content with the highest reputation on 06/08/2019 in all areas
-
Positions of searchstring in a string
FrancescoDiMuro and one other reacted to Gianni for a topic
Hi @iamtheky, actually it looks like that counting ops be quicker in the loop than stringinstr op here I've modified my previous listing trying to speed up StringInString by limiting the range of the search for each loop, nonetheless, even if quite improved, StringInString remains slower Local $String = '111AB11111111AB11AB111111AB11', $key = "AB" Local $r, $x = StringLen($String) For $i = 1 To StringSplit($String, $key, 1)[0] - 1 $x = StringInStr($String, $key, 1, -1, $x) $r = ',' & $x & $r Next MsgBox(0, 'result', StringTrimLeft($r, 1)) following is a list of all attempts in this thread to compare execution speeds for each with a final ranking in the _ArrayDisplay #include<array.au3> Global $String = '111AB11111111AB11AB111111AB11', $key = "AB" ; make a bigger string For $i = 1 To 10 $String &= $String Next Local $sCompetitors = "chimp1;iamtheky1;francescodimuro;mikell;chimp2;iamtheky2" Local $aCompetitors = StringSplit($sCompetitors, ';'), $Timer Local $aRanking[$aCompetitors[0]][2] For $Rider = 0 To $aCompetitors[0] - 1 $aRanking[$Rider][0] = $aCompetitors[$Rider + 1] $Timer = TimerInit() $Result = Call($aCompetitors[$Rider + 1]) $aRanking[$Rider][1] = Int(TimerDiff($Timer)) ConsoleWrite($aRanking[$Rider][0] & "'s result" & @CRLF) If IsArray($Result) Then ConsoleWrite(_ArrayToString($Result, ',') & @CRLF) Else ConsoleWrite($Result & @CRLF) EndIf ConsoleWrite("--------------------" & @CRLF) Next _ArraySort($aRanking, 0, 0, 0, 1) _ArrayDisplay($aRanking, "final ranking") Func iamtheky1() Local $pos, $i Do $i += 1 $pos &= StringInStr($String, "AB", 1, $i) & "," Until StringRight($pos, 3) = ",0," Return StringTrimRight($pos, 3) EndFunc ;==>iamtheky1 Func francescodimuro() Local $intOffset, _ $strReturn While 1 StringRegExp($String, $key, $STR_REGEXPARRAYMATCH, $intOffset) If @error Then ExitLoop $intOffset = @extended $strReturn &= ($intOffset - StringLen($key)) & "," WEnd Return StringLeft($strReturn, StringLen($strReturn) - 1) EndFunc ;==>francescodimuro Func mikell() Local $r = "", $x For $i = 1 To StringLen($String) $x = StringInStr($String, $key, 1, $i) $r &= $x ? $x & ',' : "" Next Return StringTrimRight($r, 1) EndFunc ;==>mikell Func chimp1() Local $r For $i = 1 To StringSplit($String, $key, 1)[0] - 1 $r &= StringInStr($String, $key, 1, $i) & ',' Next Return StringTrimRight($r, 1) EndFunc ;==>chimp1 Func chimp2() Local $r, $x = StringLen($String) For $i = 1 To StringSplit($String, $key, 1)[0] - 1 $x = StringInStr($String, $key, 1, -1, $x) $r = ',' & $x & $r Next $r = StringTrimLeft($r, 1) Return $r EndFunc ;==>chimp2 Func iamtheky2() Local $aStr = StringSplit($String, $key, 3), $x = 1 _ArrayPop($aStr) For $i = 0 To UBound($aStr) - 1 $x += StringLen($aStr[$i]) $aStr[$i] = $x $x += 2 ; length of $sMatch Next Return $aStr EndFunc ;==>iamtheky22 points -
How can I convert my AutoIT application into C++?
Earthshine and one other reacted to TheDcoder for a topic
What kind of code analysis test? There is no way to convert automatically your AutoIt code to a C variant, and definitely not code which could be human readable. Your options are to either convince them to perform a manual code analysis on your script or rewrite the whole thing in C/C++2 points -
This is a too common misconception. Tell them they walk on a path that does not lead to the top of the mountain. Most (if not all code) analysis tools can be viewed —in the very best case only— as "assigning meaning to programs" after the facts, in the sense of R. Floyd. This is exactly the same thing as trying to understand in great details all the semantic subtilties of a significantly large Klingon text, by just knowing the Klingon alphabet. Obviously such approach gains you zero guaranteed knowledge about the dangerousness of the actual Klingon intents against your planet or civilization. Monthly (weekly, daily) "vulnerability patches" from MS and others illustrate the fact. If your client really cares about security and correctness of the programs they want to use, they should think the opposite way: "assign programs to meanings": https://www.researchgate.net/publication/220695256_The_B-book_-_assigning_programs_to_meanings I don't expect generic IT staffs to go that route so the best you can do if setup a code review task force on the AutoIt source or write a formally proven correct B0 to AutoIt converter and re-develop the project with B method, down to proven-correct AutoIt code. Just get warned that the latter way isn't completely trivial.1 point
-
help me _IEGetObjByName
FrancescoDiMuro reacted to Jos for a topic
This whole "Tiktok - I want to add fiends stuff with VipTools.es" seems to be against theis TOS: So thread locked and this topic will not be discussed anymore. Jos1 point -
Companion program GetGOG Wishlist, has been updated to v1.6. Added a new screenshot. See Post #14. (v1.3) Bugfix for Webpage (overlooked adjustment for added column). Program window height reduced so I can fit my 'IonGog Wishlist' program on screen without overlap. (v1.4) Program given a Search option, using the Title field with a FIND button. Status is now displayed in the Title field, rather than using a Splash. Improved aborting with Stop. (v1.5) Color and minor improvements added to status changes. (v1.6) Backups now occur for the 'Games.ini' file (per user account), which can be manually restored at need. Program Information and feedback has been improved. More information added to end of the 'History.txt' file. NOTE - The 'Games.ini' file, is a record of initial price for each game as it is added, and only changes when that price gets lower. The program uses it during every update, to do a comparison. Colored Lines At A Glance NOTE - All these colors are the background color for a line, not the text color. Unchanged price since addition, will show (after initial Light Blue) one of the two default color lines, which alternate between Pale Pink and Pale Green. RED = Current price is much higher than last recorded price. More than 20 cents dearer. ORANGE = Current price is slightly higher than last recorded price. GREEN = Current price is lower than last recorded price. NOTE - Only displayed after an update. PINK = Price currently remains unchanged, but lower than when added. LIGHT BLUE = New addition to the list or price was free ($0.00) when added.1 point
-
How to remove a global variable?
Exit reacted to argumentum for a topic
I have no idea of just why you'd want to do that but maybe you can use something like this ? Func MyLocalStaticVar($var = Default) Local Static $myVar If $var = Default Then Return $myVar $myVar = $Var Return $myVar EndFunc1 point -
How to remove a global variable?
FrancescoDiMuro reacted to BrewManNH for a topic
Because you're redeclaring it as local inside the function every other iteration of the function call, just as I explained above. In the first call to the function, local $x isn't declared, so it's using the Global, the second call to the function is declaring a local variable with the same name so it uses the local. Every time you leave the function, the Local variable is destroyed, so it's no longer declared when you go back into it, until you declare it again. I don't see why that's hard to understand. Strong statement because it's true. Also, my comment had nothing to do with the Opt you used, that's just one way of doing things, that didn't really need to be done, as shown above. The terrible part was the point that you declared a Global inside a function, and then tried to use Global inside your If statement. Also thinking that a local variable will "kill" a global that way isn't killing anything, it's just giving a new value to your Global variable, and won't affect a local variable. This would have worked, but would still have been wrong to do it. If $i= 4 Then Global $x = 0 EndIf But, as the question has been answered, I'll leave it at this.1 point -
Based on the partial explanations you gave us, here what I did understand : Opt ("MustDeclareVars", 1) HotKeySet("{F9}", "_start") HotKeySet("^{F9}", "_start") HotKeySet("{F10}", "_stop") HotKeySet("^{F10}", "_stop") HotKeySet("{F11}", "_exit") HotKeySet("^{F11}", "_exit") Global $run While 1 Sleep(500) WEnd Func _stop() ; Stop the script $run = False EndFunc ;==>_stop Func _exit() ; Exit the script exit EndFunc ;==>_stop Func _start() Local $location $run = True While $run $location = PixelSearch(750, 293, 802, 346, 0xFF9717) ; search orange button If @error Then ; if no orange, what needs to be done ? Sleep (500) ; here to wait till it appears ContinueLoop EndIf MouseClick('left', $location[0], $location[1], 1) ; when found, click the orange button Sleep(5000) $location = PixelSearch(750, 293, 802, 346, 0x455865) ; search blue If not @error Then ; blue has appeared (means an error), what to do next ? MouseClick('left', $location[0], $location[1], 1) ; here to click the blue and start over Sleep (5000) ContinueLoop EndIf ; no blue means success then continue processing WEnd EndFunc ;==>_start1 point