Jump to content

Inserting C++ into script

Recommended Posts

I really hate to be of a bother, but I've run into a road block while writing a certain script.

I'm writing a script which is mostly using dll's to control an outside circuit board (com I think?). Anyways, I'm having troubles connecting to it. I have a sample of how to do it in C++ and was wondering if there was a way I could directly insert a small snippet of it into my program.

Also, I have trouble reading C++, the structure just makes my mind shut down, so I'd really prefer not to write this in C++.



Link to comment
Share on other sites

Sorry, you can't use C++ in AutoIt. AFAIK it's impossible.

You'll have to write the program in C++ as a DLL and use it through AutoIt and DLLCall. Now is the time to learn (at least a little) C++, especially if it's your only option. You can't run forever! :shocked:

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.
Link to comment
Share on other sites

Thank you very much. Unfortunately I recently found out that I cannot use C++ for this project since it requires windows.h, which is not allowed for VC++ express. I have been thinking about VB.net or VB6.0, but am still unsure whether I want to give up on autoit or not (one of the few I can understand).

Anyways, just in case the of the off chance that this would be easy to translate, I'm going to post what I wanted to insert. I'm not asking you to translate, just if there is an easy way, a pointer or two would be nice.

#include "stdafx.h"

#include "..\phidget21.h"

#include <windows.h>

void display_generic_properties(CPhidgetHandle phid)


int sernum, version;

const char *deviceptr;

CPhidget_getDeviceType(phid, &deviceptr);

CPhidget_getSerialNumber(phid, &sernum);

CPhidget_getDeviceVersion(phid, &version);

printf("%s\n", deviceptr);

printf("Version: %8d SerialNumber: %10d\n", version, sernum);



int __stdcall IFK_AttachHandler(CPhidgetHandle IFK, void *userptr)


printf("Attach handler ran!\n");

return 0;


int __stdcall IFK_DetachHandler(CPhidgetHandle IFK, void *userptr)


printf("Detach handler ran!\n");

return 0;


There is more, but it starts repeating the same structure, just different calls.

EDIT: Now that I looked at it again, I'm thinking that this isn't enough information to be useful. I'll continue to try and figure it out by myself, but leave it up just in case I'm wrong.

If you were curious, what I found.

"A decision was made long ago by the team that Visual C++ Express (a free product) cannot be used for native Windows development out of the box. It can only be used for .NET/CLR development."



Edited by Paranoia
Link to comment
Share on other sites

The only way you're going to use AutoIt and C++ together is with Dll's and Dll calls.

http://www.autoitking.co.nr Site is DOWN | My deviantART | No Topic Topic - Don't do it!-------------------- UDF's/Scripts:AutoIt: [BenEditor 3.6] [_ShutDown()]PHP: [CommentScript]Web Based AutoIt: [MemStats] [HTML to AU3] [User LogIn and SignUp script]
Link to comment
Share on other sites

No one seems to be aware that you can make AutoIt Plugins as well which doesn't require a DLLCall. Here's the thread.

I have made a few plugins, and they are a great addition to AutoIt.

I hope you are able to get your problem solved.

I would recommend you dont use M$ Compilers. Especially with that limitation in mind. Why dont you try Code::Blocks. That's your development environment. I would then use also MinGW as your compiler. Though you can use VC++2005 with C::B as well.

Just my opinions,


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

why cant you use C++??? almost all the free c/c++ compilers allow use of windows.h for Win32API calls


if i needed to "mix" code.. i would make the code for the part i needed in another language

then i would compile it.

then i would just do a fileinstall with autoit (include it inside the script) and basically run it when its needed.

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

if i needed to "mix" code

I dont understand what you mean by this, is it to do with using Win32 API calls in C++ (because the Win32 API is C based).

It was an example. My point was compilers like djgpp, mingw and DevC++ allow usage of the windows.h file (the problem that had arisen, and why MS VC++ Express could not be used.)

If i was writing a Win32 app i would use Qt, or wxWidgets to generate the Win32 calls, but at the end of the day everything runnng on windows must call the Win32 API at some stage, even CLI and MFC call the Win32 API.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...