If you haven't yet read the section About ASCOM, you should really go there and read it now. Knowing the basics and design philosophy can save you time and frustration compared to starting with pre-conceived ideas and ending up frustrated. Consider starting out with Alpaca, which is cross-platform, instead of classic ASCOM/COM.
Using ASCOM drivers differs in detail depending on the language you are using for your application. Over 20 languages on Windows can use drivers, so it's beyond the scope of this document to describe the details for each. The place to start is the documentation for your language that covers "COM Automation" or "ActiveX".
The ASCOM Client Toolkit is an assembly that greatly simplifies using drivers from .NET applications. Astronomy app developers wishing to use ASCOM drivers from .NET applications on Windows are encouraged to use this library, as it provides not only simplified access to drivers, but also automatic switching between the preferred early-binding interfaces and, for older drivers that don't support it, late-binding. If late binding is needed, the Client Toolkit hides all of the ugly details of calling a driver via its late-bound interface. Your code will always use native .NET class/object syntax.
C++ is by far the most difficult language from which to use ASCOM drivers (or for that matter, any Windows COM Object). Since drivers in general only support "late binding", it's necessary to implement complex IDispatch-based code to call them. The ActiveX Template Library can be a help, but it's still really difficult. You'll have to write wrapper code and be very careful calling the interface members. The learning curve is steep. Consider how married you are to C++ before starting your new astronomy application development.
Yes. The pywin32 package provides access to the ActiveX/COM features in Windows that ASCOM/COM uses. However we recommend that any new Python applications use ASCOM Alpaca to talk to astronomical devices. Your app will be cross-platform and independent of the large and complex Win32 APIs in pywin32.
It's very easy to use an ASCOM driver in most Windows languages. The basic steps are:
At this point you can control the device via the standard interface members (properties and methods). See the interface standard documents installed with the ASCOM Platform.
The following script, written in the JScript language, shows how simple it is to control a telescope using ASCOM/COM on Windows. We use the Telescope Simulator, part of the ASCOM Platform. The simulator is a Telescope driver; it's a great tool for testing your code. To switch over to talking to some other (real) telescope, all you need to do is change the driver ID from ASCOM.OmniSim.Telescope to SomethingElse.Telescope. That's it!
var T = new ActiveXObject("ASCOM.OmniSim.Telescope"); // Change for your driver's ID
T.SetupDialog(); // Comment this out once you set COM port, etc.
T.Connected = true;
WScript.StdOut.WriteLine("RA = " + T.RightAscension);
WScript.StdOut.WriteLine("DE = " + T.Declination);
if (T.CanSetTracking && !T.Tracking)
T.Tracking = true;
WScript.StdOut.WriteLine("Slewing to 1 hour east of meridian...");
T.SlewToCoordinates(T.SiderealTime + 1.0, 0);
WScript.StdOut.WriteLine("... slew complete");
WScript.StdOut.Write("Press Enter to quit and release the driver ");
WScript.StdIn.ReadLine();
Create a file ASCOMHello.js with this script in it. Open a CMD shell and change to the directory containing the new script file. Run the script with the Windows Script Host cscript. This program plays the same role as (e.g.) the Perl or Python interpreters for those languages.
C:\Foo\Bar\> cscript ASCOMHello.js
RA = 9.660283023289306
DE = -1.286254097879772e-7
Slewing to 1 hour east of meridian...
... slew complete
Press Enter to quit and release the driver
C:\Foo\Bar\>
After typing the command, you'll see the Omni Simulator's server console window appear, along with a popup advising that you need the web browser to change its settings. Just click OK on that. Now the script should produce the above result. Note that the simulator server's condole window is still minimized. The next time you want to use the simulator it will run much faster (no startup). Feel free to close this window to shut down the simulator server.
NOTE: If you are on a 64-bit system, you may need to be running this in a 32-bit CMD shell if your device's driver is a 32-bit DLL type. To open a 32-bit CMD shell, run C:\Windows\SysWOW64\cmd.exe