Jump to content
Sign in to follow this  
JohnOne

Noob Autoitx dll [Solved]

Recommended Posts

JohnOne

I've been Trying to learn enough C++ to use Autoitx

But fell at the first hurdle, even though Ive started simple.

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

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
int main()
{
    AU3_Sleep(1000);
        
    return 0;
}
My compile error is

------ Build started: Project: AU3TEST, Configuration: Debug Win32 ------

main.cpp

main.cpp(11): error C2144: syntax error : 'int' should be preceded by ';'

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Am I way off the mark here? Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
edddy

try this..

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

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow);
int main()
{
    AU3_Sleep(1000);
        
    return 0;
}
Edited by edddy

Share this post


Link to post
Share on other sites
JohnOne

Hi eddy, I had tried that, but it just generated more errors, So didnt know if it was more errors, or just errors not caught because of the syntax error.

I get

------ Build started: Project: AU3TEST, Configuration: Debug Win32 ------

main.cpp

main.obj : error LNK2019: unresolved external symbol _AU3_Sleep@4 referenced in function _main

MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

C:\Users\john\Documents\Visual Studio 2010\Projects\AU3TEST\Debug\AU3TEST.exe : fatal error LNK1120: 2 unresolved externals

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

This is way after trying the example in the autoitx folder, and getting all sorts of errors, which I could not resolve related to strings, and persisting after changing my settings to "Use Multi-Byte Character Set".

I know I need to learn more C++ but Im just twitchy and want to get a feel, "OOh Matron".


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
Mat

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

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
    AU3_Sleep(1000);
        
    return 0;
}

Share this post


Link to post
Share on other sites
JohnOne

Thanks Mat, for the reply.

I was pretty excited there for a minute, but alas, another compile error similar to the last :blink:

------ Build started: Project: AU3TEST, Configuration: Debug Win32 ------

main.cpp

main.obj : error LNK2019: unresolved external symbol _AU3_Sleep@4 referenced in function _WinMain@16

C:\Users\john\Documents\Visual Studio 2010\Projects\AU3TEST\Debug\AU3TEST.exe : fatal error LNK1120: 1 unresolved externals

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Which as far as I can tell is the same as above without "_main

MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol"

The project was started by adding the whole example folder from "AutoitX/standardDLL/VC6/" then editing out the code from original main.cpp, leaving just the Sleep() call.

There are no intelisense errors.

Any more help is very much appreciated.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
Authenticity
AutoIt3.h define the imported functions prototypes. You need to link to the dll as well. Consult your IDE user-manual on how to link to a dll, either statically or dynamically. Usually, it's under Project Properties -> Linker -> References or Dependencies.

Share this post


Link to post
Share on other sites
JohnOne

Cheers Pal

After looking into it and some searching I read a number of times this

Do you want to use functions from a dll in your program?

If yes, you require the following 3 files:

the DLL (eg usedll.dll)

a header for the dll (eg usedll.h)

and the library for this dll (eg usedll.lib)

Step 1:

Now you have to go to the project-options dialog, tab "linker".

There's a textbox with names like "gdi32.lib","user32.lib" asgo.

Go to the end of this textbox and type the name of the libfile of your dll in the box (eg usedll.lib)

Leave the dialog by pressing OK.

Step 2:

Now #include the dll-headerfile (eg #include "usedll.lib") in each *.c or *.cpp file in your project which use the dll-functions.

Step 3:

At last the dll-file must be in the path of your application or in a path set in the enviroment-string path or in the windows-directorys.

So the code looked like below, and I have AutoItX3.dll in project folder and system32 folder, and AutoItX3.lib in same as well as in "Program files\Microsoft SDKs\Windows\V7.0a\lib\".

In my project prperties under linker-input-additional dependencies it looks like this

kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib,AutoItX3.lib;%(AdditionalDependencies)

#include <Windows.h>
#include "AutoIt3.h"
#include "AutoitX3.lib"

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
    AU3_Sleep(1000);
        
    return 0;
}

And it generated a ton of errors (Below) and crashed Visual Studio :blink:

------ Build started: Project: AU3TEST, Configuration: Debug Win32 ------

main.cpp

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(1): error C2059: syntax error : '<'

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(2): error C2018: unknown character '0x60'

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(3): error C2017: illegal escape sequence

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(3): error C2017: illegal escape sequence

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(3): error C2018: unknown character '0x60'

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(3): error C2018: unknown character '0x60'

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(3): error C2018: unknown character '0x16'

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(3): error C2018: unknown character '0x16'

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(3): error C2018: unknown character '0x1e'

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(3): error C2018: unknown character '0x1e'

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(3): error C2018: unknown character '0x6'

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(3): error C2018: unknown character '0x6'

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(3): error C2059: syntax error : 'bad suffix on number'

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(3): error C3193: '^' : requires '/clr' command line option

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(3): error C2059: syntax error : ':'

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(3): error C3193: '^' : requires '/clr' command line option

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(3): error C2059: syntax error : ':'

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(3): error C2470: 'Ð' : looks like a function definition, but there is no parameter list; skipping apparent body

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(3): error C2059: syntax error : ';'

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(3): error C2059: syntax error : ';'

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(3): error C2630: ';' found in what should be a comma-separated list

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(3): error C2059: syntax error : ';'

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(3): error C2630: ';' found in what should be a comma-separated list

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(3): error C2059: syntax error : ';'

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(3): error C2630: ';' found in what should be a comma-separated list

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(3): error C2059: syntax error : '<'

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(5): error C3872: '0xa0': this character is not allowed in an identifier

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(5): error C3872: '0xa0': this character is not allowed in an identifier

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(5): error C2018: unknown character '0x40'

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(5): error C2018: unknown character '0xe'

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(5): error C2018: unknown character '0x40'

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(5): error C2018: unknown character '0xe'

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(5): error C2018: unknown character '0x40'

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(5): error C2018: unknown character '0x40'

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(5): error C2018: unknown character '0x40'

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(5): error C2018: unknown character '0x40'

c:\users\john\documents\visual studio 2010\projects\au3test\AutoitX3.lib(5): fatal error C1004: unexpected end-of-file found

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Im proper stumped.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
Authenticity

Telling you what to do next will make no difference, you're missing the fundamentals. Go read a book about C and then about Windows Application Programming Interface. You'll get stuck in the next C or API knowledge based problem and ask the same question without getting any farther, either way.

.LIB files are input files, not included source files. ..my 2 cents..

Share this post


Link to post
Share on other sites
JohnOne

Quick last thing, then I'll stop asking questions... for now :blink:

Ive finally got started, after all the pissing around trying all sorts of silly stuff, the only thing that was wrong really from the start, was a mistake on my part, mistaking a semi colon for a comma when adding the lib.

Now its debugging and completing some mouse functions I've been testing, but should I be worried about some messages I'm getting?

For all the dll files my project loads I get "Cannot find or open the PDB file"

except for autoitx3.dll which the message is "Binary was not built with debug information."

Is this going to wind up a major pain in the arse down the line? given that the project compiles and runs from the exe.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
Richard Robertson

You need to specify a location for the debug file. It's in the properties for the project.

Share this post


Link to post
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
Sign in to follow this  

×