All Activity
- Past hour
-
Ping Pong Game with AutoItObject_Internal
Numeric1 replied to Gianni's topic in AutoIt Example Scripts
The tests previously conducted to assess the performance of the UDFs AutoItObject.au3 and AutoItObject_Internal.au3 under various conditions have highlighted discernible differences, albeit subtle. The analysis of the collected data underscores the slight preference in terms of speed for AutoItObject.au3. While this difference may not be considerable, it remains non-negligible in certain usage contexts. It is important to note that each UDF has its own advantages and disadvantages, which can influence their selection depending on the specific project requirements. The comparative table provided by @genius257 while informative, may spark debates and additional nuances regarding the evaluation of the performance and features of each UDF. Unfortunately, I no longer have the test code available. -
Fastest Way to Delete Empty Records in 1d Array
AspirinJunkie replied to gcue's topic in AutoIt General Help and Support
I have added a function and packed the whole thing into a speed comparison: #include <Array.au3> Global Const $aArrayRaw = Get_Array() Global $f_DecimalPlaces = 1 Global $iT, $a_Results[0][3] Func Get_Array() Local $aArray[1e6] For $i = 0 To UBound($aArray) - 1 $aArray[$i] = Random(0,2,1) = 2 ? " " : "x" Next Return $aArray EndFunc ;==>Get_Array ; the first measurement $aArray = $aArrayRaw ReDim $a_Results[UBound($a_Results) + 1][3] $a_Results[UBound($a_Results) - 1][0] = "Andreik" $iT = TimerInit() $aArray = _strip_Andreik($aArray) $iT = TimerDiff($iT) $a_Results[UBound($a_Results) - 1][1] = ($iT) ; the second measurement $aArray = $aArrayRaw ReDim $a_Results[UBound($a_Results) + 1][3] $a_Results[UBound($a_Results) - 1][0] = "SmOke_N" $iT = TimerInit() $aArray = _strip_SmOke_N($aArray) $iT = TimerDiff($iT) $a_Results[UBound($a_Results) - 1][1] = ($iT) ; the third measurement $aArray = $aArrayRaw ReDim $a_Results[UBound($a_Results) + 1][3] $a_Results[UBound($a_Results) - 1][0] = "Nine 1" $iT = TimerInit() $aArray = _stripNine1($aArray) $iT = TimerDiff($iT) $a_Results[UBound($a_Results) - 1][1] = ($iT) ; the fourth measurement $aArray = $aArrayRaw ReDim $a_Results[UBound($a_Results) + 1][3] $a_Results[UBound($a_Results) - 1][0] = "Nine 2" $iT = TimerInit() $aArray = _stripNine2($aArray) $iT = TimerDiff($iT) $a_Results[UBound($a_Results) - 1][1] = ($iT) ; the fifth measurement $aArray = $aArrayRaw ReDim $a_Results[UBound($a_Results) + 1][3] $a_Results[UBound($a_Results) - 1][0] = "AspirinJunkie" $iT = TimerInit() _strip_AspirinJunkie($aArray) $iT = TimerDiff($iT) $a_Results[UBound($a_Results) - 1][1] = ($iT) ; calculate results and print them out _ArraySort($a_Results, 0, 0, 0, 1) For $i = 0 To UBound($a_Results) - 1 $a_Results[$i][2] = Round($a_Results[$i][1] / $a_Results[0][1], 2) $a_Results[$i][1] = Round($a_Results[$i][1], $f_DecimalPlaces) Next _ArrayDisplay($a_Results, "Measurement Results", "", 16 + 64, Default, "name|time [ms]|factor") Func _strip_Andreik(ByRef $aData, $iStart = 0) If Not IsArray($aData) Then Return SetError(1, 0, False) Local $iElements = UBound($aData) If $iStart >= $iElements Then Return SetError(2, 0, False) Local $sResult For $Index = $iStart To $iElements - 1 $sResult &= (StringStripWS($aData[$Index], 8) ? $aData[$Index] & '|' : '') Next Return StringSplit(StringTrimRight($sResult, 1), '|', 2) EndFunc Func _stripNine1(ByRef $array, $iStart = 0) Local $sArray = StringRegExpReplace(_ArrayToString($array, Default, $iStart), "\|\s*$|(?<=\|)\s*\|", "") Return StringSplit(($iStart ? _ArrayToString($array, Default, 0, $iStart - 1) & "|" : "") & $sArray, "|", $STR_NOCOUNT) EndFunc Func _stripNine2(ByRef $array, $iStart = 0) Local $aTemp = _ArrayFindAll($array, "^\s*$", $iStart, Default, 0, 3) _ArrayInsert($aTemp, 0, UBound($aTemp)) _ArrayDelete($array, $aTemp) Return $array EndFunc ; $bNoWS = White spaces only count as empty element, true by default Func _strip_SmOke_N(ByRef $aArgs, $iStart = 0, $bNoWS = True) If UBound($aArgs, 2) Then Return SetError(1, 0, 0) ; out of bounds If $iStart = Default Or $iStart == -1 Then $iStart = 0 If $bNoWS = Default Or $bNoWS == -1 Then $bNoWS = True Local $iUB = UBound($aArgs) ; catch start out of bounds If $iStart < 0 Or $iStart > $iUB - 1 Then Return SetError(2, 0, 0) Local $aRet[$iUB] Local $iEnum = 0 ; build array without concatenation For $i = $iStart To $iUB - 1 If StringLen($aArgs[$i]) == 0 Then ContinueLoop If $bNoWS Then If StringRegExp($aArgs[$i], "(?m)^\s+$") Then ContinueLoop EndIf $aRet[$iEnum] = $aArgs[$i] $iEnum += 1 Next If $iEnum = 0 Then ; nothing found, but rather than return a false ; set error and return array where user can do what they want with it Return SetError(2, 0, $aArgs) EndIf ; resize return array ReDim $aRet[$iEnum] ; return extended as the ubound of new array Return SetExtended($iEnum, $aRet) EndFunc Func _strip_AspirinJunkie(ByRef $A, $iStart = 0, $iEnd = UBound($A) - 1) Local $x = 0 For $i = $iStart To $iEnd If StringIsSpace($A[$i]) Then ContinueLoop $A[$x] = $A[$i] $x += 1 Next Redim $A[$x] EndFunc Nine`s first function performs best, but would still have to be adapted to certain special cases for which it currently does not work, depending on the type of data: 1. if first array element is empty it`s still in the array 2. only line breaks are not recognized as empty strings (which may be correct depending on the context) and 3. if pipes ("|") occur in the strings. - Today
-
ioa747 reacted to a post in a topic: Ping Pong Game with AutoItObject_Internal
-
argumentum reacted to a post in a topic: A New Dimension for Snake Game: The Object-Oriented Version
-
Danyfirex reacted to a post in a topic: Ping Pong Game with AutoItObject_Internal
-
For comparative testing purposes I tried to translate the script created by @Numeric1 at this link which uses AutoitObject, so as to use AutoItObject_Internal.au3 by @genius257 instead. (The latter does not require additional DLLs.). Maybe it seems a little slower and slightly less responsive (?) P.S. I created a new thread just to not hijack @Numeric1's original thread. (any improvements and corrections relating to the translation of the listing are welcome) ; =============================================================================================================================== ; original script created by @Numeric1 at the link below ; https://www.autoitscript.com/forum/topic/211824-ping-pong-game-with-autoitobject/ ; =============================================================================================================================== ; Game Overview: ; - The game consists of a paddle and a ball. ; - The player controls the paddle using the left and right arrow keys. ; - The objective is to bounce the ball off the paddle and prevent it from hitting the bottom edge of the window. ; - If the ball hits the bottom edge, the game ends. ; - As the game progresses, the speed of the ball increases periodically, making it more challenging. ; Controls: ; - Left Arrow Key: Move the paddle to the left. ; - Right Arrow Key: Move the paddle to the right. ; - S Key: Pause the game. ; - When the game is paused, press Left or Right arrow key to resume. ; Enjoy playing Ping Pong! ; =============================================================================================================================== #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> ; #include "AutoItObject.au3" #include "AutoItObject_Internal.au3" ; <-- https://www.autoitscript.com/forum/topic/185720-autoitobject-pure-autoit #include <Misc.au3> Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") _GDIPlus_Startup() Const $COLOR_RED = 0xFFFF0000 Const $COLOR_GREEN = 0xFF00FF00 Func Ball($x = 0, $y = 0, $size = 5) Local $cBall = IDispatch() ; _AutoItObject_Class() With $cBall .dx = 10 .dy = -10 .size = $size .X = $x .Y = $y .__defineGetter("move", _move) EndWith Return $cBall ; .Object EndFunc ;==>Ball Func Paddle($x = 0, $size = 5) Local $cPaddle = IDispatch() ; _AutoItObject_Class() With $cPaddle .X = $x .size = $size .dx = 20 .__defineGetter("moveLeft", _moveLeft) .__defineGetter("moveRight", _moveRight) EndWith Return $cPaddle ; .Object EndFunc ;==>Paddle Func _moveLeft($this) $this.parent.X -= $this.parent.dx If $this.parent.X < 0 Then $this.parent.X = 0 EndFunc ;==>_moveLeft Func _moveRight($this) ; , $maxX) Local $maxX = $this.arguments.values[0] Local $paddleWidth = $this.parent.size If $this.parent.X + $this.parent.dx + $paddleWidth <= $maxX Then $this.parent.X += $this.parent.dx Else $this.parent.X = $maxX - $paddleWidth EndIf EndFunc ;==>_moveRight Func GamePanel() Local $hGUI = GUICreate("Ping Pong", 400, 300, -1, -1, $WS_SIZEBOX + $WS_SYSMENU) GUISetBkColor(0x000000) GUISetState() Local $aClient = WinGetClientSize($hGUI) If @error Then Return SetError(1, 0, 0) Local $iWidth = $aClient[0] Local $iHeight = $aClient[1] Local $aGDIMap[5] $aGDIMap[0] = _GDIPlus_GraphicsCreateFromHWND($hGUI) $aGDIMap[1] = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $aGDIMap[0]) $aGDIMap[2] = _GDIPlus_ImageGetGraphicsContext($aGDIMap[1]) $aGDIMap[3] = _GDIPlus_BrushCreateSolid($COLOR_RED) $aGDIMap[4] = _GDIPlus_HatchBrushCreate(4, $COLOR_GREEN) Local $Ball = Ball(40, 40) Local $paddleX = Paddle(150, 100) Local $cGamePanel = IDispatch() ; _AutoItObject_Class() With $cGamePanel .iWidth = $iWidth .iHeight = $iHeight .ball = $Ball .paddle = $paddleX .map = $aGDIMap .speedLevel = 100 .__defineGetter("move", _move) .__defineGetter("drawStage", _drawStage) .__defineGetter("cleanUpResources", _cleanUpResources) .__destructor(_cleanUpResources) .__defineGetter("runGameLoop", _runGameLoop) EndWith Return $cGamePanel ; .Object EndFunc ;==>GamePanel Func _move($this) Local $x = $this.parent.ball.X Local $y = $this.parent.ball.Y Local $dx = $this.parent.ball.dx Local $dy = $this.parent.ball.dy Local $Width = $this.parent.iWidth Local $Height = $this.parent.iHeight Local $BallSize = $this.parent.ball.size If $y + $dy >= ($Height - 40) And $x + $BallSize >= $this.parent.paddle.X And $x <= $this.parent.paddle.X + $this.parent.paddle.size Then $dy *= -1 EndIf If $y + $dy <= 0 Then $dy = Abs($dy) EndIf If $y + $dy >= $Height - $BallSize Then MsgBox(0, "Game Over", "You missed the ball! Game Over!") Exit EndIf If $x + $dx <= 0 Then $dx = Abs($dx) EndIf If $x + $dx >= $Width - $BallSize Then $dx = -Abs($dx) EndIf $x += $dx $y += $dy $this.parent.ball.dx = $dx $this.parent.ball.dy = $dy $this.parent.ball.X = $x $this.parent.ball.Y = $y $this.parent.drawStage() EndFunc ;==>_move Func _drawStage($this) Local $hGraphics = $this.parent.map[0] Local $hBitmap = $this.parent.map[1] Local $hGraphicsCtxt = $this.parent.map[2] Local $iX = $this.parent.ball.X Local $iY = $this.parent.ball.Y Local $iRadius = $this.parent.ball.size Local $padX = $this.parent.paddle.X Local $padH = $this.parent.iHeight - 40 _GDIPlus_GraphicsClear($hGraphicsCtxt, 0xFF000000) _GDIPlus_GraphicsFillEllipse($hGraphicsCtxt, $iX - $iRadius, $iY - $iRadius, $iRadius * 2, $iRadius * 2, $this.parent.map[3]) _GDIPlus_GraphicsFillRect($hGraphicsCtxt, $padX, $padH, $this.parent.paddle.size, 10, $this.parent.map[4]) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $this.parent.iWidth, $this.parent.iHeight) EndFunc ;==>_drawStage Func _cleanUpResources($this) ConsoleWrite("clean up ressources...." & @CRLF) Local $map = $this.parent.map _GDIPlus_GraphicsDispose($map[0]) _GDIPlus_BitmapDispose($map[1]) _GDIPlus_GraphicsDispose($map[2]) _GDIPlus_BrushDispose($map[3]) $this.parent.map = 0 _GDIPlus_Shutdown() EndFunc ;==>_cleanUpResources Func _runGameLoop($this) Local $speedUpTime = 5000 Local $lastMoveTime = TimerInit() Local $maxX = $this.parent.iWidth While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop If _IsPressed(25) Then $this.parent.paddle.moveLeft() If _IsPressed(27) Then $this.parent.paddle.moveRight($maxX) If _IsPressed(53) Then While 1 If _IsPressed(25) Or _IsPressed(27) Then ExitLoop Sleep(100) WEnd EndIf If TimerDiff($lastMoveTime) >= $speedUpTime Then $this.parent.speedLevel -= 5 If $this.parent.speedLevel < 0 Then $this.parent.speedLevel = 0 $lastMoveTime = TimerInit() EndIf $this.parent.move() Sleep($this.parent.speedLevel) WEnd EndFunc ;==>_runGameLoop Func _ErrFunc($oError) ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc ;================================================ Global $game = GamePanel() $game.runGameLoop() ConsoleWrite("------> the end <-------" & @CRLF) ; $game = 0 ;=================================================
- Yesterday
-
Gianni reacted to a post in a topic: Ping Pong Game with AutoItObject
-
A New Dimension for Snake Game: The Object-Oriented Version
Andreik replied to Numeric1's topic in AutoIt Example Scripts
Yes, why not? Whatever makes the game interesting and entertaining. -
A New Dimension for Snake Game: The Object-Oriented Version
Numeric1 replied to Numeric1's topic in AutoIt Example Scripts
I have taken note of your valuable suggestion. What do you think about this idea? : instead of making poisoned food appear, I thought about making a speed reducer appear to give the player more luck. What do you think ? -
Fastest Way to Delete Empty Records in 1d Array
Andreik replied to gcue's topic in AutoIt General Help and Support
Redim it's quite expensive with large arrays. With few indices every version is more than enough. -
Fastest Way to Delete Empty Records in 1d Array
Nine replied to gcue's topic in AutoIt General Help and Support
Those 2 seems faster : Func StripEmpty2(ByRef $array, $iStart = 0) Local $sArray = StringRegExpReplace(_ArrayToString($array, Default, $iStart), ""\|\s*$|(?<=\|)\s*\|"", "") Return StringSplit(($iStart ? _ArrayToString($array, Default, 0, $iStart - 1) & "|" : "") & $sArray, "|", $STR_NOCOUNT) EndFunc Func StripEmpty3(ByRef $array, $iStart = 0) Local $aTemp = _ArrayFindAll($array, "^\s*$", $iStart, Default, 0, 3) _ArrayInsert($aTemp, 0, UBound($aTemp)) _ArrayDelete($array, $aTemp) Return $array EndFunc -
Fastest Way to Delete Empty Records in 1d Array
SmOke_N replied to gcue's topic in AutoIt General Help and Support
That's pretty interesting. The regex overhead is the only thing that I can think of for that with a single redim. If I'm being honest, I didn't even see your post before I posted. And was to tired to test yours out once I posted lol. But proofs in the pudding so to speak. -
WebDriver UDF (W3C compliant version) - 2024/02/19
SOLVE-SMART replied to Danp2's topic in AutoIt Example Scripts
Hi @laohacbancho37, could you please create a new Thread for your question? Because I believe there could be more suggestions, questions and so on around your question. This would be helpful to you and other people too, am sure 🤝 . Thanks. Best regards Sven -
WebDriver UDF (W3C compliant version) - 2024/02/19
SOLVE-SMART replied to Danp2's topic in AutoIt Example Scripts
Hi @FrancoBordin, what do you want to achieve? Which header information are you interested in and why? Maybe there are other approaches then WebDriver 🤔 . Best regards Sven -
Fastest Way to Delete Empty Records in 1d Array
Andreik replied to gcue's topic in AutoIt General Help and Support
Doesn't seem to be faster not even with 1 million of records. #include <Array.au3> $iLen = 1 For $Index = 1 To 6 $iLen *= 10 $aData = BuildArray($iLen) ConsoleWrite('Records in array: ' & $iLen & @CRLF) ConsoleWrite('Empty records: ' & @extended & @CRLF) $iTimer = TimerInit() $aNew1 = StripEmptyRecords($aData, 0) ConsoleWrite(Round(TimerDiff($iTimer), 2) & ' ms' & @TAB) ConsoleWrite('Records: ' & UBound($aNew1) & @CRLF) $iTimer = TimerInit() $aNew2 = _StripEmptyElements($aData) ConsoleWrite(Round(TimerDiff($iTimer), 2) & ' ms' & @TAB) ConsoleWrite('Records: ' & UBound($aNew2) & @CRLF) ConsoleWrite(@CRLF) Next Func BuildArray($iLen) Local $aData[$iLen] Local $sData, $iEmpty = 0 For $Index = 0 To $iLen - 1 $sData = (Random(1, 10, 1) = 5 ? '' : RandomString(Random(10, 50, 1))) $aData[$Index] = $sData If Not $sData Then $iEmpty += 1 Next Return SetError(0, $iEmpty, $aData) EndFunc Func RandomString($iLen) Local Static $aChars = StringSplit('abcdefghijklmnopqrstuvwxyz', '') Local $sString For $Index = 1 To $iLen $sString &= $aChars[Random(1, $aChars[0], 1)] Next Return $sString EndFunc Func StripEmptyRecords(ByRef $aData, $iStart) If Not IsArray($aData) Then Return SetError(1, 0, False) Local $iElements = UBound($aData) If $iStart >= $iElements Then Return SetError(1, 0, False) Local $sResult For $Index = $iStart To $iElements - 1 $sResult &= (StringStripWS($aData[$Index], 8) ? $aData[$Index] & '|' : '') Next Return StringSplit(StringTrimRight($sResult, 1), '|', 2) EndFunc Func _StripEmptyElements(ByRef $aArgs, $iStart = 0, $bNoWS = True) If UBound($aArgs, 2) Then Return SetError(1, 0, 0) ; out of bounds If $iStart = Default Or $iStart == -1 Then $iStart = 0 If $bNoWS = Default Or $bNoWS == -1 Then $bNoWS = True Local $iUB = UBound($aArgs) ; catch start out of bounds If $iStart < 0 Or $iStart > $iUB - 1 Then Return SetError(2, 0, 0) Local $aRet[$iUB] Local $iEnum = 0 ; build array without concatenation For $i = $iStart To $iUB - 1 If StringLen($aArgs[$i]) == 0 Then ContinueLoop If $bNoWS Then If StringRegExp($aArgs[$i], "(?m)^\s+$") Then ContinueLoop EndIf $aRet[$iEnum] = $aArgs[$i] $iEnum += 1 Next If $iEnum = 0 Then ; nothing found, but rather than return a false ; set error and return array where user can do what they want with it Return SetError(2, 0, $aArgs) EndIf ; resize return array ReDim $aRet[$iEnum] ; return extended as the ubound of new array Return SetExtended($iEnum, $aRet) EndFunc Results: -
Fastest Way to Delete Empty Records in 1d Array
SmOke_N replied to gcue's topic in AutoIt General Help and Support
Doing it without concatenation may be faster for larger arrays. Based on what you're showing, you could do a simple for/next loop with a blank ret array or you could put in the bells and whistles to catch some errors like so: #include <Array.au3> Global $array = Get_Array() _ArrayDisplay($array) $array = _StripEmptyElements($array) _ArrayDisplay($array) Func Get_Array() Local $array[7] $array[0] = "12345" $array[1] = "01621" $array[2] = "xyz" $array[3] = "abc@defg.com" $array[4] = " john smith" $array[5] = " sally turner " $array[5] = " " & @CRLF & " " $array[6] = "zxy" Return $array EndFunc ;==>Get_Array ; $bNoWS = White spaces only count as empty element, true by default Func _StripEmptyElements(ByRef $aArgs, $iStart = 0, $bNoWS = True) If UBound($aArgs, 2) Then Return SetError(1, 0, 0) ; out of bounds If $iStart = Default Or $iStart == -1 Then $iStart = 0 If $bNoWS = Default Or $bNoWS == -1 Then $bNoWS = True Local $iUB = UBound($aArgs) ; catch start out of bounds If $iStart < 0 Or $iStart > $iUB - 1 Then Return SetError(2, 0, 0) Local $aRet[$iUB] Local $iEnum = 0 ; build array without concatenation For $i = $iStart To $iUB - 1 If StringLen($aArgs[$i]) == 0 Then ContinueLoop If $bNoWS Then If StringRegExp($aArgs[$i], "(?m)^\s+$") Then ContinueLoop EndIf $aRet[$iEnum] = $aArgs[$i] $iEnum += 1 Next If $iEnum = 0 Then ; nothing found, but rather than return a false ; set error and return array where user can do what they want with it Return SetError(2, 0, $aArgs) EndIf ; resize return array ReDim $aRet[$iEnum] ; return extended as the ubound of new array Return SetExtended($iEnum, $aRet) EndFunc -
Fastest Way to Delete Empty Records in 1d Array
gcue replied to gcue's topic in AutoIt General Help and Support
that works great! thank you @Andreik!! -
Fastest Way to Delete Empty Records in 1d Array
Andreik replied to gcue's topic in AutoIt General Help and Support
Since _ArrayToString() already traverse the entire array you can do it by yourself and meanwhile keep just non empty data: #include <Array.au3> $array = Get_Array() _ArrayDisplay($array) $array = StripEmptyRecords($array, 0) _ArrayDisplay($array) Func Get_Array() Local $array[7] $array[0] = "12345" $array[1] = "01621" $array[2] = "xyz" $array[3] = "abc@defg.com" $array[4] = " john smith" $array[5] = " sally turner " $array[5] = " " $array[6] = "zxy" Return $array EndFunc ;==>Get_Array Func StripEmptyRecords(ByRef $aData, $iStart) If Not IsArray($aData) Then Return SetError(1, 0, False) Local $iElements = UBound($aData) If $iStart >= $iElements Then Return SetError(2, 0, False) Local $sResult For $Index = $iStart To $iElements - 1 $sResult &= (StringStripWS($aData[$Index], 8) ? $aData[$Index] & '|' : '') Next Return StringSplit(StringTrimRight($sResult, 1), '|', 2) EndFunc -
Here is what I am using but maybe it can be done faster within this line and not have to go through the loop to test for empty values? Thanks in advance! $tmp_array = StringRegExpReplace($tmp_array, "\|\|+", "|") $array = Get_Array() _ArrayDisplay($array) $array = StripEmptyRecords($array, 0) _ArrayDisplay($array) Func Get_Array() Local $array[7] $array[0] = "12345" $array[1] = "01621" $array[2] = "xyz" $array[3] = "abc@defg.com" $array[4] = " john smith" $array[5] = " sally turner " $array[5] = " " $array[6] = "zxy" Return $array EndFunc ;==>Get_Array Func StripEmptyRecords($array, $start_row) $tmp_array = _ArrayToString($array, "|", $start_row) $tmp_array = StringStripCR($tmp_array) $tmp_array = StringRegExpReplace($tmp_array, "\|\|+", "|") If StringRight($tmp_array, 1) = "|" Then $tmp_array = StringTrimRight($tmp_array, 1) EndIf If StringLeft($tmp_array, 1) = "|" Then $tmp_array = StringTrimLeft($tmp_array, 1) EndIf $final_array = StringSplit($tmp_array, "|", 2) For $x = UBound($final_array) - 1 To 0 Step -1 If StringStripWS($final_array[$x], 8) = "" Then _ArrayDelete($final_array, $x) EndIf Next Return $final_array EndFunc ;==>StripEmptyRecords
-
A New Dimension for Snake Game: The Object-Oriented Version
Andreik replied to Numeric1's topic in AutoIt Example Scripts
When the snake is long enough the chance of food being spawn under the snake it's pretty high. It would be a good idea to check if the location where the food is spawn it's an empty space. Also it's very hard to eat a poison food (even if you want) if it's randomly spawn and the duration of being displayed it's so short. It would be more interesting if the food stays longer or if the poison food it's spawned in the proximity of the snake. -
SkysLastChance reacted to a post in a topic: BETA: SciTE v5x & lua Dynamic_include and "Smart" AutoComplete for Vars/UDFs/Abbrevs
-
Unable to click element in Teradata SQL Assistant
Andreik replied to Luli's topic in AutoIt General Help and Support
Try this: $hWin = WinWait('Teradata SQL Assistant') If IsHWnd($hWin) Then ControlClick($hWin, '', '[REGEXPCLASS:(?i)WindowsForms\d+\.Window\.\d+\.app\.\d+\.[a-z0-9_]+_ad1; INSTANCE:30]') -
SkysLastChance reacted to a post in a topic: Function hints in SciTe for user functions (like intellisense)
-
fraizor reacted to a post in a topic: _ArraySort is Not working correctly ?
-
_ArraySort is Not working correctly ?
Nine replied to fraizor's topic in AutoIt General Help and Support
Streamlined : #include "C:\Apps\AutoIt\JSON\json.au3" #include <Array.au3> $object = json_decode(FileRead("Test.json")) ;for local testing $Coins = json_get($object, '.data') Local $Chart[UBound($Coins)][2] for $i = 0 to UBound($Coins) -1 $Chart[$i][0] = json_get($object, '.data[' & $i & '].name' ) $Chart[$i][1] = Number(json_get($object, '.data[' & $i & '].quote.USD.percent_change_1h'), 3) Next _ArraySort($Chart, 3, Default, Default, 1) _ArrayDisplay($Chart) -
_ArraySort is Not working correctly ?
water replied to fraizor's topic in AutoIt General Help and Support
I see. Then I suggest: Global $iRow ; Loop starts here $iRow = _ArrayAdd($Chart,$name) $Chart[$iRow][1] = number($change_1h,3) -
_ArraySort is Not working correctly ?
ioa747 replied to fraizor's topic in AutoIt General Help and Support
#include "json.au3" #include <Array.au3> Dim $Chart[0][5] ; Array size of 2 columns $object = json_decode(FileRead("Test.json")) ;for local testing $Coins = json_get($object, '.data') for $i = 0 to UBound($Coins) -1 $name = json_get($object, '.data[' & $i & '].name' ) $change_1h = json_get($object, '.data[' & $i & '].quote.USD.percent_change_1h') _ArrayAdd($Chart,$name & "|" & number($change_1h,3) ) $Chart[$i][2] = VarGetType ( $Chart[$i][1] ) $Chart[$i][3] = number($change_1h,3) $Chart[$i][4] = VarGetType ( $Chart[$i][3] ) Next _ArraySort($Chart, 1, Default, Default, 3) _ArrayDisplay($Chart) -
_ArraySort is Not working correctly ?
fraizor replied to fraizor's topic in AutoIt General Help and Support
@waterThank you for your response i tried to Call _ArrayAdd twice, but it created spaces in the array ... _ArrayAdd($Chart,$name) _ArrayAdd($Chart, $change_1h,1 ) Still after adding each value alone it is still not sorting properly .. -
_ArraySort is Not working correctly ?
water replied to fraizor's topic in AutoIt General Help and Support
This code returns a String as AutoIt internally converts your number to a String again to be able to concatenate them. $name & "|" & number($change_1h,3) Call _ArrayAdd twice to fill the two columns. See the help file for details: "String datatype elements are sorted alphabetically and number datatype elements are sorted numerically - it is important to ensure that elements are of the correct datatype before sorting." -
Try using your own profile. See wiki of webdriver.
-
Hello I am on Firefox with a PAC proxy with authentication on Windows 10, all is working without AutoIt and the Proxy's username and password are not asked because it's s stored in Firefox. How can I use Firefox with AutoIt (webdriver, winhttp and other is installed): if I give my Proxy's username and password on each execution it works, but it's not pratical to use. How can I store the proxy password in the Firefox AutoIT environment? There are not many comments to use the constants and the functions in case of a Proxy use... No standard case is explained with proxy use... Thanks As regards A. (FRANCE)