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 

Plugin concept?

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
AGU
Guest





PostPosted: Sat Jun 17, 2006 12:41 pm    Post subject: Plugin concept? Reply with quote

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

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
Back to top
Roland



Joined: 08 Jun 2006
Posts: 307

PostPosted: Sat Jun 17, 2006 8:01 pm    Post subject: Reply with quote

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
}
Back to top
View user's profile Send private message
AGermanUser



Joined: 12 Feb 2005
Posts: 82

PostPosted: Mon Jun 19, 2006 3:23 pm    Post subject: Reply with quote

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? Mr. Green
___________________
Cheers
AGermanUser a.k.a. AGU
Back to top
View user's profile Send private message
Roland



Joined: 08 Jun 2006
Posts: 307

PostPosted: Mon Jun 19, 2006 3:39 pm    Post subject: Reply with quote

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). Smile 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 Question; probably not such a good idea though).
Back to top
View user's profile Send private message
corrupt



Joined: 29 Dec 2004
Posts: 2485

PostPosted: Tue Jun 20, 2006 2:36 am    Post subject: Reply with quote

WM_USER, WM_APP
Back to top
View user's profile Send private message Visit poster's website
ProsperousOne



Joined: 19 Sep 2005
Posts: 115

PostPosted: Mon Sep 29, 2008 9:25 pm    Post subject: Reply with quote

corrupt wrote:
WM_USER, WM_APP


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
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help 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