Sign in to follow this  
Followers 0
meows

Trying to run program1 and when it ends run program2

11 posts in this topic

#cs ----------------------------------------------------------------------------

AutoIt Version: v3.3.8.1

Author: me

Script Function:

waits until no instance of progtam.exe exists to start next program.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

;waits until no instance of program1.exe exists

ProcessWaitClose("C:\Program Files (x86)\AutoIt3\Tryit\Hag1\2bottom.exe"[,"CProgram Files (x86)AutoIt3TryitHag1\Files"])

; This will wait until this particular instance of program1 has exited

Local $PID = Run("C:\Program Files (x86)\AutoIt3\Tryit\Hag1\2bottom.exe")

ProcessWaitClose($PID)

ProcessWaitClose("C:\Program Files (x86)\AutoIt3\Tryit\Hag1\2atop\2atop.exe"[,"CProgram Files (x86)AutoIt3TryitHag1\Files"])

; This will wait until this particular instance of program2 has exited

Local $PID = Run("C:\Program Files (x86)\AutoIt3\Tryit\Hag1\2atop\2atop.exe")

ProcessWaitClose($PID)

I keep getting errors no matter what I try.

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /prod /AU3Check /in "C:\Program Files (x86)\AutoIt3\Tryit\Hag1\h3.au3"

+>16:05:16 Starting AutoIt3Wrapper v.2.1.0.8 Environment(Language:0409 Keyboard:00000409 OS:WIN_7/Service Pack 1 CPU:X64 OS:X64)

>Running AU3Check (1.54.22.0) from:C:\Program Files (x86)\AutoIt3

C:\Program Files (x86)\AutoIt3\Tryit\Hag1\h3.au3(15,73) : ERROR: syntax error

