?
Solved

AutoIT - Howto "translate" command line output to a gui progress bar output via AutoIT

Posted on 2012-03-27
3
Medium Priority
?
2,111 Views
Last Modified: 2012-04-09
Is there a way and\or how would I go about "translating" the command output (for the progress) of this app (http://downloads.sourceforge.net/project/nfgdump/nfgdump/nfgdump-0.1/nfgdump-win32-binary.zip?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fnfgdump%2F&ts=1332884584&use_mirror=iweb) to a progress bar, via AutoIT?

nfgdump.exe " & $DumporRestore & " /v /p /c /g /o=gz /d=\Dev" & $Drive-X & " /f=t:\LinuxImageStore\" & $ImgName & ".img"

nfgdump.exe dump /v /p /c /g /o=gz /d=\Dev0 /f=c:\Images\myimage.img

Note: if possible, an example would prove most helpful.
0
Comment
Question by:2newbie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 29

Expert Comment

by:matrixnz
ID: 37775560
What does the output look like?
0
 

Author Comment

by:2newbie
ID: 37779145
the command output looks like this:



Dump of '\Dev0\1 (C:)' started: (UTC) Wed Mar 28 22:42:38 2012

1.69% (comp: 62.34%), 9.82 MB/s, finished in 01:03:11.



it is the first portion, section or parameter (the one that shows 1.69%) of the output that i wish to transfer into a progress bar. however, i would like the throughput (9.82 MB/s and finished in 01:03:11 displayed as well, if possible).

Thanks.
0
 
LVL 29

Accepted Solution

by:
matrixnz earned 2000 total points
ID: 37779504
Basically what needs to happen is you need to use STDOUT_CHILD to capture the output then you need to use StringSplit on the line using ',' as the delimiter.  This should give you an array with three  variables, you then use Number on the first variable to get 1.69 and then use Round to get a whole number, you can then update your progress bar with each of the three variables, i.e. $Var[1] = 2, $Var[2] = 9.82, $Var[3] = finished in 01:03:11

Below is an example, I haven't tested, but hopefully it'll get you started.
#include <Array.au3>
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>

Global $GUI_PROGRESS, $GUI_BUTTON, $RUN_NFGDUMP, $GUI_DATASTREAM, $GUI_FINISHEDIN

Example()

Func Example()
	Local $STD_NFGDUMP
	Local $DumporRestore = 'Dump or Restore'
	Local $Drive_X = 'Drive Letter'
	Local $ImgName = 'Image Name'
    GUICreate("NFGDUMP", 320, 100, 100, 200)
	GUICtrlCreateLabel('NFG Dump or Restore', 10, 15, 300, 20)
	GUICtrlSetFont(-1, 9, 800)
    $GUI_PROGRESS = GUICtrlCreateProgress(10, 40, 300, 20, $PBS_SMOOTH)
    $GUI_BUTTON = GUICtrlCreateButton("Start", 240, 70, 70, 20)
	$GUI_DATASTREAM = GUICtrlCreateLabel('', 10, 70, 70, 20)
	$GUI_FINISHEDIN = GUICtrlCreateLabel('', 80, 70, 70, 20)
    GUISetState()

    Do
        $msg = GUIGetMsg()
        If $msg = $GUI_BUTTON Then
			$RUN_NFGDUMP = Run("nfgdump.exe " & $DumporRestore & " /v /p /c /g /o=gz /d=\Dev" & $Drive_X & " /f=t:\LinuxImageStore\" & $ImgName & ".img", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
			While 1
				$STD_NFGDUMP = StdoutRead($RUN_NFGDUMP)
					If @error Then ExitLoop
				If StringInStr($STD_NFGDUMP, 'finished in') Then FNC_PROGRESS($STD_NFGDUMP)
			WEnd
        EndIf
    Until $msg = $GUI_EVENT_CLOSE
EndFunc

Func FNC_PROGRESS($PAR_NFGDUMP)
	Local $VAR_NFGDUMP
	$VAR_NFGDUMP = StringSplit($PAR_NFGDUMP, ',')
	If IsArray($VAR_NFGDUMP) And $VAR_NFGDUMP[0] = 3 Then
		GUICtrlSetData($GUI_PROGRESS, Round(Number($VAR_NFGDUMP[1])))
		GUICtrlSetData($GUI_DATASTREAM, $VAR_NFGDUMP[2])
		GUICtrlSetData($GUI_FINISHEDIN, $VAR_NFGDUMP[3])
		Sleep(1000)
	EndIf
EndFunc

Open in new window

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is about my first experience with programming Arduino.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
Progress
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question