Jump to content

stdio functions


Recommended Posts

I been trying to figure out how to use a progress bar to provide the user some eye candy while I process tasks in the background. I want the progress to true indicate to the user actual activity. I want the progress bar to move as I provide it updates and update the text messages within the progress bar. I have attempted 3 methods stdin/stdout console in/out, and finally TCP Server & client. The only one I have working is the TCP Server & Client method. I submitted it to the example forums, but nobody replied or followed up on the code I wrote.

Using the help from autoit
the progress bar function is pretty straight forward:


ProgressOn("Progress Meter", "Increments every second", "0 percent")
For $i = 10 to 100 step 10
    sleep(1000)
    ProgressSet( $i, $i & " percent")
Next
ProgressSet(100 , "Done", "Complete")
sleep(500)
ProgressOff()

So I changed it a little to work with updates in the TCP example: I submit a value of $pack to the function for the progress bar to change:

Func _ProgressBar($pack)
    If $pack = 1 Then
        ProgressOn("Single Sign-On", "Sign-On Progress", "0 percent")
        For $pack = 1 to 20 Step 5
        ProgressSet( $pack, $pack & " percent","Checking for the application")
        sleep(250)
        Next
    
    EndIf
    If $pack = 20 Then
        For $pack = 20 to 40 Step 5
        ProgressSet( $pack, $pack & " percent","Launching the application")
        sleep(250)
        Next
    EndIf
    If $pack = 40 Then
        For $pack = 40 to 60 Step 5
        ProgressSet( $pack, $pack & " percent","Waiting for Login dialog.")
        sleep(250)
        Next
        
    EndIf
    If $pack = 60 Then
        For $pack = 60 to 80 Step 5
        ProgressSet( $pack, $pack & " percent", "Submittng the Credentials")
        sleep(250)
        Next
        
    EndIf
    If $pack = 80 Then
        For $pack = 80 to 99 Step 5
        ProgressSet( $pack, $pack & " percent", "Checking the Login Results.")
        sleep(250)
        Next
        
    EndIf
    If $pack = 100 Then
        ProgressSet(100 , "Done", "Sign-On Complete")
        sleep(500)
        ProgressOff()
        Exit
    EndIf

So now the behavior of the progress is complete how to I update the process to pass status updates (values) to the $pack variable from another program.

The issue seems that if I launch the child process from another program and provide data thru a GUI the updates for $pack pass and the progressbar works great. If I close the parent program, I can never send it anymore updates. If I use TCP listen and TCp send the process works good, but I not sure I want to have a tcp server open and having to establish tcp connection every time I want to send the process an update.

StdoutRead ( process_id[, peek = false[, binary = false]] )

StdinWrite ( process_id[, data] )

ConsoleRead ( [peek = false[, binary = false ]])

ConsoleWrite ( "data" )

What I would like is to have a program which is running the progressbar and a update program with I can pass values to from another program.

progressbar.exe (opens the progress bar and remains open until I send a 100 value)

updateprogress.exe 10 sends a $pack value to the progressbar.exe program, which then updates the progressbar to 10%

Thanks for any help!

Roger Fleming

Link to comment
Share on other sites

I been trying to figure out how to use a progress bar to provide the user some eye candy while I process tasks in the background. I want the progress to true indicate to the user actual activity. I want the progress bar to move as I provide it updates and update the text messages within the progress bar. I have attempted 3 methods stdin/stdout console in/out, and finally TCP Server & client. The only one I have working is the TCP Server & Client method. I submitted it to the example forums, but nobody replied or followed up on the code I wrote.

Using the help from autoit
the progress bar function is pretty straight forward:

ProgressOn("Progress Meter", "Increments every second", "0 percent")
For $i = 10 to 100 step 10
    sleep(1000)
    ProgressSet( $i, $i & " percent")
Next
ProgressSet(100 , "Done", "Complete")
sleep(500)
ProgressOff()

So I changed it a little to work with updates in the TCP example: I submit a value of $pack to the function for the progress bar to change:

Func _ProgressBar($pack)
    If $pack = 1 Then
        ProgressOn("Single Sign-On", "Sign-On Progress", "0 percent")
        For $pack = 1 to 20 Step 5
        ProgressSet( $pack, $pack & " percent","Checking for the application")
        sleep(250)
        Next
    
    EndIf
    If $pack = 20 Then
        For $pack = 20 to 40 Step 5
        ProgressSet( $pack, $pack & " percent","Launching the application")
        sleep(250)
        Next
    EndIf
    If $pack = 40 Then
        For $pack = 40 to 60 Step 5
        ProgressSet( $pack, $pack & " percent","Waiting for Login dialog.")
        sleep(250)
        Next
        
    EndIf
    If $pack = 60 Then
        For $pack = 60 to 80 Step 5
        ProgressSet( $pack, $pack & " percent", "Submittng the Credentials")
        sleep(250)
        Next
        
    EndIf
    If $pack = 80 Then
        For $pack = 80 to 99 Step 5
        ProgressSet( $pack, $pack & " percent", "Checking the Login Results.")
        sleep(250)
        Next
        
    EndIf
    If $pack = 100 Then
        ProgressSet(100 , "Done", "Sign-On Complete")
        sleep(500)
        ProgressOff()
        Exit
    EndIf

