Jump to content
Sign in to follow this  
ionut

ShellExecute not run unless #include<custom.au3> is moved below it

Recommended Posts

ionut

Hello,

I have written several scripts which are all using the same functions so I have decided to created a custom.au3 script with all the common functions and to include it in the scripts. In order for the functions to create a results I need to open the GUI of my application. The scripts now look like this:

#include <custom.au3>

ShellExecute("PathtoFiletoBeOpened")

If I am starting the script like this nothing happens. If I invert the lines:

ShellExecute("PathtoFiletoBeOpened")

#include <custom.au3>

the GUI opens up and the script starts to run as expected. It seems that the functions from the custom.au3 script are somehow called by the #include command and cannot execute because the GUI is not opened.

Am I correct making this assumption? Any help in explaining this behavior is greatly appreciated.

Thank you,

Ionut

Share this post


Link to post
Share on other sites
KaFu

Yep, sounds good. Seems like you've got a loop somewhere in your custom include. Check that out and ensure that the custom.au3 by itself runs through smoothly (exit without hanging).

Share this post


Link to post
Share on other sites
ionut

Yep, sounds good. Seems like you've got a loop somewhere in your custom include. Check that out and ensure that the custom.au3 by itself runs through smoothly (exit without hanging).

Kafu,

I don't think I have a loop in the custom script but I do have a bunch of WinWaitActive conditions which are not met unless my application's GUI is opened. If I keep the window opened the custom script will execute fine. If I close it the custom script will hang.

My expectations were slightly different: I thought the functions from the custom script will be called and run only after the main script requires them, not when the #include <custom.au3> line is parsed and executed.

Thanks,

Ionut

Share this post


Link to post
Share on other sites
KaFu

My expectations were slightly different: I thought the functions from the custom script will be called and run only after the main script requires them, not when

Includes are just placeholders. The code inside the include is parsed to exactly that line in the script where the include is called. If you just have func / endfunc enclosed functions in your include you're fine. If you have code which is run on calling the include (not enclosed by func/endfunc), it will do exactly that.

Share this post


Link to post
Share on other sites
ionut

OK, now I understand this behavior is as designed. Thanks a lot for your explanations, Kafu!!!

Regards,

Ionut

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  

×