Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

[Problem]Autoit w c++


Rekomendowane odpowiedzi

Opublikowano

Witam, wiecie może jak w środowisku microsoft
visual c++ używać komend autoit. W angielskich poradnikach jest żeby
importować autoit.h (znalazłem go w folderze z autoitem) ale jak napisać
kod w c++ i, w którym jego miejscu pisać kod autoit? Pomożecie?
Mam coś takiego:

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

typedef void (__stdcall *pAU3_Sleep)(long);

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR   lpCmdLine,
                     int       nCmdShow)
{
    HMODULE dllHandle = LoadLibrary("AutoItX3.dll");
    
    pAU3_Sleep funcHandle = (pAU3_Sleep)GetProcAddress(dllHandle, "AU3_Sleep");
    
    funcHandle(1000);
    
    FreeLibrary(dllHandle);
    return 0;
}

No i w którym miejscu i jak pisać komendy z autoit?

Opublikowano

Example z folderu Example x) (AutoIt3\AutoItX\VC6\Example\main.cpp)

 

// Empty project additions:
//        Added "AutoIt3.h" include
//        Added "AutoItX3.lib" to the input linker libraries
//
// AutoItX3.dll needs to be in the run path during execution
 
#include <Windows.h>
#include "AutoIt3.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"
    AU3_Sleep(1000);
    AU3_Run("notepad.exe", "", 1);
    AU3_WinWaitActive("Untitled -", "", 0);
    AU3_Send("Hello{!}", 0);
 
    // Get the text in the status bar
    //char szText[1000];
    //AU3_StatusbarGetText("Untitled -", "", 2, szText, 1000);
    //MessageBox(NULL, szText, "Text:", MB_OK);
 
    return 0;
}
846331404756772371599.jpeg
Opublikowano

1>------ Build started: Project: nie wiem, Configuration: Debug Win32 ------
1> stdafx.cpp
1> nie wiem.cpp
1>c:\documents and settings\szpadel\pulpit\dla autoita\nie wiem\nie wiem\nie wiem.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:\documents and settings\szpadel\pulpit\dla autoita\nie wiem\nie wiem\nie wiem.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:\documents and settings\szpadel\pulpit\dla autoita\nie wiem\nie wiem\nie wiem.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
1> main.cpp
1>c:\documents and settings\szpadel\pulpit\dla autoita\main.cpp(7): warning C4627: '#include <Windows.h>': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\documents and settings\szpadel\pulpit\dla autoita\main.cpp(8): warning C4627: '#include "AutoIt3.h"': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\documents and settings\szpadel\pulpit\dla autoita\main.cpp(28): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?
1> Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

a takiego czegos: AutoIt3X.lib nie mam w folderze autoita

Opublikowano

spróbuj

// Empty project additions:
//        Added "AutoIt3.h" include
//        Added "AutoItX3.lib" to the input linker libraries
//
// AutoItX3.dll needs to be in the run path during execution
 
#include <Windows.h>
#include "AutoIt3.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"
    AU3_Sleep(1000);
    AU3_Run(L"notepad.exe", "", 1);
    AU3_WinWaitActive(L"Untitled -", "", 0);
    AU3_Send(L"Hello{!}", 0);
 
    // Get the text in the status bar
    //char szText[1000];
    //AU3_StatusbarGetText("Untitled -", "", 2, szText, 1000);
    //MessageBox(NULL, szText, "Text:", MB_OK);
 
    return 0;
}

 

Jednak odnośnie błędów stricte związanych z tą biblioteką nie jestem w stanie nic powiedzieć.

Opublikowano

1>------ Build started: Project: test, Configuration: Debug Win32 ------
1> stdafx.cpp
1> main2.cpp
1>c:\documents and settings\szpadel\pulpit\test\test\main2.cpp(7): warning C4627: '#include <Windows.h>': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\documents and settings\szpadel\pulpit\test\test\main2.cpp(8): warning C4627: '#include "AutoIt3.h"': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\documents and settings\szpadel\pulpit\test\test\main2.cpp(9): error C2001: newline in constant
1>c:\documents and settings\szpadel\pulpit\test\test\main2.cpp(11): error C2146: syntax error : missing ';' before identifier 'WinMain'
1>c:\documents and settings\szpadel\pulpit\test\test\main2.cpp(12): warning C4007: 'WinMain' : must be '__stdcall'
1>c:\documents and settings\szpadel\pulpit\test\test\main2.cpp(12): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\szpadel\pulpit\test\test\main2.cpp(14): error C3861: 'AU3_Sleep': identifier not found
1>c:\documents and settings\szpadel\pulpit\test\test\main2.cpp(15): error C3861: 'AU3_Run': identifier not found
1>c:\documents and settings\szpadel\pulpit\test\test\main2.cpp(16): error C3861: 'AU3_WinWaitActive': identifier not found
1>c:\documents and settings\szpadel\pulpit\test\test\main2.cpp(17): error C3861: 'AU3_Send': identifier not found
1> main.cpp
1>c:\documents and settings\szpadel\pulpit\test\test\main.cpp(1): warning C4627: '#include <Windows.h>': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\documents and settings\szpadel\pulpit\test\test\main.cpp(2): warning C4627: '#include "AutoIt3.h"': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\documents and settings\szpadel\pulpit\test\test\main.cpp(5): error C2146: syntax error : missing ';' before identifier 'WinMain'
1>c:\documents and settings\szpadel\pulpit\test\test\main.cpp(5): error C2065: 'HINSTANCE' : undeclared identifier
1>c:\documents and settings\szpadel\pulpit\test\test\main.cpp(5): error C2146: syntax error : missing ')' before identifier 'hInstance'
1>c:\documents and settings\szpadel\pulpit\test\test\main.cpp(5): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\szpadel\pulpit\test\test\main.cpp(8): error C2059: syntax error : ')'
1>c:\documents and settings\szpadel\pulpit\test\test\main.cpp(9): error C2143: syntax error : missing ';' before '{'
1>c:\documents and settings\szpadel\pulpit\test\test\main.cpp(9): error C2447: '{' : missing function header (old-style formal list?)
1> Generating Code...
1> Skipping... (no relevant changes detected)
1> test.cpp
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...