Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[module] Plugin framework 1.0


  • Please log in to reply
18 replies to this topic
majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
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)

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
Posted Image

ahklerner
  • Members
  • 1386 posts
  • Last active: Oct 08 2014 10:29 AM
  • Joined: 26 Jun 2006
Cross Posting.
<!-- m -->http://www.autohotke...ic.php?p=148368<!-- m -->

automaticman
  • Members
  • 658 posts
  • Last active: Nov 20 2012 06:10 PM
  • Joined: 27 Oct 2006

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

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
It accepts arbitrary names, only extension is important.
Posted Image

automaticman
  • Members
  • 658 posts
  • Last active: Nov 20 2012 06:10 PM
  • Joined: 27 Oct 2006

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.

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
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.
Posted Image

automaticman
  • Members
  • 658 posts
  • Last active: Nov 20 2012 06:10 PM
  • Joined: 27 Oct 2006

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.

freakkk
  • Members
  • 182 posts
  • Last active: Dec 16 2014 06:23 PM
  • Joined: 29 Jul 2005

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

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


automaticman
  • Members
  • 658 posts
  • Last active: Nov 20 2012 06:10 PM
  • Joined: 27 Oct 2006
Is not working, too.

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
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.
Posted Image

automaticman
  • Members
  • 658 posts
  • Last active: Nov 20 2012 06:10 PM
  • Joined: 27 Oct 2006

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?

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006

For this to work you must change the subroutine names inside plugins.


Example (trivial plugin API, it requires plugin to implement subroutine with the same name as its own)


Posted Image

automaticman
  • Members
  • 658 posts
  • Last active: Nov 20 2012 06:10 PM
  • Joined: 27 Oct 2006

For this to work you must change the subroutine names inside plugins.


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?

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
just use freakkks version of sample and RTFM.
Posted Image

automaticman
  • Members
  • 658 posts
  • Last active: Nov 20 2012 06:10 PM
  • Joined: 27 Oct 2006

just use freakkks version of sample and RTFM.

Maybe others can help here in future. Thanks anyway for your comments.