I made this script to search for all open/visible windows with title which contains string ATHENA and put them into an array and after that arrange those windows side by side.
My problem is that I also whant at the end to delete the arrays completely.I have searched the forum , tried examples but I didn't managed to empty/delete the arrays.
#include <Array.au3>
Global $GUIVersion = "0.0"
Global $GUITitle = "Athena Windows Rearrange v" & $GUIVersion
Global $HandlesArray[1]
Global $TitlesArray[1]
$W=@DesktopWidth/2
$H=@DesktopHeight-25
Local $Paused
HotKeySet("{PAUSE}", "_TogglePause")
HotKeySet("{ESC}", "_Terminate")
#Region ### START Koda GUI section ### Form=g:\script\positons final\gui.kxf
;~ $GUI = GUICreate($GUITitle, 400, 400, -1, -1)
;~ GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
_CreateArrays()
$rows = UBound($TitlesArray)-1
If $rows = 0 Then
$msgtext = "Could not find any open ATHENA projects" & @CRLF & "Please open some for me !"
MsgBox ( 0, "Error", $msgtext)
ElseIf $rows = 1 Then
MsgBox(0, "Error", "I found just one ATHENA window" & @CRLF & "Nothing to do !")
Else
_RearangeWindows()
;_Delete ($TitlesArray)
;_Delete ($HandlesArray)
EndIf
Func _CreateArrays()
$var = WinList()
For $i = 1 to $var[0][0]
; Only display visble windows that have a title
If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then
$nOffset = 1 ;Option 1, using offset
$asResult=StringRegExp($var[$i][0], "ATHENA", 1, $nOffset) ; Search windows titles that contains "ATHENA" sting
If @error = 0 Then
_ArrayAdd($HandlesArray, $var[$i][1]) ; array with only "Athena" -handels-
_ArrayAdd($TitlesArray, $var[$i][0]) ; array with only "Athena" -title names-
;Else
;ExitLoop
EndIf
EndIf
Next
;~ _ArrayDisplay($HandlesArray, "Array: ATHENA handles")
;~ _ArrayDisplay($TitlesArray, "Array: ATHENA titles")
EndFunc ;==> Create arrays for existing Athena windows
Func IsVisible($handle)
If BitAnd( WinGetState($handle), 2 ) Then
Return 1
Else
Return 0
EndIf
EndFunc ;==> Checkes window state is visible
Func _RearangeWindows()
$WindowsNumber = UBound($TitlesArray)-1 ;total windows number in Titels Array
For $i=1 to $WindowsNumber
If Mod($i, 2) <> 0 Then ;check if a number is even or not
WinMove ($HandlesArray[$i], "",0 ,0 , $W, $H)
Else
WinMove ($HandlesArray[$i], "", @DesktopWidth/2, 0, $W, $H)
EndIf
Next
EndFunc ;==> Arange windows side by side
Func _TogglePause ()
$Paused = NOT $Paused
While $Paused
sleep(100)
ToolTip($GUITitle & ' is "Paused"',@DesktopHeight/2,@DesktopWidth/2, "", 0, 2)
WEnd
ToolTip("")
EndFunc ;==> TogglePause
Func _Terminate ()
MsgBox(0, $GUITitle, "Exit!")
Exit 0
EndFunc ;==> Terminate
This is what I tried
_Delete ($TitlesArray)
_Delete ($HandlesArray)
Func _Delete ($aArray)
For $i = 1 To Ubound($aArray)-1
_ArrayDelete($aArray, 0) ; Always the first element until $aArray = "" or nothing.
Next
;_ArrayDisplay($aArray, "Array after delete")
EndFunc