Jump to content

AutoIt3 + Visual C++ 2010 Express Edition


Recommended Posts

I really like how Au3 works and I would like to use it with C++/ I saw a thread here describing how but it just doesn't seem to be working for me

http://www.autoitscript.com/forum/topic/60107-using-autoitx-in-visual-c-and-dev-c/

Here is what I do:

1: Create new project -> Empty Project Visual C++ ( I named it Attempt )

2: Copy AutoIt3.h AutoItX3.lib AutoItX3.dll main.cpp and Paste into my project file directory (Documents\Visual Studio 2010\Projects\Attempt)

3: When I try to do "in visual studio, go to Project->Add To Project->Files" I have no option of "Add To Project" but there is an option to add existing files which ends up adding all of the above files

4: I now try to run, this is the error I get

1>------ Build started: Project: Attempt, Configuration: Debug Win32 ------
1>  main.cpp
1>c:\users\pent\documents\visual studio 2010\projects\attempt\main.cpp(17): error C2664: 'AU3_Run' : cannot convert parameter 1 from 'const char [12]' to 'LPCWSTR'
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\pent\documents\visual studio 2010\projects\attempt\main.cpp(18): error C2664: 'AU3_WinWaitActive' : cannot convert parameter 1 from 'const char [11]' to 'LPCWSTR'
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\pent\documents\visual studio 2010\projects\attempt\main.cpp(19): error C2664: 'AU3_Send' : cannot convert parameter 1 from 'const char [9]' to 'LPCWSTR'
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

5: I now try to change "APIENTRY WinMain(....)" in main.cpp to "main()" and run and I get this error

1>------ Build started: Project: Attempt, Configuration: Debug Win32 ------
1>  main.cpp
1>c:\users\pent\documents\visual studio 2010\projects\attempt\main.cpp(14): error C2664: 'AU3_Run' : cannot convert parameter 1 from 'const char [12]' to 'LPCWSTR'
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\pent\documents\visual studio 2010\projects\attempt\main.cpp(15): error C2664: 'AU3_WinWaitActive' : cannot convert parameter 1 from 'const char [11]' to 'LPCWSTR'
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\pent\documents\visual studio 2010\projects\attempt\main.cpp(16): error C2664: 'AU3_Send' : cannot convert parameter 1 from 'const char [9]' to 'LPCWSTR'
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Btw I'm running windows 7 x64 , I also tried the x64 versions of the files to add in directory, it didn't help.

Can someone lead me in the right direction?

I have uploaded my project folder in an archive, the file exceeds the 64k so I uploaded to a file host. I will post the url to it if I am allowed/ if any1 wants to see it.

Edited by rohaa8673
Link to comment
Share on other sites

Your problem is that you are passing multibyte strings to functions that expect wide strings (AutoIt is unicode).

Use wchar_t instead of char, and prefix your string literals with L like so:

const wchar_t my_string[] = L"String data";

Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG

Link to comment
Share on other sites

Thank you so much, everything works fine now. I guess now I actually have to code the script :mellow:

What I ended up doing was declaring the strings before using them:

const wchar_t my_string[] = L"notepad.exe";

const wchar_t my_string2[] = L"Untitled -";

const wchar_t my_string3[] = L"Hello{!}";

const wchar_t my_string4[] = L"";

AU3_Sleep(1000);

AU3_Run(my_string, my_string4, 1);

AU3_WinWaitActive(my_string2, my_string4, 0);

AU3_Send(my_string3, 0);

Is there any way I could make things a bit more efficient?

Link to comment
Share on other sites

Thank you so much, everything works fine now. I guess now I actually have to code the script :mellow:

What I ended up doing was declaring the strings before using them:

const wchar_t my_string[] = L"notepad.exe";

const wchar_t my_string2[] = L"Untitled -";

const wchar_t my_string3[] = L"Hello{!}";

const wchar_t my_string4[] = L"";

AU3_Sleep(1000);

AU3_Run(my_string, my_string4, 1);

AU3_WinWaitActive(my_string2, my_string4, 0);

AU3_Send(my_string3, 0);

Is there any way I could make things a bit more efficient?

No problem, and yeah you can do it directly:

AU3_Sleep(1000);
    AU3_Run(L"notepad.exe", L"", 1);
    AU3_WinWaitActive(L"Untitled -", L"", 0);
    AU3_Send(L"Hello{!}", 0);

Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG

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
 Share

  • Recently Browsing   0 members

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