Sign in to follow this  
Followers 0
vernalex

Pause script processing while GUI autoit is running

7 posts in this topic

Is there a way to make a command-line script wait until an AutoIt executable is done running?

I wrote a program and it's meant to be run in scripts. But, when the application is compiled as a GUI application then when a script runs it the application immediately returns control back to the script so it continues on without waiting for the script to finish.

If I compile it as a command-line application this isn't an issue. But, I need it to be a GUI application because it can be run graphically and I don't want a console window in the background.

I can start the program with "start /wait", but I'd prefer if there were a way for AutoIt to hold control until it is done.

Ideas?

Share this post


Link to post
Share on other sites



RunWait() possibly

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

This doesn't resolve my issue because the Vollatran Project has the same issue as my own program.

To clarify I'm not trying to spawn an external program from within AutoIt. I am already very familiar with RunWait(...).

To give a quick example... write a simple program with a MsgBox. Compile it as a GUI application and as a console application. Then run it from the command-line shell. 

The GUI application will immediately drop back to the shell while the MsgBox appears on the screen, which would allow you to run another program. This is very bad for script processing.

The console application will display the MsgBox and the shell will wait. This is how I'd like it to work. But if you run a console application the GUI will appear as well as a shell, which is definitely not desired in my case.

Share this post


Link to post
Share on other sites

When you run any program from the command line or a batch file, other than a CUI program, control returns immediately to the command console unless you use start /wait in the command line. It's a Windows issue, not an AutoIt one.


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

This doesn't resolve my issue because the Vollatran Project has the same issue as my own program.

To clarify I'm not trying to spawn an external program from within AutoIt. I am already very familiar with RunWait(...).

To give a quick example... write a simple program with a MsgBox. Compile it as a GUI application and as a console application. Then run it from the command-line shell. 

The GUI application will immediately drop back to the shell while the MsgBox appears on the screen, which would allow you to run another program. This is very bad for script processing.

The console application will display the MsgBox and the shell will wait. This is how I'd like it to work. But if you run a console application the GUI will appear as well as a shell, which is definitely not desired in my case.

You are looking for multi-threading. AutoIt does not support this.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Ignore what this guy said, <snip>, this has nothing to do with multithreading.

What you could do is compile as CUI and add first two lines to your script:

DllCall("kernel32", "bool", "FreeConsole")
DllCall("kernel32", "bool", "AttachConsole", "dword", -1)

; ...The rest of your code...
That way you have "waiting" effect if run from cmd, and no console if run by double-click. However, you'll have initial console flash in latter case, so if that doesn't satisfy you seek alternatives. Edited by Melba23
Insult removed
2 people like this

♡♡♡

.

eMyvnE

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