Jump to content

Recommended Posts

Posted

hi friends I'm new to this fabulous community, I ask you for a help to understand how I can redirect the standard output of a netcat, let me explain better:

I have a network application that sends me a stream of data I would like to take them and put them in a listbox updating them dynamically, I noticed that autoit is not multithreading , so I thought of having NetCat do the data reception and if it was possible to redirect the result to a listview, do you think it makes sense or are there better solutions like UDF? I have personally searched but I have not found anything that did for me, below the draft I wrote

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>


; End Initialization
#Region ### START Koda GUI section ###
$MainForm = GUICreate("Terminal", 303, 144, 344, 260)
$NRShellStart = GUICtrlCreateButton("Start", 12, 29, 129, 65)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$NRShellStop = GUICtrlCreateButton("Stop", 148, 29, 131, 65)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch

    Select
        Case $nMsg = $NRShellStart
            ;ShellExecute( @ScriptDir & "\nc64.exe", "-lvp 23456", "c:\")
            Local $text
            Local $Pid = Run( @ScriptDir & "\nc64.exe -lvp 23456", "", 2 + 4)
            $text &= StdoutRead($Pid, False, False)
            ConsoleWrite($text & @CRLF)
        Case $nMsg = $NRShellStop
            ProcessClose("nc64.exe")
 
    EndSelect
WEnd

thanks in advance to all those who want to answer

by Rob99

Posted (edited)

your run statement skips the show flag, see help file, that is why it doesn't work.

And the way you capture $text may not be enough to grab all data, usually it should be embedded in a loop.

And there is no reason why you have a switch and a select, you can combine those 2 into a single switch.

Edited by Nine

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
  • Recently Browsing   0 members

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