saaadhu / choreo

Atmel Studio extension for writing macros
3 stars 0 forks source link

Add example which shows how to use the extension #1

Open krist10an opened 11 years ago

krist10an commented 11 years ago

Hi,

This looks very interesting for me, but I find it hard to get started. Can you add an example which inserts some text into the current document as a starting point? That would be most helpful.

saaadhu commented 11 years ago

I've expanded the "Using Choreo" section in README.md to include an example of text insertion (see https://github.com/saaadhu/choreo, and scroll down to the README section). Does that help?

krist10an commented 11 years ago

Thanks a lot. I got it working with that description!

Is is possible to get a console somewhere for output from the python script (print) and/or interactive console? I was not able find any.

Are there any other objects than the DTE available? http://msdn.microsoft.com/en-us/library/vstudio/envdte.dte.aspx

saaadhu commented 11 years ago

The DTE object covers most of the Visual Studio Shell APIs. There are no other objects injected into the Python environment, but you can always reference DLLs from the python files themselves. For Atmel Studio specific functionality, there is the Atmel Studio XDK (http://gallery.atmel.com/Partner). The following snippet inserts the name of the device currently being debugged into the output window. It adds a reference to the SDK dll, imports a type, and then proceeds to call methods and access properties in that type. This also shows how you can use the VS output window as a console.

import clr
from System import DateTime
from System.Diagnostics import Process

clr.AddReferenceToFileAndPath("C:\Program Files (x86)\Atmel\Atmel Studio 6.1\extensions\Application\Atmel.Studio.Services.Interfaces.dll")
from Atmel.Studio.Services import ATServiceProvider

def InsertTargetName():
    device = ATServiceProvider.TargetService2.GetLaunchedTarget().Device.Name
    writeToOutputWindow(device)

def writeToOutputWindow(message):
    window = dte.Windows.Item("{34E76E81-EE4A-11D0-AE2E-00A0C90FFFC3}");
    window.Object.ActivePane.OutputString(message);