AutoHotkey Community

It is currently May 27th, 2012, 7:28 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Plugin concept?
PostPosted: June 17th, 2006, 1:41 pm 
Ok, here's another post related to one of my previous question about quitting an AHK script from within another script. It aimed at an idea about some kind of plugin system for BBCodeWriter. Goyyah's rainbow text and he personally himself brought me to this idea.

Let's get into detail about this idea as how far I thought about it.

I thought about creating another submenu (PlugIns) within the main menubar which is filled upon startup. BBCodeWriter should loop through the plugins subfolder within the script's directory and pick all .ahk scripts in order to import it as an entry to the mentioned plugin menu.

I also thought about some kind of defined format for these PlugIn scripts. E.g. it would be good if the script provides it's own hotkey keys with which it could be called from within the main script by using the hotkey command. So we would need a variable defined which holds the key values for this.
  • The first idea of a Plugin script is the already mentioned rainbow text script by Goyyah extended by the color fade option (stay within one color) also mentioned in the concerning thread. Using the specified hotkey within the script will call a small GUI that lets you enter your text and decide whether you want a rainbow or a color faded text.
  • A second idea raised after reading about the new forum improvements. The forum now supports color formatting within code tags. So I thought about some simple syntaxhighlighter for Autohotkey code that will color up the code by looking for keywords. Maybe these keywords can be extracted from any of these textfiles provided within the "extra" folder within the Autohotkey install folder.

As these PlugIn scripts should be loaded together with the main script they shouldn't have any tray icon. So I'm looking for a way to exit these plugin scripts when exiting the main script. Otherwise these plugins would still be in effect and a user wouldn't even notice that these scripts are running apart from checking the taskmanager.

In the previous thread SendMessage in combination with the OnExit label was proposed as a possible solution. As I'm relatively new to all this WM_Messages thingie I'm asking myself what message should be sent and how. Does anybody maybe have a short example script that closes another script with the help of SendMessage?
Is SendMessage the proper way to solve this problem or do you see a better solution to get some kind of plugin system?

I hope you don't think I'm expecting full working code or someone who does the work for me. I just want avoid going into the wrong direction with the concept and discover afterwards that I can't solve the problem with it. On the other hand I'm looking for additional ideas to sharpen the concept. Maybe anyone of you has some brilliant ideas about this which I haven't thought about yet. :)

Put in a nutshell, I'm looking for a solution that lets a user modify its own BBCodeWriter installation with plugins that can expand its possibilities without changing the main script because these "possibilites" aren't needed by all users.

_________________
Cheers
AGU


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 17th, 2006, 9:01 pm 
Offline

Joined: June 8th, 2006, 9:38 pm
Posts: 307
Quote:
In the previous thread SendMessage in combination with the OnExit label was proposed as a possible solution. As I'm relatively new to all this WM_Messages thingie I'm asking myself what message should be sent and how. Does anybody maybe have a short example script that closes another script with the help of SendMessage?


Here's what I have been using.

Code:
;#### Script1 #####

Run, Script2.ahk
return

^!e::
DetectHiddenWindows On
SetTitleMatchMode 2
If WinExist("Script2.ahk ahk_class AutoHotkey")
  PostMessage, 0x5555
return


Code:
;#### Script2 - Save as Script2.ahk #####

#SingleInstance force
;#NoTrayIcon
OnMessage(0x5555, "HandleMsg")
return

HandleMsg()
{
Msgbox Script2 will exit.
ExitApp
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 19th, 2006, 4:23 pm 
Offline

Joined: February 12th, 2005, 8:31 pm
Posts: 82
Thx Roland,

I'll give it a try.

I've got two questions concerning your sample scripts.

  • Why are you using "0x5555" as value for PostMessage. Can't find it in the Message List.
    Is it allowed to use any value you want? Did you use it because it would be an unique value not recognized by other programs?
  • Can I exit more than one script with this method as long as all scripts have an OnMessage label that catches 0x5555? Or would the first script with the OnMessage routine "swallow" the Message for all other scripts?

Sorry if these questions sound silly to you? :mrgreen:
___________________
Cheers
AGermanUser a.k.a. AGU


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 19th, 2006, 4:39 pm 
Offline

Joined: June 8th, 2006, 9:38 pm
Posts: 307
Quote:
Why are you using "0x5555" as value for PostMessage. Can't find it in the Message List.
Is it allowed to use any value you want? Did you use it because it would be an unique value not recognized by other programs?


Well, I just followed the example (somwhere under OnMessage() I think). :) But IIRC it is because system messages are all lower than 0x5555 or something.

Quote:
Can I exit more than one script with this method as long as all scripts have an OnMessage label that catches 0x5555? Or would the first script with the OnMessage routine "swallow" the Message for all other scripts?


You have to post the message to the script you want to exit. No other windows will get that message (although maybe you could post it systemwide :?:; probably not such a good idea though).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2006, 3:36 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2545
WM_USER, WM_APP


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 29th, 2008, 10:25 pm 
Offline

Joined: September 19th, 2005, 1:31 am
Posts: 115
corrupt wrote:


I tried several times to use WM_USER & WM_APP (PostMessage 0x400 & 0x8000) to no avail. However, I did create a simple app that closes all Scripts except for the AutoHotkey.exe:

Code:
#NoEnv
#Persistent
#SingleInstance force

+^Esc::
DetectHiddenWindows On
SetTitleMatchMode 2
WinGet, ScriptID, List, ahk_class AutoHotkey, , AutoHotkey.ini
Loop, %ScriptID%
  {
     ID := ScriptID%A_Index%
     WinClose, ahk_id %ID%
  }
Return


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: HotkeyStick, oldbrother, sjc1000, thor and 59 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group