问题
I am trying to make a gesture based PowerPoint slideshow. JavaScript would certainly not work here as I want my slideshow to work when that particular PowerPoint file (.ppt) is opened for windows.
I googled, posted a question on the Leap Motion forum, but in vain. My primary concerns are:
I am unsure about what to use here. Are there some SDKs for this purpose? In simple words, how do I write some custom code for a PowerPoint file on our system? Leap Motion apps can be developed with C#, C++, Python, JavaScript, Java, Objective-C
Integrating the code for Leap Motion device with the above code.
It's OK if you reply with any of the two points. I am sorry I couldn't post any code as I am absolutely new to PowerPoint-based programming for the system itself.
I am open to any language (C, C#, C++, Java, and Objective-C) that lets me accomplish my task. Sugesstions with some information/code would definitely help.
I am a PHP and JavaScript developer. I hope I am clear and not misunderstood.
Update:
I found LEAP Motion Controller Add-ins for Microsoft Office 2010/2013 (C#).
回答1:
The LEAP Motion Controller Add-ins for Microsoft Office which you found is likely to be the best way to integrate the controller with Powerpoint.
To get started with it, you'll need Visual Studio (seems like you'll need 2012). Microsoft has an overview page for Office Development in Visual Studio.
Follow the instructions on the Configuring a Computer to Develop Office Solutions page.
Download the Leap SDK for Windows, and unzip it, then in Visual Studio in the project GestureLib.NET4.0, add a reference to the LeapCSharp.NET4.0 dll
Make a trivial fix to GestureListener.cs (use IsEmpty at line 44).
After that you ought to be able to run the LEAP Motion Controller Add-in from within Visual Studio. It'll start Powerpoint when you do that.
"VSTO" is the name of the technology you are using here, so for more, Google 'VSTO add-in powerpoint'.
From the source code for the Add-In, it looks like you should see a single button on the ribbon in Powerpoint, for starting and stopping Leap.
Looking at ThisAddIn.cs, once started (by pressing the button on the ribbon), the controller ought to respond to left and right gestures, by moving to next/previous slides respectively:-
if (direction.ToString() == "Right")
{
Application.ActivePresentation.SlideShowWindow.View.Next();
LastGesture = DateTime.Now;
}
if (direction.ToString() == "Left")
{
Application.ActivePresentation.SlideShowWindow.View.Previous();
LastGesture = DateTime.Now;
}
GestureLib supports additional gestures, which you could make do something following that same pattern.
回答2:
If your aim is just to interact with a PowerPoint presentation then a simple solution might be to use BetterTouchTool.
It's designed for OS X, it works with the Leap Motion Controller, it allows you to map gestures (captured by the LM Controller) to keyboard shortcuts and as long as it's configured correctly, it works whilst it's running in the background.
Essentially, it should be possible to map a swipe with X fingers to the right as a press on the right arrow key - which will advance the presentation to the next slide. And so on.
If, however, you are looking for a programmatic challenge/hoping to make this in to an app for Airspace then you could use something like Apache POI's Java API.
This is a lot more complicated solution, but it does have the benefit that it will run on OS X - and requires you to muck around with some code :).
It seems like the easiest solution would be to follow the example for exporting the slides in to images. You now have a collection of images - one for each PowerPoint slide. This gives you quite a lot of options, such as
- You can treat this data an an in-memory database (and a web service) and go back to your comfort zone of PHP and JS and use the JS API for the Leap Motion Controller to capture gestures to drive essentially an online picture gallery.
- You can develop a pure Java solution using the Java API to capture gestures from the Leap Motion Controller and display the data using Swing/JavaFX or in the browser using JSF.
回答3:
A very simple solution could look like this:
- Build a basic C# application based on the LeapMotion API (you can use the C# example app from ther SDK). This application must be allowed to run in the background. It connects to the LeapMotion and waits for gestures. It provides a .NET remoting interface (see here for an easy example) and raises an event (see here for an example of events with remoting) for each interesting gesture. When you use the example app, just replace some of the
SafeWriteLine(...)
with the raising the appropriate event. - Build an office add-in with C# (just use NetOffice, it is free). This add-in starts the background app from step 1, connects with remoting and waits for events.
- When the add-in gets an event, it triggers the according actions in PowerPoint (e.g.
presentation.GotoSlide(presentation.Slides.Count)
).
回答4:
PowerPoint and all office tools supports visual basic .net macros. Simply wrote a vb macro for your ppt file that recognizes the gesture and trigger the page change action. This is enough.
If you want, C# code of leap motion can be integrated in your vb.net macro
来源:https://stackoverflow.com/questions/18433059/writing-custom-code-for-powerpoint-using-leap-motion