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 

Script Merging - additional idea...

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Tester



Joined: 06 Jul 2006
Posts: 48
Location: Poland

PostPosted: Sun Jul 30, 2006 8:59 pm    Post subject: Script Merging - additional idea... Reply with quote

For some time I've been trying to make AHK scripts work as modules managed by simple parent script/manager.

In the meantime majkinetor laid the foundation for script merging (in fact this is more of a workaround to avoid the limitations of the current version of Autohotkey, than a final merging solution) which is discussed in Constructive Language Criticism & Script Merging

I try to expand this one step further... to makes parent script auto-search and auto-load modules automatically.

Because AHK lacks of executing dynamic code (e.g in variables) I must make some workaround concept to loading multiple inclusions based on the following algorithm:
1. Parent script at first execution searches for modules and creates modules.ini file with contents like this:
Code:
;MODULES.INI FILE (after auto-searching modules byAutoConfigureModules(configfilename) function)

#Include modules\first_found_module.ahk
#Include modules\mouse_module.ahk
#Include modules\windows_module.ahk
#Include modules\keyboard_module.ahk
#Include modules\my_drive_crypt_module.ahk
#Include modules\multi-clipboard.ahk
;etc.
2. and restarts itself with parameter telling to skip modules searching in upcoming instance.
3. Then in new instance directive #Include modules.ini loads all detected modules automatically.

Parent script may look like this:
Code:
;PARENT SCRIPT
#Include internal\internal_functions.ahk
GetCmdParams()
if not SkipConfiguration
{
   AutoConfigureModules("modules.ini")
   Restart("/skipcfg")
}
#Include *i modules.ini

Some handy internal functions:
Code:
;INTERNAL\INTERNAL_FUNCTIONS.AHK FILE
GetCmdParams()   {
   local cmdparam
   Loop, %0%
   {
      if %A_Index% in /skipcfg,-skipcfg
         SkipConfiguration=1
   }
}

AutoConfigureModules(configfilename)   {
   global
   ;in this function all *.ahk files are enumerated in modules sub-folder, and are listed to modules.ini file after #Include directive
}

Restart(restartparameter)   {
   global
   if A_IsCompiled
      Run, %A_ScriptFullPath% /restart %restartparameter%
   else
      Run, %A_AhkPath% /restart %A_ScriptFullPath% %restartparameter%
   ExitApp
}

Finally auto-searching and auto-loading modules works fine with AHK source scripts.
The main benefit to the user is installing ahk add-ons as modules by simply copying module to its folder without editing any code.

Unfortunatelly this method not works with compiled scripts. Sad

ps
Keep in mind that for code simplification of my approach I pass over all majkinetor's functions and algorithms, but they can be easily fused by experienced users.
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3626
Location: Belgrade

PostPosted: Mon Sep 04, 2006 3:17 pm    Post subject: Reply with quote

I was thinking originaly to create something like this, even with configuration dialog witch user would use to enable/disable found scripts.

But, it seems that need for script merging is beyond this community for now, according to the feedback both you and me got for this investigation. This doesn't bother me much, since I merge all my scripts into single script anyway, but we will never have "proffesional merging" until more people are interested, that is, until something rings a bell in the head of "typical user", since that one is only relevant for the future of AHK.

This is much more important for me after I discovered that eatch script, even the basic one, eats about 5MB of system memory. Merged scripts eat also 5 MB of memory since this RAM value is not because of badly written code (generally)

I also like the idea of plug-ins very much. Most of the people only have glances of AHK power or how it should grow.


PS: The newest AHK addon GUI label can be used for easier GUI separation (although benefits are small). Maybe we will have more luck when #v2 directive comes but I keep that at the lowest level of optimism
_________________
Back to top
View user's profile Send private message MSN Messenger
Tester



Joined: 06 Jul 2006
Posts: 48
Location: Poland

PostPosted: Mon Sep 04, 2006 3:42 pm    Post subject: Reply with quote

majkinetor wrote:
I was thinking originaly to create something like this, even with configuration dialog witch user would use to enable/disable found scripts.
Exactly Smile

majkinetor wrote:
I also like the idea of plug-ins very much.
Yes, recently I too try to write some universal container for modules/plugins. But now I haven't enough time, so I write average few lines of AHK code per week Very Happy

Btw originally I have idea for free plugins/modules manager and free and payed plugins, but for this to work it should be implemented in AHK running code from variable. Then it would be possible to distribute either free and crypted/payed AHK (sub)code, and executing it dynamically.
You can look at this topic: http://www.autohotkey.com/forum/viewtopic.php?t=11282

majkinetor wrote:
PS: The newest AHK addon GUI label can be used for easier GUI separation (although benefits are small).
Yes, I have seen it and agree.
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
Page 1 of 1

 
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