ProcessWaitClose("C:\Program Files (x86)\AutoIt3\Tryit\Hag1\2bottom.exe"[

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Program Files (x86)\AutoIt3\Tryit\Hag1\h3.au3(21,77) : ERROR: syntax error

ProcessWaitClose("C:\Program Files (x86)\AutoIt3\Tryit\Hag1\2atop\2atop.exe"[

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Program Files (x86)\AutoIt3\Tryit\Hag1\h3.au3 - 2 error(s), 0 warning(s)

!>16:05:16 AU3Check ended.rc:2

>Exit code: 0 Time: 0.785

I also tried

RunWait ( "program" [, "workingdir" [, show_flag [, opt_flag]]] )

I need to have program one run and when it ends program 2 starts and when program 2 ends we come back to the opening form.

Share this post


Link to post
Share on other sites



Remove the "[ ]" from the last parameter in the ProcessWaitClose command. Those are only there in the help file to indicate that what's inside them is optional, don't include them around those parameters, in any command.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

try?

ProcessWaitClose("2bottom.exe")
RunWait(FileGetShortName("C:Program Files (x86)AutoIt3TryitHag12bottom.exe"))
; This will wait until this particular instance of program2 has exited
RunWait(FileGetShortName("C:Program Files (x86)AutoIt3TryitHag12atop2atop.exe"))

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

;) First THANK YOU BrewManNH and ApudAngelorum It works. However it has issues. First I need to know where the temp dir is located. As the program keeps running the same exe no matter what I put in the ProcessWaitClose("1aedit.exe") RunWait settings. I even built the program and it worked perfectly but ran the wrong program! I shall try moving that directory and see what that does. Now how do I center screen the splash screen? I can't find anything in help or forums to center a image with a splash screen, Or use a image GUISetBkColor(0xFF9900) instead of a color for a background. MANY MANY Thanks again BrewManNH and ApudAngelorum

#cs ----------------------------------------------------------------------------

AutoIt Version: v3.3.8.1 Author: me

Script Function: waits until no instance of progtam.exe exists to start next program.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here #include <GUICONSTANTSEX.AU3>#include <WINDOWSCONSTANTS.AU3>Opt("GUIOnEventMode", 1)

;Splash Screen $tamanhox=@DesktopWidth*0.75 ;amanhox=@DesktopWidth*0.46875 $tamanhoy=$tamanhox/2 $posicaox=(@DesktopWidth/2)-($tamanhox/2) $posicaoy=(@DesktopHeight/2)-($tamanhoy) splashImageOn("","terrorinsoul2.gif",$tamanhox,$tamanhoy,$posicaox,$posicaoy,1) $GUI = GUICreate ("Teste", $tamanhox, $tamanhoy, $posicaox, $posicaoy,$WS_POPUP, BitOR ($WS_EX_TRANSPARENT, $WS_EX_LAYERED, $WS_EX_TOPMOST)) $label = GUICtrlCreateLabel("© Tester 3", $posicaox+($tamanhox/6), $posicaoy/($tamanhoy), $tamanhox/4, $tamanhoy/4) GUICtrlSetFont(-1,15,$tamanhox/30) WinSetTrans ($GUI, "", 50) GUISetBkColor(0xffffff, $GUI) GUISetState(@SW_SHOW,$GUI) sleep(2000) Splashoff()

;; ---------------------------------- ProcessWaitClose("1aedit.exe") RunWait(FileGetShortName("C:Program Files (x86)AutoIt3TryitHag11aedit1aedit.exe")) ; This will wait until this particular instance of program2 has exited ProcessWaitClose("2atop.exe") RunWait(FileGetShortName("C:Program Files (x86)AutoIt3TryitHag12atop2atop.exe")) Exit

Edited by meows

Share this post


Link to post
Share on other sites

ProcessWaitClose("1aedit.exe")
RunWait(FileGetShortName("C:Program Files (x86)AutoIt3TryitHag11aedit1aedit.exe"))
FileChangeDir ( "C:Program Files (x86)AutoIt3TryitHag12atop" )
ProcessWaitClose("C:Program Files (x86)AutoIt3TryitHag12atop2atop.exe")
RunWait(FileGetShortName("C:Program Files (x86)AutoIt3TryitHag12atop2atop.exe"))
Exit

Thank you

BrewManNH and ApudAngelorum

If any other need to run one program after another you can use this, It actually works! Well at least for me.

I do need to know how to center a splash page dead center in the monitor,

Share this post


Link to post
Share on other sites

Hi, meows. Look into @DesktopHeight and @DesktopWidth in the helpfile. If you're using SplashImageOn, you can use these to set the X and Y coordinates for the image.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Your process parameter for the ProcessWaitClose isn't correct. From the help file for ProcessWaitClose:

Process names are executables without the full path, e.g., "notepad.exe" or "winword.exe"

Also, RunWait won't let the script continue until that program has closed, your ProcessWaitClose probably isn't even seeing the first program run because of this. Although, if it's not running any longer, it will just go right past that line anyways. As to your FileChangeDir command, you can include the working directory in the Run command so that shouldn't be needed.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Hi, meows. Look into @DesktopHeight and @DesktopWidth in the helpfile. If you're using SplashImageOn, you can use these to set the X and Y coordinates for the image.

Thank you sir,

I found them in the Micro section but not how to use them.

@DesktopWidth=640, @DesktopHeight=480 gives a error

@DesktopWidth=640, @DesktopHeight=480 gives a error

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:Program Files (x86)AutoIt3lessonslesson1.au3" /UserParams

+>14:07:54 Starting AutoIt3Wrapper v.2.1.0.8 Environment(Language:0409 Keyboard:00000409 OS:WIN_7/Service Pack 1 CPU:X64 OS:X64)

>Running AU3Check (1.54.22.0) from:C:Program Files (x86)AutoIt3

C:Program Files (x86)AutoIt3lessonslesson1.au3(1,14) : ERROR: syntax error

@DesktopWidth=

~~~~~~~~~~~~~^

C:Program Files (x86)AutoIt3lessonslesson1.au3 - 1 error(s), 0 warning(s)

!>14:07:54 AU3Check ended.rc:2

>Exit code: 0 Time: 7.829

Share this post


Link to post
Share on other sites

<PRE>ProcessWaitClose("1aedit.exe")
RunWait(FileGetShortName("C:Program Files (x86)AutoIt3TryitHag11aedit1aedit.exe"))
FileChangeDir ( "C:Program Files (x86)AutoIt3TryitHag12atop" )
ProcessWaitClose("C:Program Files (x86)AutoIt3TryitHag12atop2atop.exe")
RunWait(FileGetShortName("C:Program Files (x86)AutoIt3TryitHag12atop2atop.exe"))
Exit</PRE>

Your process parameter for the ProcessWaitClose isn't correct. From the help file for ProcessWaitClose:

Also, RunWait won't let the script continue until that program has closed, your ProcessWaitClose probably isn't even seeing the first program run because of this. Although, if it's not running any longer, it will just go right past that line anyways. As to your FileChangeDir command, you can include the working directory in the Run command so that shouldn't be needed.

I am so sorry. My third day at this. And Just doing what I find in the forums and help files.

This actually does work at least on my computer.

I have to have the working dir for these programs to run and how

can they find themselves if I do not put in the location?

I looked all over the help files for how to set relative

directories so when you build the program can find it's

self and files it needs to interact with.

Share this post


Link to post
Share on other sites

@ScriptDir will tell the script the directory the script is being run from.

From the help file for the Run command:

Run ( "program" , "workingdir" , show_flag , opt_flag )

That's where you can set the working directory for the Run command. FileSetDir does the same thing, but you don't need to do that if you set it in the Run command. Also, because you used RunWait instead of Run, the working directory isn't getting set until AFTER the program has finished running, and not during its run.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

@DesktopHeight and @DesktopWidth are macros that automatically input those values. Try @DesktopHeight - 50 or @DesktopHeight / 2 to see the effect. You can then play around with this until you get your desired effect.


√-1 2^3 ∑ π, and it was delicious!

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