Jump to content

Trouble With Autoitdll


Recommended Posts

when ever i use the send function in c++ it will not compile it, i have the header file in the right directory, i onlt get an error with the send function heres what i type;

void WINAPI AUTOIT_Send(char, Send "{Left}");

and the error i get is

: error C2061: syntax error : identifier 'Send'

what do i do about this

(i'm working in visual c++ 6)

Link to comment
Share on other sites

  • Administrators

Make sure you check the AutoItDLL example, there is a fully working VC6 project in there. The main things to remember to do are

1. Remember to include AutoIt.h

2. Remember to add AutoItDLL.lib to your linker settings

3. Your call doesn't look right, here is the example code for doing a Send

// Empty project additions:
//  Added "AutoIt.h" include
//  Added "AutoItDLL.lib" to the linker libraries
//
// AutoItDLL.dll needs to be in the run path during execution

#include <Windows.h>
#include "AutoIt.h"

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
  // You can now call AutoIt commands, e.g. to send the keystrokes "hello"
    Sleep(2000);
    AUTOIT_Send("hello");

    return 0;
}

Link to comment
Share on other sites

ok it compiles properly but now i get some more errors when trying to build the exe

this is my code

// Empty project additions:
//  Added "AutoIt.h" include
//  Added "AutoItDLL.lib" to the linker libraries
//
// AutoItDLL.dll needs to be in the run path during execution

#include <Windows.h>
#include "AutoIt.h"

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
  // You can now call AutoIt commands, e.g. to send the keystrokes "hello"
   
    void WINAPI AUTOIT_LeftClick(int n700, int n457);

    Sleep(500);

    void WINAPI AUTOIT_LeftClick(int n712, int n572);

    Sleep(500);

    AUTOIT_Send("{Left}");

    void WINAPI AUTOIT_SetKeyDelay(int n2500);

    return 0;
}

and here is the error i get

--------------------Configuration: suibot - Win32 Debug--------------------
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/suibot.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

suibot.exe - 2 error(s), 0 warning(s)

and i did add the autoitdll.lib to the linker settings and the autoit.h file too. what do ?

Link to comment
Share on other sites

You're trying to compile it as a console app. It's looking for an entry point named "main" but the code is written to be compiled as a Windows app, so it uses the entry point "WinMain". Change the "Subsystem" in the configuration page to a Windows program and you'll be okay.

Link to comment
Share on other sites

  • Administrators

Why don't you just use the complete example project as your starting point. There is no way we will ever be able to talk you through setting up a complete VC6 app from scratch.

Either that or open the example project and look at the Project / Settings. There are about 50 tabs that change the way the program will be compiled and they have to be correct. Although doing a File / New Project / Win32 Application (not console) should generate a base set of files that work (that's how the example was created).

Also you don't include all the "VOID WINAPI" stuf in a function call. Do like the AUTOIT_Send in the example.,

Link to comment
Share on other sites

ok, well, i've tried your advice and i'm running into even more problems. All i need to know how to do is

Change the "Subsystem" in the configuration page to a Windows program and you'll be okay.

i went into the project settings and couoldnt find it, is it possibe to do this. It compiles fine i just can't write the exe.

If you can't answer my above question:

also if i get rid of the void WINAPI stuff it won't work, it gives me more erroros when i compile.

so i made a win32 app and copied my previous code

// program.cpp : Defines the entry point for the application.
//

#include <Windows.h>
#include "stdafx.h"
#include "Autoit.h"

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
  // TODO: Place code here.

void WINAPI AUTOIT_LeftClick(int n700, int n457);

Sleep(500);

void WINAPI AUTOIT_LeftClick(int n712, int n572);

Sleep(500);

AUTOIT_Send("{Left}");

void WINAPI AUTOIT_SetKeyDelay(int n2500);

return 0;
}

now it compiles with out any errors until i try to build the exe then i get this

--------------------Configuration: bot2 - Win32 Debug--------------------
Linking...
program.obj : error LNK2001: unresolved external symbol _AUTOIT_Send@4
Debug/program.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

program.exe - 2 error(s), 0 warning(s)

so what does this mean, and what can i do about it.

i appreciate all your help, i shouldn't be having this much trouble

Link to comment
Share on other sites

  • Administrators

ok start from scratch.

Can you compile and run the example project from the AutoItDLL zip file? I just open it up, click build and it works fine.

The only thing I can think of is that you are using the wrong autoit.h with the wrong dll and library (there are two versions, static and dynamic - both with examples in seperate directories)

If you can't get one of the examples to build (not the stuff we've been writing here, the actual Visual C 6 examples that come in the zip file) then we aren't going to get very far.

As to your error message, it means you aren't linking AutoItDLL.lib to your program. (project/settings/linker/input). Actually, the version you link also depends on which version (static or dynamic) you are using. You need to tell us that too.

Link to comment
Share on other sites

ok i open up autoitdll, then open up the c folder then i open the visual 6 and i see 2 folders, staticlib and dll, i can't build either one, and i'm using the header and lib from the dll folder, i'm running in xp, i don't know if that makes a difference or not.

and i'm tring to compile that scrip i showed at the begginning of this whole thing. but still the examples won't build for me. :whistle::angry:B)

so thats where i'm at right now

ok, i also put the AutoItDll.lib in the input part in link and i get this now

--------------------Configuration: suibot - Win32 Debug--------------------
Linking...
AutoItDll.lib : fatal error LNK1136: invalid or corrupt file
Error executing link.exe.

suibot.exe - 1 error(s), 0 warning(s)

and i tried the one from the staticlib and they don't work either

Link to comment
Share on other sites

  • Administrators

Your visual C is broken then. Reinstall Visual C 6 and make sure you apply the latest visual studio 6 service pack (5 I think). Then I just do this to build an example:

1. Load visual C

2. File \ Open Workspace

3. Choose dll \ example \ main.dsw

4. Select Build \ Build main.exe

--------------------Configuration: main - Win32 Release--------------------
Compiling...
main.cpp
Linking...

main.exe - 0 error(s), 0 warning(s)

Link to comment
Share on other sites

well i re-installed visual c++ then got the service pack 5 and installed that then did exactly what you told me to do and i still get the linking errors. i have know idea what to do. i don't think autoit and c++ is guna work for me. unless there is anything else i can do i'm guna scrap my whole project.

thanks for the help anyway

Link to comment
Share on other sites

  • Administrators

Well, I'm out of ideas :whistle: Lots of people use it fine and I've checked and rechecked that the example works out of the box.

The only other guess would be if you are using Visual C Standard (rather than Pro/Enterprise) as I heard that it does certain things differently. But apart from that I have no clue.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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