Jump to content

Basic behaviour of script in a dos box


Recommended Posts

sorry if my question seems stupid, I am an autoIt beginner.

I would like to make a AutoIt script build as an exe synchronous:

In this script I make a simple winwait("my caption","",100000) in order to wait for a window to appear.

Then I run this exe in a dos box. My problem is that the exe returns immediately while I was expecting a synchronous execution waiting for the window to appear before returning.

The process of the script is still running as seen in Task Manager and the script is "paused" as it is shown

in the system tray.

Thanks in advance

Link to comment
Share on other sites

sorry if my question seems stupid, I am an autoIt beginner.

I would like to make a AutoIt script build as an exe synchronous:

In this script I make a simple winwait("my caption","",100000) in order to wait for a window to appear.

Then I run this exe in a dos box. My problem is that the exe returns immediately while I was expecting a synchronous execution waiting for the window to appear before returning.

The process of the script is still running as seen in Task Manager and the script is "paused" as it is shown

in the system tray.

Thanks in advance

Welcome to AutoIt, this really is a great tool and forum. Its amazing how this stuff becomes easier after reading the millions of code examples there. I'm not complete sure what you're wanting to do, but I'm going to guess reading up on the following commands in the help file. Maybe one of them will give you what you need?

- Run ( "filename" [, "workingdir" [, flag[, standard_i/o_flag]]] )

- RunWait ( "filename" [, "workingdir" [, flag]] )

- ShellExecute ( "filename" [, "parameters" [, "workingdir" [, "verb" [, showflag]]]] )

- ShellExecuteWait ( "filename" [, "parameters" [, "workingdir" [, "verb" [, showflag]]]] )

If you can share what code you have that would also help. Your WinWait command is going to wait for 100,000 seconds? Maybe you were thinking this was like Sleep() that uses milliseconds and not seconds. And if you want to script to wait for the window forever you don't need the timeout. The timeout basically says if the condition isn't true within 100,000 seconds then continue to the next line of code even if condition has not been met.

Also if you share the code with us, can you paste it between the "[ autoit ]" and "[ /autoit ]" (without the quotes and no spaces of course) tags like this:

[ autoit ]

.... paste code here ....

[ /autoit ]

Link to comment
Share on other sites

If you're in a DOS box and run a non-CLI executable, the default behavior is to run the executable in the background and return immediately. If you wish to wait for the command to finish, then you must use the "start" command:

CODE
start /wait /b myscript.exe
Link to comment
Share on other sites

Here is my auto it code ( quite simple ..)

[ autoit ]

;

; AutoIt Version: 3.0

$par1 = ""

$par2 = ""

$par3 = ""

if ( $CmdLine[0] >=1 ) Then

$par1 = $CmdLine[1]

endIf

if ( $CmdLine[0] >=2 ) Then

$par2 = $CmdLine[2]

EndIf

if ( $CmdLine[0] >=3 ) Then

$par3 = $CmdLine[3]

Else

$par3 = 1000

EndIf

winwait($par1,$par2,$par3)

[ /autoit ]

I would like to use the powerness and simpleness of AutoIt from another exe not written in AutoIt. This other main exe

should inherit for example the possibility of waiting for a window to appear which is very conveniently coded in AutoIt.

In my main exe, I call the AutoIt exe with the appropriate parameters.

When I run my main exe with the expected window not present, the AutoIt exe above just pass in state paused and control is returned immediately to my main exe.

Link to comment
Share on other sites

If you're in a DOS box and run a non-CLI executable, the default behavior is to run the executable in the background and return immediately. If you wish to wait for the command to finish, then you must use the "start" command:

CODE
start /wait /b myscript.exe

Thanks for that clue but, after verification, it does not seem to solve the issue.

Link to comment
Share on other sites

  • 2 months later...

Thanks for that clue but, after verification, it does not seem to solve the issue.

Yeah... I have the same kind of problem:

Let's resume for the ones (like me) that looks for running au3 scripts synchronously: By that I mean, I want my script to execute until the need THEN returns to the original caller process (for example, I want that the script returns only when EVERYTHING has finished.

Here is my current understanding after trying different things:

1) you want to interpret a script synchronously: not possible !

2) you want to run a compiled version of a script synchronously:

CODE
"Start /Wait /script.exe"

Solution 2 generally works fine ! BUT... unfortunately it sounds to not work when you're using Vista and if you have

CODE
#requireAdmin
in your original script !!!!!!!

This is breaking all my integration of autoit tests in my test management system <_<

Any ideas guys ?

Eg\\*

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...