Skip to content
Chad Wilson edited this page May 17, 2017 · 13 revisions

AHK Studio version 1.0.43+ will have support for Plugins.

A plugin for using ahk.us.to

Place your created file in the Plugins sub directory and reload AHK Studio.

Getting the interface:

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'

Structure for your plugin:

Auto Close When Studio Closes

Studio.AutoClose(A_ScriptHwnd)

Menu Items

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)

Styling Your GUI Window

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 Information From Studio

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

Getting The Entire Project

text:=Studio.Publish(1)

Publish is a function that gets the entire project put together including all of the include files

Using Functions From AHK Studio

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

Getting Globals And Classes

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

Changing The Text In The Current Segment (include file)

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 []

Built In Commands For The Scintilla Control

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.

Running Labels

 Studio.SetTimer("Label_Name",Period)

The period will be converted to a negative number so that it is only run once.

Disable/Enable the main Scintilla window

 Studio.EnableSC([0:1])

0= Disables redraw for the Scintilla Control 1= Enables redraw for the Scintilla Control

Clone this wiki locally