Jump to content

winlist @_@


Recommended Posts

Dim $record

Dim $number_handle_there_already_is

Dim $is_it_new_handle

$number_handle_there_already_is = iniRead ( "handles.ini", 0, "number", "")

$counter = 0

$handle_array = winlist ( "txt" )

;~ If $record = $handle_array[0][0] Then

;~ MsgBox ( 0, "handle fault", "there isn't a new handle when winlist is called.")

;~ EndIf

If ($handle_array[0][0] - $record ) > 1 Then

MsgBox ( 0, "handle fault", "there is more than one new handle when winlist is called.")

EndIf

$array_live = winlist ("star wars galaxies") ; theoretically always bigger with 1

$array_record = IniRead ( "handle.ini", 1, "number", "")

$counter_1 = 0

$counter_2 = 0

Do

$counter_1 = $counter_1 + 1

Do

$counter_2 = $counter_2 + 1

$c = IniRead ("handles.ini", 1, $counter_2, "")

If $array_live[$counter_1][1] = $c Then

$is_it_new_handle = true

EndIf

if $is_it_new_handle = true Then

fileopen ( "newhandle.txt", 2)

FileWriteLine ( "newhandle.txt", $array_live[$counter_1][1] )

IniWrite ( "handles.ini", 1, ($number_handle_there_already_is + 1 ), $array_live[$counter_1][1] )

EndIf

$is_new_handle = false

Until $counter_2 = $number_handle_there_already_is

$counter_2 = 0

Until $counter_1 = $handle_array[0][0]

the syntax checked fine, yet when run this is returned:

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\python_codes\handle.au3"

C:\python_codes\handle.au3 (34) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

If $array_live[$counter_1][1] = $c Then

If ^ ERROR

>Exit code: 1 Time: 0.350

Link to comment
Share on other sites

It still runs infinitely since I don't really know what its doing

#include <Array.au3>

Dim $record
Dim $number_handle_there_already_is
Dim $is_it_new_handle

$number_handle_there_already_is = iniRead ( "handles.ini", 0, "number", "")
$counter = 0

$handle_array = winlist ( "txt" )

;~ If $record = $handle_array[0][0] Then
;~ MsgBox ( 0, "handle fault", "there isn't a new handle when winlist is called.")
;~ EndIf

If ($handle_array[0][0] - $record ) > 1 Then
MsgBox ( 0, "handle fault", "there is more than one new handle when winlist is called.")
EndIf
MsgBox(0,"",$handle_array[0][0])

$array_live = winlist ("SciTE") ; theoretically always bigger with 1
;$array_live = winlist ("star wars galaxies") ; theoretically always bigger with 1

;_ArrayDisplay($array_live)

;Check if any windows are returned
If ($array_live[0][0] = 0) Then
    MsgBox(0,"","ERROR - No matching windows found")
    
Else
    $array_record = IniRead ( "handle.ini", 1, "number", "")
    $counter_1 = 0
    $counter_2 = 0

    Do
        $counter_1 += 1
        Do
            $counter_2 = += 1
            $c = IniRead ("handles.ini", 1, $counter_2, "")

            If $array_live[$counter_1][1] = $c Then
                $is_it_new_handle = true
            EndIf
            
            if $is_it_new_handle = true Then
                fileopen ( "newhandle.txt", 2)
                
                FileWriteLine ( "newhandle.txt", $array_live[$counter_1][1] )
                IniWrite ( "handles.ini", 1, ($number_handle_there_already_is + 1 ), $array_live[$counter_1][1] )
            EndIf

            $is_new_handle = false

        Until $counter_2 = $number_handle_there_already_is
        $counter_2 = 0
    Until $counter_1 = $handle_array[0][0] ;You are setting $counter_1 to 1 on the first run, it will never be zero
EndIf
Link to comment
Share on other sites

Pretty obvious why you get the error..

the $array_live[$counter_1][1] is invalid if if there isn't a window with the title "star wars galaxies".

$counter_1 = 1 on the first loop...

So the return from $array_live = winlist ("star wars galaxies") wouldn't have $array_live[$counter_1][1] value.

Get how many windows match your Title..

$array_live[0][0] holds how many handels/titles that match your requested winlist.

So the counter shouldn't be greater then $array_live[0][0] amount , otherwise you get the error your getting.

Have you ever thought of using a MsgBox to debug what you write?

Cheers

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...