So now the behavior of the progress is complete how to I update the process to pass status updates (values) to the $pack variable from another program.

The issue seems that if I launch the child process from another program and provide data thru a GUI the updates for $pack pass and the progressbar works great. If I close the parent program, I can never send it anymore updates. If I use TCP listen and TCp send the process works good, but I not sure I want to have a tcp server open and having to establish tcp connection every time I want to send the process an update.

StdoutRead ( process_id[, peek = false[, binary = false]] )

StdinWrite ( process_id[, data] )

ConsoleRead ( [peek = false[, binary = false ]])

ConsoleWrite ( "data" )

What I would like is to have a program which is running the progressbar and a update program with I can pass values to from another program.

progressbar.exe (opens the progress bar and remains open until I send a 100 value)

updateprogress.exe 10 sends a $pack value to the progressbar.exe program, which then updates the progressbar to 10%

Thanks for any help!

Roger Fleming

You could create a custom GUI with a progress bar control (vice using ProgressOn) and register WM_COPYDATA messages to it, or include a hidden input control and set the data in that. You could even send data through a temp file or registry key.

But the StdOutRead() and StdInWrite() depend on an internal AutoIt process that captures handles to the process IO streams at Run() time (if you specify the appropriate flags). I don't think you can pass it arbitrary process IDs that were not started by AutoIt with Run().

>_<

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Okay we are getting somewhere, I have figured out the process.

updateprocess

#include "MessageHandler.au3"
$Str = $cmdline[1];give a percentage value when executing the updater 'updatepgbar.exe 10'
$Local_ReceiverID_Name = "Script2sReceiverID";This is the ID that the other script will use to send data
$Remote_ReceiverID_Name = "Script1sReceiverID";This is the ID of the script we want to send data too
$hwnd = _SetAsReceiver($Local_ReceiverID_Name)
$iSent = _SendData($Str,$Remote_ReceiverID_Name)
Exit

Here is the active progressbar process code

#include "MessageHandler.au3"
$Local_ReceiverID_Name = "Script1sReceiverID";This is the ID that the other script will use to send data
$Remote_ReceiverID_Name = "Script2sReceiverID";This is the ID of the script we want to send data too

$hwnd = _SetAsReceiver($Local_ReceiverID_Name)
ConsoleWrite("hwnd of the Local_ReceiverID_Name is " & $hwnd & @crlf)
$update = _SetReceiverFunction("_progress")
ConsoleWrite("My data receiver function is " & $update & @crlf)

While 1
    Sleep(1000)
WEnd

Func _progress($pack)
    If $pack = 1 Then
        ProgressOn("Single Sign-On", "Sign-On Progress", "0 percent")
        For $pack = 1 to 20 Step 1
        ProgressSet( $pack, $pack & " percent","Checking for the application")
        ;sleep(250)
        Next
    EndIf
    If $pack = 20 Then
        For $pack = 20 to 40 Step 1
        ProgressSet( $pack, $pack & " percent","Launching the application")
        ;sleep(250)
        Next
    EndIf
    If $pack = 40 Then
        For $pack = 40 to 60 Step 1
        ProgressSet( $pack, $pack & " percent","Waiting for Login dialog.")
        ;sleep(250)
        Next
        
    EndIf
    If $pack = 60 Then
        For $pack = 60 to 80 Step 1
        ProgressSet( $pack, $pack & " percent", "Submittng the Credentials")
        ;sleep(250)
        Next
        EndIf
    If $pack = 80 Then
        For $pack = 80 to 99 Step 1
        ProgressSet( $pack, $pack & " percent", "Checking the Login Results.")
        ;sleep(250)
        Next
    EndIf
    If $pack = 100 Then
        ProgressSet(100 , "Done", "Sign-On Complete")
        sleep(500)
        ProgressOff()
        Exit
        EndIf
EndFunc

It leaves me with one question, How to pass variables from a command line variable $cmdline[1] and $cmdline[2] all the way to the other process as 2 seperate variables? I have tried a few things and the Array of variables breaks down during the process of sending it the progressbar. It would allow me to not to have the conditionals statements and allow customized values to be past to the progressbar. Please look a the _progress Function to understand why I want to do this.

Thanks in Advance,

Roger

Link to comment
Share on other sites

If you need to use a command line then this should help

If  $CMDLINE [0] = 0 then Exit

Local $Str
For $i = 1 to $CMDLINE[0]
    $Str &= "<" & $CMDLINE[$i] & "/>"
Next


$Local_ReceiverID_Name = "Script2sReceiverID";This is the ID that the other script will use to send data
$Remote_ReceiverID_Name = "Script1sReceiverID";This is the ID of the script we want to send data too
$hwnd = _SetAsReceiver($Local_ReceiverID_Name)
$iSent = _SendData($Str,$Remote_ReceiverID_Name)

Exit

Use this to get your array back in the progress script

#include <String.au3>
#include<Array.au3>
$aCMDLINE = _StringBetween($Str, "<", "/>")
_ArrayDisplay($aCMDLINE)
Edited by ChrisL
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...