Jump to content

Recommended Posts

Posted

Here are the 2 snippets you need, then I'll explain the problem. (Also, sorry for lack of comments...well no comments...but it is AutoIt so pretty much straight forward)

Server

elseif $recvbuffer = "winlist" Then
        $winnumber = WinList()
        $sendbuffer = $winnumber[0][0]
        TCPSend($AcceptedSocket, $sendbuffer)
        $sendbuffer = ""
        $recvbuffer = TCPRecv($AcceptedSocket, 2)
        if $recvbuffer = "OK" Then
            for $i = 1 to $winnumber[0][0]
                TCPSend($AcceptedSocket, $winnumber[$i][0])
            Next
        EndIf
        $recvbuffer = ""

Client

Func WindowList()
    TCPSend($connection, "winlist")
    $recvbuffer = TCPRecv($connection, 2)
    dim $recvbuffer2
    TCPSend($connection, "OK")
    dim $WindowList[Number($recvbuffer)]
    For $i = 1 to $recvbuffer
        $recvbuffer2 = TCPRecv($connection, 80)
        $WindowList[($i-1)] = $recvbuffer2
    Next
    For $s = 1 to $recvbuffer
        _GUICtrlListAddItem($WinList, $WindowList[($s-1)])
    Next
EndFunc

Now whenever I try to test this, it doesn't give any compile errors, but when I call the WindowList function on the client, it gives me an error on this line:

dim $WindowList[Number($recvbuffer)]

Telling me :

Line 9 (File "C:\Documents and Settings\Owner\My Documents\Client.exe"):

dim $WindowList[Number($recvbuffer)]
dim $WindowList[^ERROR

Error: Array variable subscript badly formatted.

Any ideas. ;)

Posted

What is the value of $recvbuffer before the dim statement?

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Posted (edited)

What is the value of $recvbuffer before the dim statement?

Its *supposed* to be the number of windows they have.

I got rid of the errors anyhow, but some wierd stuff is going on...

Here is the current code...

Server

elseif $recvbuffer = "winlist" Then
    ;Send How Many Windows We Have
        $winnumber = WinList()
        $sendbuffer = $winnumber[0][0]
        TCPSend($AcceptedSocket, $sendbuffer)
        $sendbuffer = ""
        
    ;Get OK and then send the name of each window
        $recvbuffer = TCPRecv($AcceptedSocket, 2)
        if $recvbuffer = "OK" Then
            for $i = 1 to $winnumber[0][0]
                TCPSend($AcceptedSocket, $winnumber[$i][0])
            Next
        EndIf
        $recvbuffer = ""
        
    EndIf

Client

Func WindowList()
;Send Command to Get Windows
    TCPSend($connection, "winlist")
;Recv how many windows they have
    $recvbuffer = TCPRecv($connection, 2)
    dim $recvbuffer2
;Send Confirmation
    TCPSend($connection, "OK")
;Make an array of 1
    dim $WindowListk[1]
;For loop to loop enough Recv's to recv their window list
    For $i = 1 to $recvbuffer
    ;Recv window name
        $recvbuffer2 = TCPRecv($connection, 80)
    ;if first window
        if $i = 1 Then
        ;assign to the first array slot
            $windowListk[0] = $recvbuffer2
        Else
        ;add a value to teh array of the next recved window
            _ArrayAdd($WindowListk, $recvbuffer2)
        EndIf
    Next
;for how many windows they had
    For $s = 1 to $recvbuffer
    ;add them to teh GUI list control
        _GUICtrlListAddItem($WinList, $WindowListk[($s-1)])
    Next
EndFunc

But now, call the function and nothing gets added to the List box(as you can see at the bottom _GUICtrlListAddItem()) but then I call it a second time and it gives me likes hundreds of windows, when I only have a couple open. Stuff like MSN Messenger Dummy window...and they are all on one line also.

Edited by Encryption

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
×
×
  • Create New...