RogFleming Posted July 28, 2009 Share Posted July 28, 2009 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. expandcollapse popupUsing 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 More sharing options...
PsaltyDS Posted July 29, 2009 Share Posted July 29, 2009 (edited) 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. expandcollapse popupUsing 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 July 29, 2009 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 More sharing options...
RogFleming Posted August 4, 2009 Author Share Posted August 4, 2009 Tell me more about using WM_COPYDATA sounds good. thanks in advance. Roger Link to comment Share on other sites More sharing options...
ChrisL Posted August 4, 2009 Share Posted August 4, 2009 Tell me more about using WM_COPYDATA sounds good.thanks in advance.RogerLook herehttp://www.autoitscript.com/forum/index.php?showtopic=77979 [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
RogFleming Posted August 7, 2009 Author Share Posted August 7, 2009 Look here http://www.autoitscript.com/forum/index.php?showtopic=77979 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 expandcollapse popup#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 More sharing options...
ChrisL Posted August 8, 2009 Share Posted August 8, 2009 I'm confused why you still need to use commandlines? [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
ChrisL Posted August 8, 2009 Share Posted August 8, 2009 (edited) 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 August 8, 2009 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now