Sign in to follow this  
Followers 0
dancer58

Just starting with GUI

9 posts in this topic

I am trying to move (imagex.exe /info e:\backups\test2.wim) to a GUI window but have not got it to do it. So much of the instruction is over my head (small brain) .

This is what I have so far, I would appreceate any help

The SplashTextOn is only for me to see if I am getting to the end

#include <GUIConstants.au3>

#include <Constants.au3>

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Wim File Info", 666, 444, 300, 222)

$Edit1 = GUICtrlCreateEdit("", 40, 56, 600, 300)

$exitbtn = GUICtrlCreateButton("exit", 250, 410, 81, 25, 0)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

$nMsg = GUIGetMsg()

Switch $nMsg

Case $exitbtn

Exit

EndSwitch

$i_Pid = Run('e:\backups\imagex_gui\imagex.exe /info e:\backups\test2.wim ', @WorkingDir, @SW_SHOW)

$data = ''

While 1

$data = StdoutRead($i_Pid)

If @error = -1 Then ExitLoop

GUICtrlSetData($Edit1, $data, 1)

ExitLoop

WEnd

SplashTextOn("test3", "Imagex3 = " & $i_Pid, 400, 100, -2, -2, 32, "Tahoma", 16, 500)

Sleep(3000)

SplashOff()

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I am trying to move (imagex.exe /info e:\backups\test2.wim) to a GUI window but have not got it to do it. So much of the instruction is over my head (small brain) .

What is a win File and what does imagex.exe do with it. And finally: what exactly do you want to "move" in the GUI Window?

Ok, got what u want, so are you sure imagex.exe does output command line Text? have you tested it with

$i_Pid = Run(@ComSpec & " /c dir foo.bar", @SystemDir, @SW_SHOW, $STDERR_CHILD + $STDOUT_CHILD)

i get an output to the edit box.

As written in the help file: process_id: The process ID of a child process, as returned by a previous call to Run.

So maybe add "$STDERR_CHILD + $STDOUT_CHILD" as Run Variable and StdoutRead can read it

Edited by qsek

Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite

Share this post


Link to post
Share on other sites

What is a win File and what does imagex.exe do with it. And finally: what exactly do you want to "move" in the GUI Window?

Ok, got what u want, so are you sure imagex.exe does output command line Text? have you tested it with

$i_Pid = Run(@ComSpec & " /c dir foo.bar", @SystemDir, @SW_SHOW, $STDERR_CHILD + $STDOUT_CHILD)

i get an output to the edit box.

As written in the help file: process_id: The process ID of a child process, as returned by a previous call to Run.

So maybe add "$STDERR_CHILD + $STDOUT_CHILD" as Run Variable and StdoutRead can read it

Thanks

One more question How do I get the window to stay open untill I close it.

The only thing keeping it open now is SplashTextOn command. I would like to be able to close the window with the exit button

Thanks again

Share this post


Link to post
Share on other sites

Thanks

One more question How do I get the window to stay open untill I close it.

The only thing keeping it open now is SplashTextOn command. I would like to be able to close the window with the exit button

Thanks again

You need to keep a loop around the case statement checking for the exit button.

Have the loop exit on your two conditions: One, a user clicks exit. Two, the imagex PID has terminated.

You probably do not need the splashtexton at all and can include that information as part of your GUI

Share this post


Link to post
Share on other sites

Perhaps this updated code may help

#include <GUIConstants.au3>
#include <Constants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Wim File Info", 666, 444, 300, 222)
$Edit1 = GUICtrlCreateEdit("", 40, 56, 600, 300)
$Gobtn = GUICtrlCreateButton("go", 200, 410, 81, 25, 0)
$exitbtn = GUICtrlCreateButton("exit", 300, 410, 81, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $exitbtn, $GUI_EVENT_CLOSE
            Exit
        Case $Gobtn
            _ImageX()
    EndSwitch
WEnd

Exit

Func _ImageX()
    Local $i_Pid, $data
    $i_Pid = Run('e:\backups\imagex_gui\imagex.exe /info e:\backups\test2.wim ', '', @SW_HIDE, 2)
    Do
        $data &= StdoutRead($i_Pid)
    Until @error
    ProcessWaitClose($i_Pid)
    GUICtrlSetData($Edit1, $data, 1)
    ;
    SplashTextOn("test3", "Imagex3 = " & $i_Pid, 400, 100, -2, -2, 32, "Tahoma", 16, 500)
    Sleep(3000)
    SplashOff()
EndFunc

:)

Share this post


Link to post
Share on other sites

How do I get the window to stay open untill I close it.

The only thing keeping it open now is SplashTextOn command. I would like to be able to close the window with the exit button

I think that depend mostly on the executed program itself. If it only reads a file, then output console text and then closes, there's not much autoit can do.

You can Hide or show the execution but not prevent the program from closing. Maybe there's an option in the program itself to not close on finishing.


Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite

Share this post


Link to post
Share on other sites

One more problem

I read somewhere there is a limit to number of lines in a window and there was a solution but I cannot find it now

Thanks for the help

Share this post


Link to post
Share on other sites

Thanks MHz

Appearently there cannot be nested Func's so I modified yours to:

Func DoInfo()

#Region ### START Koda GUI section ### Form=

$InfoGUI = GUICreate("InfoGUI", 666, 444, 300, 222)

$Edit10 = GUICtrlCreateEdit("", 40, 56, 600, 300)

$Gobtn = GUICtrlCreateButton("go", 200, 410, 81, 25, 0)

$exitbtn = GUICtrlCreateButton("exit", 300, 410, 81, 25, 0)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $exitbtn, $GUI_EVENT_CLOSE

GUIDelete ($InfoGUI)

Case $Gobtn

Do

Local $i_Pid, $data

$i_Pid = Run('e:\backups\imagex_gui\imagex.exe /info e:\backups\test2.wim ', '', @SW_HIDE, 2)

Do

$data &= StdoutRead($i_Pid)

Until @error

ProcessWaitClose($i_Pid)

GUICtrlSetData($Edit10, $data, 1)

until $exitbtn

Exitloop

EndSwitch

wend

Endfunc ;===DoInfo

This works except when I try to close $infoGUI. I can get it to close but the buttons on the Imagex main screen don't work or I can get it to close both GUI's. I have not been able to close just $infoGUI and have everything work on the main Imagex GUI.

Any sugestions

Share this post


Link to post
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
Sign in to follow this  
Followers 0