Sign in to follow this  
Followers 0
knight666

Making add-ons for an AutoIt program

18 posts in this topic

#1 ·  Posted (edited)

Hi there.

I'm making an IRC chatbot that uses mIRC, and I've come across a problem.

What I figured was: I need to make addons for my bot, so I can easily add functionality.

But #include only takes STRINGS and can't take variables.

Aha, but what if I #include "addons.au3", which has a list of addons?

Well, apparantly, AutoIt needs to compile ALL the scripts, including the addons.

And that isn't really an option.

So, my question is: how could I load in an external function written in AutoIt?

For instance, the function NowPlaying(), ripped from a mIRC library

Func NowPlaying()
 $dll = DllOpen("2latemirc.dll")
 $song = DllCall($dll,"none","MP3Song",   "hwnd",-1,"hwnd",-1,"str","","str","3","int","1","int","1")
 $position = DllCall($dll,"none","MP3Position",   "hwnd",-1,"hwnd",-1,"str","","str","3","int","1","int","1")
 $length = DllCall($dll,"none","MP3Lenght",   "hwnd",-1,"hwnd",-1,"str","","str","3","int","1","int","1")
 ControlSend("mIRC -","",  "Edit1", "Now playing: " & $song[3] & " (" & $position[3] & " / " & $length[3] & ") {ENTER}")
 DllClose($dll)
EndFunc

Please help me and don't yell at me, it's 1:36 am and I'm too tired to use the search button beyond the first page. :)

Edited by knight666

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Form1: AutoIt3.exe [/ErrorStdOut] [/AutoIt3ExecuteScript] file [params ...]
                Execute an AutoIt3 Script File
it's from the help file...

To execute a standard AutoIt Script File 'myscript.au3', use the command:
'AutoIt3.exe myscript.au3'
Edited by alexmadman

Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Share this post


Link to post
Share on other sites

In my defense, it was quite hidden. :)

Share this post


Link to post
Share on other sites

Wait, this isn't quite solved just yet.

When I put the AutoIt3.exe in my folder and have my script Run() my addon like this:

Run (@ScriptDir & '\AutoIt3.exe ' & @ScriptDir & '\Addons\addonNowPlaying.au3')

It doesn't actually add the function NowPlaying to the script!

Why doesn't it do that? :S

Share this post


Link to post
Share on other sites

It appears to run a simple MsgBox just fine, but it doesn't include the function. :\

Is there any way around this?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

if i understand you right you want to do something like this:

(this code does NOT work)

CODE

$file = FileFindFirstFile(@ScriptDir & "\Addons\*.au3")

$foundfile = FileFindNextFile($file)

#include "Addons\" & $foundfile

Am i right?

If yes i would go around this by creating a "temporary script".

Create your real script. By running it it checks if thereis a addon folder and if there are files in "/Addons".

If yes. It copys the whole script into /temp/ including the *.au3s from /addons and writes at start of the script "#include youraddonfileau3"

this is ugly but would work for you.

Edited by Kademlia

Share this post


Link to post
Share on other sites

How would I write a new line to my already compiled script?

And the problem is: it works when you simply include the scripts, but what if you have an updated version of a function?

You'd have to recompile the script, negating the whole external function thing.

Share this post


Link to post
Share on other sites

okay your talking about a compiled one...

i think that would result in writing autoit yourself or including AU3 in your script :)

Share this post


Link to post
Share on other sites

okay your talking about a compiled one...

i think that would result in writing autoit yourself or including AU3 in your script :)

Aha, but what if I #include "addons.au3", which has a list of addons?

Well, apparantly, AutoIt needs to compile ALL the scripts, including the addons.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I ment including "Autoit" itself.

to be able to insert scripts.

Edit:

Okay if you realy want to do this i would do it this way:

Make a AU3 script with Fileinstall(Autoit.exe).

Compile to an .exe

By running the *.exe you extract te autoit.exe and your script. then go on with creating the temp...

but this definitely sucks

Edited by Kademlia

Share this post


Link to post
Share on other sites

The problem is not keeping track of the currently installed addons.

The problem is importing functions from addon .au3 files.

Recompiling the script every time there's an update for a function is not an option.

Share this post


Link to post
Share on other sites

;Here's a sample script to get the idea

