Jump to content

Attach StdoutRead() to "old" $iPID


Recommended Posts

This code outputs the Stdout Stream as Tooltip:

Local $run=Run(@ScriptDir & '\application.exe',@ScriptDir,@SW_HIDE,1+2+4)

$tooltip=''

While 1
    $line = StdoutRead($run, False, False)
    $tooltip &= $line
    ToolTip($tooltip)
    Sleep(10)
WEnd

However, this does not output anything:

Local $iPid='1234'

If IsString($iPid) Then $iPid = ProcessExists($iPid)

$tooltip=''

While 1
    $line = StdoutRead($iPid, False, False)
    $tooltip &= $line
    ToolTip($tooltip)
    Sleep(10)
WEnd

Is it not possible to attach StdoutRead() to "old" processes / windows?

Link to comment
Share on other sites

  • Moderators

PID is an integer

Are you trying to intercept another apps stdout stream that you haven't ran yourself?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

PID is an integer

 

I also unsuccessfully tried it with:

Local $iPid=1234 ;no quotes
Local $iPid=Int(1234)

... which should both be an integer. So this doesn't seem to be the culprit here.

 

Are you trying to intercept another apps stdout stream that you haven't ran yourself?

 

I don't know exactly what you are referring to. Just consider the first example in my first post being split into two scripts, where the first part runs the application, and the second tries to intercept this apps' stdout stream (in contrast to having one script run and then interceps this apps' stdout stream).

Link to comment
Share on other sites

According to the help file for StdOutRead.

 

StdoutRead() reads from the console standard output stream of a child process, which is normally used by console applications to write to the screen.

You'd have to run the program from your script to be able to read from the StdOut streams from what I'm reading here.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

ok, thank you for the clarification.

Seems like there is no workaround either:

ParentProcessId

Data type: uint32

Access type: Read-only

Unique identifier of the process that creates a process. Process identifier numbers are reused, so they only identify a process for the lifetime of that process. It is possible that the process identified by ParentProcessId is terminated, so ParentProcessId may not refer to a running process. It is also possible that ParentProcessId incorrectly refers to a process that reuses a process identifier. You can use the CreationDate property to determine whether the specified parent was created after the process represented by this Win32_Process instance was created.

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...