| View previous topic :: View next topic |
| Author |
Message |
majkinetor
Joined: 24 May 2006 Posts: 3589 Location: Belgrade
|
Posted: Mon Aug 13, 2007 9:12 am Post subject: [module] Plugin framework 1.0 |
|
|
Plugin framework for non compiled scripts
Documentation in the code (to create HTML docs see this)
The plugin framework works as in any other program - you copy the plugin to "plugins" folder and restart application. New plugin will be loaded and what happens next depends on your plugin API. To desable plugin, change its extension or remove it from "plugins" folder.
AutoHotkey is very friendly for making pluginable applications as you have entire AHK language avaialable to be used by plugin developers. End user can learn the language very fast and he doesn't need to have any development tools (Notepad is enough).
Download
Example (trivial plugin API, it requires plugin to implement subroutine with the same name as its own)
| Code: | Plugins_Init() ;check for new plugins on startup
Plugins_Get("plug") ;get loaded plugins in plug1...plugN array
loop, %plug0%
GoSub plug%A_Index% ;execute plugin routine - better : Call( plugX "_function")
return
#include inc\plugin.ahk |
Note: To create better plugin API you should use Call, instead GoSub _________________
 |
|
| Back to top |
|
 |
ahklerner
Joined: 26 Jun 2006 Posts: 1090 Location: USA
|
|
| Back to top |
|
 |
automaticman
Joined: 27 Oct 2006 Posts: 300
|
Posted: Thu Oct 11, 2007 6:12 pm Post subject: Re: [module] Plugin framework 1.0 |
|
|
| majkinetor wrote: | Plugin framework for non compiled scripts
The plugin framework works as in any other program - you copy the plugin to "plugins" folder and restart application. New plugin will be loaded and what happens next depends on your plugin API. To desable plugin, change its extension or remove it from "plugins" folder.
|
Thanks, but this seems to accept only plugin names in the format of
plug1.ahk
plug2.ahk
...
plugN.ahk
and not also free plugin names like e.g.
Joe.ahk
Peter.ahk
Samson.ahk
... |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3589 Location: Belgrade
|
Posted: Thu Oct 11, 2007 7:35 pm Post subject: |
|
|
It accepts arbitrary names, only extension is important. _________________
 |
|
| Back to top |
|
 |
automaticman
Joined: 27 Oct 2006 Posts: 300
|
Posted: Thu Oct 11, 2007 7:46 pm Post subject: Re: [module] Plugin framework 1.0 |
|
|
| majkinetor wrote: |
| Code: | Plugins_Init() ;check for new plugins on startup
Plugins_Get("plug") ;get loaded plugins in plug1...plugN array
loop, %plug0%
GoSub plug%A_Index% ;execute plugin routine - better : Call( plugX "_function")
return
#include inc\plugin.ahk |
|
But not with this?! I tried with this and it didn't work here. |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3589 Location: Belgrade
|
Posted: Thu Oct 11, 2007 9:05 pm Post subject: |
|
|
You made a mistake then.
For this to work you must change the subroutine names inside plugins. But that is specific to plugin API it has nothing to do with plugin framewors itself. _________________
 |
|
| Back to top |
|
 |
automaticman
Joined: 27 Oct 2006 Posts: 300
|
Posted: Thu Oct 11, 2007 9:29 pm Post subject: |
|
|
| majkinetor wrote: | You made a mistake then.
For this to work you must change the subroutine names inside plugins. But that is specific to plugin API it has nothing to do with plugin framewors itself. | Yes, maybe, although changing the subroutine name inside the plugins didn't work here. Maybe we need to be ahk-experts to use your plugin solution.
It would be nice to have a minimal help which describes which parameters to set to get this framework work with any plugin names. |
|
| Back to top |
|
 |
freakkk
Joined: 29 Jul 2005 Posts: 122
|
Posted: Thu Oct 11, 2007 10:38 pm Post subject: |
|
|
| automaticman wrote: | | It would be nice to have a minimal help which describes which parameters to set to get this framework work with any plugin names. | I don't believe this could be any more straight forward..
Try this example; this will actually tell you the label names that are missing if they don't exist and will work w/ Joe.ahk, Peter.ahk, Samson.ahk.......... | Code: | Plugins_Init() , MyPlugins := Plugins_Get()
Loop, Parse, MyPlugins, `n
If IsLabel( A_LoopField . "_Init" )
GoSub, % A_LoopField . "_Init"
Else
MsgBox, You need to create a "%A_LoopField%_Init:" label within your plugin!
return
#include inc\plugins.ahk |
_________________ .o0[ corey ]0o. |
|
| Back to top |
|
 |
automaticman
Joined: 27 Oct 2006 Posts: 300
|
Posted: Fri Oct 12, 2007 6:28 am Post subject: |
|
|
| Is not working, too. |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3589 Location: Belgrade
|
Posted: Fri Oct 12, 2007 9:38 am Post subject: |
|
|
What is the point of this? What are you trying to achieve?
The code works. I have already 3 projects with it. The code by freakkk works too.
I see that you are not ahk-expert, but we are not even remotely close to that domain. _________________
 |
|
| Back to top |
|
 |
automaticman
Joined: 27 Oct 2006 Posts: 300
|
Posted: Fri Oct 12, 2007 9:54 am Post subject: |
|
|
| majkinetor wrote: | What is the point of this? What are you trying to achieve?
| I'll give an example. In your download above:
rename plug2.ahk to joe.ahk
edit joe.ahk: change "plug2:" to "joe:"
run PluginHost.ahk
Does this work? If not, how can I make joe.ahk work? |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3589 Location: Belgrade
|
Posted: Fri Oct 12, 2007 12:21 pm Post subject: |
|
|
| I wrote: | | For this to work you must change the subroutine names inside plugins. |
| I wrote: | | Example (trivial plugin API, it requires plugin to implement subroutine with the same name as its own) |
_________________
 |
|
| Back to top |
|
 |
automaticman
Joined: 27 Oct 2006 Posts: 300
|
Posted: Fri Oct 12, 2007 1:11 pm Post subject: |
|
|
| majkinetor wrote: | | I wrote: | | For this to work you must change the subroutine names inside plugins. |
| I wrote: | | Example (trivial plugin API, it requires plugin to implement subroutine with the same name as its own) |
| I can't connect your tips from above with my described problem. Can't you decode the solution a little more by directly getting joe.ahk to work? |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3589 Location: Belgrade
|
Posted: Fri Oct 12, 2007 2:26 pm Post subject: |
|
|
just use freakkks version of sample and RTFM. _________________
 |
|
| Back to top |
|
 |
automaticman
Joined: 27 Oct 2006 Posts: 300
|
Posted: Fri Oct 12, 2007 3:01 pm Post subject: |
|
|
| majkinetor wrote: | | just use freakkks version of sample and RTFM. | Maybe others can help here in future. Thanks anyway for your comments. |
|
| Back to top |
|
 |
|