#include addonNowPlaying.au3 ;works perfectly, except when you update the .au3, in which case you will have to recompile the program
Run ("AutoIt3.exe addonNowPlaying.au3") ;will run scripts, but won't install user defined functions
Execute('Func Test()' & @CRLF & 'MsgBox(64,"Test.","This is a test.")' & @CRLF & 'EndFunc') ;will not install the function
FileInstall("addonNowPlaying.au3","\Temp\addonNowPlaying.au3") ;from what i can tell this will install the script in some other folder? i don't know how this will help meoÝ÷ Ù«­¢+ÙÕ¹9½ÝA±å¥¹ ¤(ÀÌØí±°ô±±=Á¸ ÅÕ½Ðìɱѵ¥É¹±°ÅÕ½Ðì¤(ÀÌØíͽ¹ô±±
±° ÀÌØí±°°ÅÕ½Ðí¹½¹ÅÕ½Ðì°ÅÕ½Ðí5@ÍM½¹ÅÕ½Ðì°ÅÕ½Ðí¡Ý¹ÅÕ½Ðì°´Ä°ÅÕ½Ðí¡Ý¹ÅÕ½Ðì°´Ä°ÅÕ½ÐíÍÑÈÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐíÍÑÈÅÕ½Ðì°ÅÕ½ÐìÌÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½ÐìÄÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½ÐìÄÅÕ½Ðì¤(ÀÌØíÁ½Í¥Ñ¥½¸ô±±
±° ÀÌØí±°°ÅÕ½Ðí¹½¹ÅÕ½Ðì°ÅÕ½Ðí5@ÍA½Í¥Ñ¥½¸ÅÕ½Ðì°ÅÕ½Ðí¡Ý¹ÅÕ½Ðì°´Ä°ÅÕ½Ðí¡Ý¹ÅÕ½Ðì°´Ä°ÅÕ½ÐíÍÑÈÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐíÍÑÈÅÕ½Ðì°ÅÕ½ÐìÌÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½ÐìÄÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½ÐìÄÅÕ½Ðì¤(ÀÌØí±¹Ñ ô±±
±° ÀÌØí±°°ÅÕ½Ðí¹½¹ÅÕ½Ðì°ÅÕ½Ðí51¹¡ÐÅÕ½Ðì°ÅÕ½Ðí¡Ý¹ÅÕ½Ðì°´Ä°ÅÕ½Ðí¡Ý¹ÅÕ½Ðì°´Ä°ÅÕ½ÐíÍÑÈÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐíÍÑÈÅÕ½Ðì°ÅÕ½ÐìÌÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½ÐìÄÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½ÐìÄÅÕ½Ðì¤(
½¹Ñɽ±M¹ ÅÕ½Ðíµ%I´ÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðí¥ÐÄÅÕ½Ðì°ÅÕ½Ðí9½ÜÁ±å¥¹èÅÕ½ÐìµÀìÀÌØíͽ¹lÍtµÀìÅÕ½Ðì ÅÕ½ÐìµÀìÀÌØíÁ½Í¥Ñ¥½¹lÍtµÀìÅÕ½Ðì¼ÅÕ½ÐìµÀìÀÌØí±¹Ñ¡lÍtµÀìÅÕ½Ðì¤í9QIôÅÕ½Ðì¤(±±
±½Í ÀÌØí±°¤)¹Õ¹

Nothing works. :)

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

if i get your right:

You want a *.exe file that uses *.au3 addons right?

Afaik this is not possible. EXCEPT you do like this:

[pseudocode]

Fileinstall(Autoit.exe)

Fileinstall(yourscript as a *.au3)

SearchforAddons("/addons/") ;(Filefindfirst / filefindnext)

fileopen(yourscript as a *.au3)

fileopen (youtscript_TEMP.tmp)

filewrite (youtscript_TEMP.tmp, "#include " & $foundaddon)

filewrite (yourscript_TEMP.tmp, $code_from_yourscript) ; all the code thats in youscript.au3

fileclose(yourscript_temp.tmp)

rename(yourscript_temp.tmp,yourscript_temp.au3)

run(yourscript_temp.au3); run the *.au3 with the extracted autoit.exe

[/pesudocode]

____

what does it do?:

basically install Autoit and then run *.au3s....

as i said...this sucks big time. but would work

Edited by Kademlia

Share this post


Link to post
Share on other sites

@knight666

Did you ever figure something out?

Look at RazerM script editor. It has the abillity to add "plugins"..

I downloaded the editor, but did not see anything about the plugins. Can you point me a little closer please?

Share this post


Link to post
Share on other sites

I shall talk to him on MSN tonight (if he is on) and asked what happened or if he has an example. Sadly he hasn't been with us recently (very busy!)

Cool thanks...

@knight

BTW, you should look at this thread Post#9

It will probably work for you, since your func is all expressions:

http://www.autoitscript.com/forum/index.ph...=63654&st=8

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