Jump to content
Sign in to follow this  
monitorlg

How Can we call a function From other Script.

Recommended Posts

monitorlg

Hi All,

I am trying to call a script from other script but i am not able to do that...

Here is my code:

$abc = ShellExecute("Audio.au3", "", @ScriptDir)

msgbox(0,"",$abc)

The msgbox returns to me 1, that means calling the script is success, But still the script is not called...

Can anybody help me...

Share this post


Link to post
Share on other sites
SmOke_N

Your au3 file is a script, so you can't just expect it to run as an executable without compiling it first using functions like ShellExecute/OpenProcess API/ or Run.

One way to do what you want is something like:

Global $s_file_to_run = @ScriptDir & "\Audio.au3"
Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $s_script_to_run & '"')
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
monitorlg

Hi All,

I have two queries.

a) I have two scripts.

I want to call a Function Of script2 from Script 1.

Does anybody know how can we acheieve it.

b)Does AUTOIT support Object oriented Programming...

Please Reply to me.

Thanks in Advance..

Share this post


Link to post
Share on other sites
SmOke_N

Hi All,

I have two queries.

a) I have two scripts.

I want to call a Function Of script2 from Script 1.

Does anybody know how can we acheieve it.

b)Does AUTOIT support Object oriented Programming...

Please Reply to me.

Thanks in Advance..

Your impatience is on the edge of annoying. Don't double post.

Now, if you are just wanting to call functions from a script that isn't hard coded to run something, then you can use that .au3 (other file) as an #include in "script 1". Otherwise, you can hard code it and do as I suggested in the previous post.

On your 2nd question, There is a manual/help file for you to read that can answer most of your questions if you take the time to do so.

<merged>

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
monitorlg

Your impatience is on the edge of annoying. Don't double post.

Now, if you are just wanting to call functions from a script that isn't hard coded to run something, then you can use that .au3 (other file) as an #include in "script 1". Otherwise, you can hard code it and do as I suggested in the previous post.

On your 2nd question, There is a manual/help file for you to read that can answer most of your questions if you take the time to do so.

<merged>

@SmOke_N,

Thanks... Your code works.

and I was not impatient, if u read my post clearly u can notice that i have posted abt calling a script in post 1 and calling a function in another script in post2...I cannot hardcode the funtion in the script 1. I had no means to annoy anyone and neither i was impatient.

For my second question i read the help file..but i was not able to come to a conclusion so i had posted it thinking any body would have helped me..

I Can understand that u being a moderator is more worried for the duplicate posts and unwanted posts..you want everybody to abide the rules while posting in the Forum..But i would request you to read the the posts and then comment if they are duplicate posts or not....

Thanks for the Help..

Share this post


Link to post
Share on other sites
SmOke_N

@SmOke_N,

Thanks... Your code works.

and I was not impatient, if u read my post clearly u can notice that i have posted abt calling a script in post 1 and calling a function in another script in post2...I cannot hardcode the funtion in the script 1. I had no means to annoy anyone and neither i was impatient.

For my second question i read the help file..but i was not able to come to a conclusion so i had posted it thinking any body would have helped me..

I Can understand that u being a moderator is more worried for the duplicate posts and unwanted posts..you want everybody to abide the rules while posting in the Forum..But i would request you to read the the posts and then comment if they are duplicate posts or not....

Thanks for the Help..

http://www.autoitscript.com/forum/index.ph...highlite=%2BOOP

Third topic down, 2nd post by Valik.

That's 15 seconds I'll never get back :D

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
LoranRendel

May be a function from Script_2 be called from Script_1 without including it? I need to compile Script_1, and this compiled script should call a function from script_2.a3x

Share this post


Link to post
Share on other sites
Diception

May be a function from Script_2 be called from Script_1 without including it? I need to compile Script_1, and this compiled script should call a function from script_2.a3x

yes you can call a funtion from a second or even tenth script by using includes and when you compile a script that uses includes it .... wait for it .... it includes that other script into the compiled exe :):party::idea:

Your welcome

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  

×