Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


General Incorrect tcc Library Errors

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
xmydl
Newbie cheater
Reputation: 0

Joined: 28 Apr 2023
Posts: 12

PostPosted: Mon Feb 19, 2024 7:55 am    Post subject: General Incorrect tcc Library Errors Reply with quote

Hello, there. I'm trying to make a simple test script which sends a keyboard input (specifically "e" here) using $C. However I have encountered much kind of problems due to lack of related information and docs. By the way, I have already tried using LUA's built in doKeyPress function but it seems that VK inputs are not recognized at all. It funtions well outside the game.
Here goes my auto assembler script.

Code:
{$lua}
  if syntaxcheck then return end
  path = getAesopEngineDir()
  addCIncludePath(path .. 'include\\')
  addCIncludePath(path .. 'include\\winapi\\')
{$asm}
[ENABLE]
{$ccode}
    #include <windows.h>

    INPUT ip;
    ip.type = INPUT_KEYBOARD;
    ip.ki.time = 0;
    ip.ki.wVk = 0;
    ip.ki.dwExtraInfo = 0;

    ip.ki.wScan = 0x12;
    ip.ki.dwFlags = KEYEVENTF_SCANCODE;
    SendInput(1, &ip, sizeof(INPUT));

    ip.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
    SendInput(1, &ip, sizeof(INPUT));
{$asm}
[DISABLE]


Could you please help me check if there is any problem?
Last but not least, it seems that 7.5.1(I'm on patreon) can't correctly run auto assembler script with {$luacode} built in. Is it a bug or may be my environment goes wrong?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25298
Location: The netherlands

PostPosted: Mon Feb 19, 2024 8:20 am    Post subject: Reply with quote

getAesopEngineDir() is not going to work on any official CE version
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
xmydl
Newbie cheater
Reputation: 0

Joined: 28 Apr 2023
Posts: 12

PostPosted: Mon Feb 19, 2024 8:31 am    Post subject: Reply with quote

I'm Really Sorry for the mistake!

That's my self compiled cheat engine because 7.5.1 seems not to recognize my {$luacode} blocks in another test script. I tried to use previous version (7.4.1) and it seemed to work there. However the problem mentioned before (tcc library errors) is still not solved. Here is the code.

Code:
{$lua}
  if syntaxcheck then return end
  path = getCheatEngineDir()
  addCIncludePath(path .. 'include\\')
  addCIncludePath(path .. 'include\\winapi\\')
{$asm}
[ENABLE]
{$ccode}
    #include <windows.h>

    INPUT ip;
    ip.type = INPUT_KEYBOARD;
    ip.ki.time = 0;
    ip.ki.wVk = 0;
    ip.ki.dwExtraInfo = 0;

    ip.ki.wScan = 0x12;
    ip.ki.dwFlags = KEYEVENTF_SCANCODE;
    SendInput(1, &ip, sizeof(INPUT));

    ip.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
    SendInput(1, &ip, sizeof(INPUT));
{$asm}
[DISABLE]


May I sincerely ask for a helping hand?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25298
Location: The netherlands

PostPosted: Mon Feb 19, 2024 8:58 am    Post subject: Reply with quote

i don't recommend using windows.h just declare the functions and structs and defines yourself

but what errors and warnings do you get?

and how about 7.5.2 ?

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
xmydl
Newbie cheater
Reputation: 0

Joined: 28 Apr 2023
Posts: 12

PostPosted: Mon Feb 19, 2024 10:26 am    Post subject: Reply with quote

Huge Thanks, DarkByte!!
After encoounting more problems, I edit the code as this. tcc can't deal with _stricmp and _strnicmp so I manually added them. Here's the final result. Somehow it runs but can't actually function. (I set a hot key to enable it and see the result, even outside the game it cannot function)

Code:
{$lua}
  if syntaxcheck then return end
  path = getCheatEngineDir()
  addCIncludePath(path .. 'include\\')
{$asm}
[ENABLE]
{$c}
#include <stdint.h>
#include <string.h>
#include <windows.h>

int _stricmp(const char *s1, const char *s2) {
    while (*s1 && *s2) {
        if (tolower(*s1) != tolower(*s2))
            return (tolower(*s1) - tolower(*s2));
        s1++;
        s2++;
    }
    return 0;
}

int _strnicmp(const char *s1, const char *s2, size_t n) {
    while (n && *s1 && *s2) {
        if (tolower(*s1) != tolower(*s2))
            return (tolower(*s1) - tolower(*s2));
        s1++;
        s2++;
        n--;
    }
    return 0;
}

int main() {
    INPUT ip;
    ip.type = INPUT_KEYBOARD;
    ip.ki.time = 0;
    ip.ki.wVk = 0;
    ip.ki.dwFlags = 0;
    ip.ki.dwExtraInfo = 0;

    ip.ki.wScan = 0x12;
    ip.ki.dwFlags = KEYEVENTF_SCANCODE;

    SendInput(1, &ip, sizeof(INPUT));

    ip.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
    SendInput(1, &ip, sizeof(INPUT));
}
{$asm}
[DISABLE]


What I prefer is using {$ccode} so it could be implemented into the actual code. And run every time in the code block. However {$ccode} seemed not to be able to include windows.h but I have to typedef them manually.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25298
Location: The netherlands

PostPosted: Mon Feb 19, 2024 3:00 pm    Post subject: Reply with quote

if you add
Code:

#define NO_OLDNAMES

you can ignore the _stricmp and _strnicmp which are used by string.h

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites