Sign in to follow this  
Followers 0
ficofico

need help with while

9 posts in this topic

I guys I've a problem that i'm not able to solve.

I've written a gui program that have about 2000 lines in an only 1 while .

I have a gui and when I click over button instruction start, and this cause to start x264, mencoder, mp4box etc etc, i've used runwait to exute this command.

the problem is that I want to make a button in the same gui that stop all instruction and exit the gui, but until the loop it's not finished , button in the gui don't work.

since today all works well, because there's a exe file with all the instruction, and button only have to start this exe........ obviously stop button work's well, but now I've moved the instruction in the while loop of the gui, becuase I want to write in the gui, some text like................

now mencoder is running

now x264 is running

and the only way I've find, is to have all the instryuction in the same gui..

there's another way to to that?

How can I modify my loop while to have access at stop button every time?

thanks

Share this post


Link to post
Share on other sites



I guys I've a problem that i'm not able to solve.

I've written a gui program that have about 2000 lines in an only 1 while .

I have a gui and when I click over button instruction start, and this cause to start x264, mencoder, mp4box etc etc, i've used runwait to exute this command.

the problem is that I want to make a button in the same gui that stop all instruction and exit the gui, but until the loop it's not finished , button in the gui don't work.

since today all works well, because there's a exe file with all the instruction, and button only have to start this exe........ obviously stop button work's well, but now I've moved the instruction in the while loop of the gui, becuase I want to write in the gui, some text like................

now mencoder is running

now x264 is running

and the only way I've find, is to have all the instryuction in the same gui..

there's another way to to that?

How can I modify my loop while to have access at stop button every time?

thanks

Instead of runwait you could use $pidA = Run(...

then you can check if the program is still running with if ProcessExists($pidA) and you will have control returned to your script rather than having to wait for the program to finish. You can also stop the program with ProcessClose($pidA)


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

yes but I need to stop all event and exit the gui.......... normally when start, script may take 1 hours, and do a lot of work, not only x264 or mencoder........... All it's right, but the stop button that not work.

I've think another way to do what I want. I can make exe file with all the instruction like before. In this instruction with _writefiletoline I can write in a text file " mencoder it's running or x264 it's running" . Now i've to , after pressing the button that start di exe file, make the gui refresh every second, reading info from text file.... it's possible. In this way stop button can work well without problem

Share this post


Link to post
Share on other sites

yes but I need to stop all event and exit the gui.......... normally when start, script may take 1 hours, and do a lot of work, not only x264 or mencoder........... All it's right, but the stop button that not work.

I've think another way to do what I want. I can make exe file with all the instruction like before. In this instruction with _writefiletoline I can write in a text file " mencoder it's running or x264 it's running" . Now i've to , after pressing the button that start di exe file, make the gui refresh every second, reading info from text file.... it's possible. In this way stop button can work well without problem

I don't understand what you're saying. I thought you wanted to start a program by pressing a button, then be able to exit the script and maybe stop the program, or programs, using another button. I can't see what the problem is at the moment, so can you post some sample script?

This is what I thought you meant

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $btn[2], $lbl[2]
$Form2 = GUICreate("Form2", 633, 447, 193, 125)
$btn[0] = GUICtrlCreateButton("notepad", 104, 40, 75, 25, 0)
$btn[1] = GUICtrlCreateButton("regedit", 104, 88, 75, 25, 0)
$Button3 = GUICtrlCreateButton("quit", 104, 144, 75, 25, 0)
$lbl[0] = GUICtrlCreateLabel("not running", 200, 45, 57, 17)
$lbl[1] = GUICtrlCreateLabel("not running", 200, 94, 57, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $pidA[2] = [0, 0]
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $Button3
            If $nMsg = $Button3 Then
                For $n = 0 To 1
                    If $pidA[0] <> 0 Then ProcessClose($pidA[$n])
                Next
            EndIf
            Exit
            
        Case $btn[0]
            $pidA[0] = Run("Notepad.exe")
        Case $btn[1]
            $pidA[1] = Run("RegEdit.exe")

    EndSwitch

    For $n = 0 To 1
        If $pidA[$n] <> 0 Then
            If ProcessExists($pidA[$n]) Then
                If GUICtrlRead($lbl[$n]) <> "running" Then GUICtrlSetData($lbl[$n], "running")
            Else
                $pidA[$n] = 0
            EndIf
        ElseIf GUICtrlRead($lbl[$n]) <> "not running" Then
            GUICtrlSetData($lbl[$n], "not running")
        EndIf
    Next
    
    
WEnd

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Use GUICtrlSetOnEvent() for the Stop button and then in the function write Exit

Regards

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

this is some of the code, it's written all like this.

forum.txt

Edited by ficofico

Share this post


Link to post
Share on other sites

this is some of the code, it's written all like this.

Maybe you could have an AdlibEnable to check if you want to exit every so often.

$chkExit = GUICtrlCreateCheckbox("Finished",80,200,100,22)
.
..
AdlibEnable("wantexit",1000);at start of script


.
.
.
Func wantexit()
    if GUICtrlRead($chkExit) = $GUI_CHECKED Then Exit
EndFunc

This way you can get what I think you want with very little change to your script which must have taken a long time to write.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

very long time.... but it's only a part of whole..., thanks martin

Share this post


Link to post
Share on other sites

When I came back at home I'll try your suggestion.... now i've a second question..... more complicated!!!

the lastest build of x264 give the % of work and other statistic ( fps etc) directly on the title of the dos shell windows.

There's a way to capture this info, like put into variable the title of a windows and put variable into a text file every time on line 1, but every second?

the process name it's always x264.exe, also I think that it's possible, after this, read from the text file every second and refresh the gui.

suggestion? muttley

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