Jump to content

Plugin system for an AutoIt script


er453r
 Share

Recommended Posts

I would like to make a plugin system for one of my scripts. I want it to work something like this -> check a given dir for plugin files (*.plg for example) -> include functions in these files to my script.

And I had a few ideas, but none of them worked.

Idea nr1

Combine all *.plg files into one and include this one in a typical way (#include). But it failes, because (from what I understand) includes are done out-of-script order during compilation.

Idea nr2

Call a function included in a string (plg file contents). But this is (propably) impossible.

Oh yeah, and these functions should be capable of recieving arguments...

So please, help. And big thanks in advance.

ps. You don't have to give me the full code, just the basic idea. I'll work it out :P

Link to comment
Share on other sites

could always make your own plugin format (plugins not written in autoit) and parse them yourself.

but that's a lot of work.

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

Ive thought a lot about this too, although my purposes are slightly different than yours, perhaps my ideas may help you.

i guess ill give some simple background info: im creating a simple (but not to simple) leveling bot for WoW. the problem is I only play warrior, so i can only include the warrior fight code into the script and i have no plans to integrate other jobs because i have no use for adding them- this leaves everyone else who plays other classes out of luck. So: bassically what i want is something where different developers and put in their own additions to my program without actually changing or seeing the source, since open source really isnt a feasible option for my position. ive been rolling this over in my head for probably a month now, and ive had a lot of ideas, and ive tried a lot of things including this http://www.autoitscript.com/forum/index.php?showtopic=23106 and this http://www.autoitscript.com/forum/index.php?showtopic=37187 , however, neither was really what i was looking for. what im trying to do now is encrypt the script, then having a AU3 file where developers can add their own code, and then having a .exe that decrypts my script (to a file as of right now, hopefully ill find someway to decrypt directly into memory and acheive the same desired affect), add the code written by the 3rd party developer to a pre-defined spot in my script and then compiling it all. I have a some of it written (the encrypt and decrypt function) but im still far away from posting my UDFs, or providing a sample of how to make an extremely crude plugin system, however, if youd like some sample code , id be more than happy to post what i have so far.

hope that helps, and gluck with getting your problem worked out.

Link to comment
Share on other sites

If $CmdLineRaw <> "-ALLOK" Then
   FileInstall(*PATH TO THIS SOURCE*, @TEMPDIR&"\temp.au3")
   $filehandle = FileFindFirstFile ( @ScriptDir&"\*.plg" )
   While $filehandle <> -1
      $file = FileFindNextFile($filehandle)
      If @error Then ExitLoop
      FileWrite(@TEMPDIR&"\temp.au3", @CRLF&FileRead($file)&@CRLF)
   Wend
   Run(@AutoItEXE&' /AutoIt3ExecuteScript "'&@TEMPDIR&'\temp.au3" -ALLOK')
   Exit
EndIf

;;;;;Your normal main script code here.

The *plg files must be AutoIt *source* files just with their extentions renamed.

#)

edit: Only requirement: Main script must be compiled.

Edited by nfwu
Link to comment
Share on other sites

If $CmdLineRaw <> "-ALLOK" Then
   FileInstall(*PATH TO THIS SOURCE*, @TEMPDIR&"\temp.au3")
   $filehandle = FileFindFirstFile ( @ScriptDir&"\*.plg" )
   While $filehandle <> -1
      $file = FileFindNextFile($filehandle)
      If @error Then ExitLoop
      FileWrite(@TEMPDIR&"\temp.au3", @CRLF&FileRead($file)&@CRLF)
   Wend
   Run(@AutoItEXE&' /AutoIt3ExecuteScript "'&@TEMPDIR&'\temp.au3" -ALLOK')
   Exit
EndIf

;;;;;Your normal main script code here.

The *plg files must be AutoIt *source* files just with their extentions renamed.

#)

edit: Only requirement: Main script must be compiled.

very nice, but that would prevent compiling. And allow MAJOR yet extremely EASY ways to crash/hack the program.

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

I understand almost everything except the "-ALLOK" part. What option does it trigger in the command line?

pretty sure if -ALLOK is in the command line, no plugins will be loaded. allows a sort oh fail/hack-safe. Edited by theguy0000

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

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...