Jump to content

Writing to input stream of a process NOT launched by AutoIt scripts


 Share

Recommended Posts

Hello,

I have an issue with writing data to the input stream of a process that was not launched by AutoIt functions (Run function).

I have this process tree:

RAServer.exe (remote agent controller for Junit testing)

-> CMD.exe

-> setupWIN.exe

-> java.exe

It would be of tremendous help if I could write to the input stream of java.exe (java.exe is launched by setupWIN.exe)

I tried to write data using StdinWrite (I gave the pid obtained from tasklist) but it didn't work.

When setupWIN.exe is launched by the RAServer.exe (as the example above), I do not have access to the console of java.exe.

That is why I cannot use the Send function to simulate pressing keys. Therefore, I turned my attention to using processes

but it seems that StdinWrite doesn't work.

Do you have any idea how could I write data to the input stream of java.exe?

Any help will be greatly appreciated.

Thank you.

Link to comment
Share on other sites

  • 1 year later...

Sorry for bumping this here, but the issue here also pertains to mine. Here's my code thus far; it doesn't seem to function despite being tinkered with for several hours =.="

#include <Constants.au3>
#include <GuiConstantsEx.au3>
 
$mGUI = GUICreate('My Test GUI', 800, 550, -1, -1)
 
$sProc = Run('cmd.exe', @ScriptDir, @SW_HIDE, $STDIN_CHILD + $STDERR_MERGED)
 
$sText = GUICtrlCreateEdit('', 10, 10, 780, 500)
$sInput = GUICtrlCreateInput('', 10, 520, 700, 20)
$sEnter = GUICtrlCreateButton('Send', 720, 520, 70, 20)
 
GUISetState(@SW_SHOW, $mGUI)
 
While 1
    $msg = GUIGetMsg($mGUI)
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ProcessClose($sProc)
            ExitLoop
        Case $sEnter
            If GUICtrlRead($sInput) <> '' Then
                StdinWrite($sProc, GUICtrlRead($sInput))
                GUICtrlSetData($sInput, '')
            EndIf
    EndSwitch
 
    If ProcessExists($sProc) Then
        $sRead = StdoutRead($sProc)
 
        If $sRead <> '' Then
            $sRead = StringReplace($sRead, @LF, @CRLF)
 
            $sRead = GUICtrlRead($sText) & $sRead
            GUICtrlSetData($sText, $sRead)
        EndIf
    EndIf
WEnd
Edited by BoonPek
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...