-
Notifications
You must be signed in to change notification settings - Fork 68
Plugin SDK
Place your created file in the Plugins sub directory and reload AHK Studio.
To get an object for interfacing with AHK Studio
Studio:=Studio()
For the rest of the documentation any mention to the object will be called 'Studio'
Studio.AutoClose(A_ScriptHwnd)
Menus are added using comments.
;menu Your Menu Name,Special_Instructions
The "Special_Instructions" can be used like this.
commandline=%1%
if (commandline="Special_Instruction"){
;Your Code Here
ExitApp ;Needs to be done or it will cause an error.
}
You can replace 'Special_Instructions' with anything as long as it is plain text with no spaces (think variable definitions)
You can easily copy the style from the main window by using this code.
info:=Studio.Style()
Gui,Font,% "c" info.color " s" info.size,% info.font
Gui,Color,% info.Background,% info.Background
And then code your GUI however you like.
Just be Absolutely sure that when you close the GUI or are done running the script to use ExitApp to cleanly exit your plugin
Getting the text from the current include can be done by
text:=Studio.sc.gettext()
sc stands for Scintilla Control, and gettext() is the function that gets the text
text:=Studio.Publish(1)
Publish is a function that gets the entire project put together including all of the include files
Any function can be called
text:=Studio.call["Publish",1]
There are several commands that you can call to. I will not go into a list here but all of the menu items are either attached to a function or label with all spaces replaced with _ so for example
hotkey:=convert_hotkey("^f")
That will return Ctrl+F
You can interface directly with the classes and global variables
settings:=Studio.get("settings")
That will retrieve the settings xml. Be careful with it because if you change something important you may end up ruining your settings and have to start over.
You can use this for storing information for your GUI or whatever you need saved.
settings:=Studio.get("settings")
settings.add({path:"Your_Setting_Root",att:{attribute:"attribute name",title:"Title of Something"}})
settings.save(1)
Then to get the information back
Object:=settings.ea("//Your_Setting_Root")
MsgBox % Object.attribute " " Object.title
There are a lot of commands for SciLexer.dll or the Scintilla Control and they can be found Here
There are codes associated with all of the commands found on that page. They can be found by going to Special Menu/Scintilla Code Lookup
A quick example:
sc:=Studio.sc() ;You only have to call to this once to get the Scintilla Control object (sc)
sc.2181(0,["New Text"]) ;This will change the text in the window to New Text
;Just an fyi for this. If you have a variable or want to change the text to digits only, enclose your new text inside of []
I have a few basic controls that make it a bit easier to get information from the control.
sc:=Studio.sc()
text:=sc.gettext() ;Use this to get the text from the current control
selectedtext:=sc.getseltext() ;Use this to get the currently selected text
textrange:=sc.textrange(40,45) ;This will get the text from position 40-45 without needing to change the selection
line:=sc.getline(20) ;This will get the 21st line (everything is 0 based so the first line is actually 0 not 1)
That is it for the basics. If you want to do anything more advanced please see My Plugins for a few more examples.
Studio.SetTimer("Label_Name",Period)
The period will be converted to a negative number so that it is only run once.
Studio.EnableSC([0:1])
0= Disables redraw for the Scintilla Control 1= Enables redraw for the Scintilla Control