AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[module] Plugin framework 1.0
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
majkinetor



Joined: 24 May 2006
Posts: 3589
Location: Belgrade

PostPosted: Mon Aug 13, 2007 9:12 am    Post subject: [module] Plugin framework 1.0 Reply with quote

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
View user's profile Send private message MSN Messenger
ahklerner



Joined: 26 Jun 2006
Posts: 1090
Location: USA

PostPosted: Sun Sep 16, 2007 6:51 pm    Post subject: Reply with quote

Cross Posting.
http://www.autohotkey.com/forum/viewtopic.php?p=148368
Back to top
View user's profile Send private message
automaticman



Joined: 27 Oct 2006
Posts: 300

PostPosted: Thu Oct 11, 2007 6:12 pm    Post subject: Re: [module] Plugin framework 1.0 Reply with quote

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
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3589
Location: Belgrade

PostPosted: Thu Oct 11, 2007 7:35 pm    Post subject: Reply with quote

It accepts arbitrary names, only extension is important.
_________________
Back to top
View user's profile Send private message MSN Messenger
automaticman



Joined: 27 Oct 2006
Posts: 300

PostPosted: Thu Oct 11, 2007 7:46 pm    Post subject: Re: [module] Plugin framework 1.0 Reply with quote

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
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3589
Location: Belgrade

PostPosted: Thu Oct 11, 2007 9:05 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
automaticman



Joined: 27 Oct 2006
Posts: 300

PostPosted: Thu Oct 11, 2007 9:29 pm    Post subject: Reply with quote

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
View user's profile Send private message
freakkk



Joined: 29 Jul 2005
Posts: 122

PostPosted: Thu Oct 11, 2007 10:38 pm    Post subject: Reply with quote

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

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
View user's profile Send private message
automaticman



Joined: 27 Oct 2006
Posts: 300

PostPosted: Fri Oct 12, 2007 6:28 am    Post subject: Reply with quote

Is not working, too.
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3589
Location: Belgrade

PostPosted: Fri Oct 12, 2007 9:38 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
automaticman



Joined: 27 Oct 2006
Posts: 300

PostPosted: Fri Oct 12, 2007 9:54 am    Post subject: Reply with quote

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
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3589
Location: Belgrade

PostPosted: Fri Oct 12, 2007 12:21 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
automaticman



Joined: 27 Oct 2006
Posts: 300

PostPosted: Fri Oct 12, 2007 1:11 pm    Post subject: Reply with quote

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
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3589
Location: Belgrade

PostPosted: Fri Oct 12, 2007 2:26 pm    Post subject: Reply with quote

just use freakkks version of sample and RTFM.
_________________
Back to top
View user's profile Send private message MSN Messenger
automaticman



Joined: 27 Oct 2006
Posts: 300

PostPosted: Fri Oct 12, 2007 3:01 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group