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 


{$luacode} ???

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
vovasivy
Cheater
Reputation: 0

Joined: 09 Jun 2021
Posts: 43

PostPosted: Tue Nov 16, 2021 12:34 am    Post subject: {$luacode} ??? Reply with quote

Why the "doKeyPress(0x1B)" function does not work.
Function "sleep()" and "print()" work.

How to make it work.
I will be grateful for your help.
Code:
define(address,"witcher3.exe"+150ECEA)
define(bytes,42 8B 0C 08 8B 07)

[ENABLE]

assert(address,bytes)
alloc(newmem,$1000,"witcher3.exe"+150ECEA)

label(code)
label(return)
label(flag_menu)

registersymbol(flag_menu)

newmem:

  cmp [flag_menu],0
  je code
  mov [flag_menu],0

{$luacode}
  doKeyPress(0x1B)    -- The "Esc" key does not turn on.
  --print("Hello")    -- It works.
{$asm}

{$luacode}
  sleep(10000)    -- It works.
{$asm}

{
  cmp r15w,00D8
  jne code
  mov [rax+r9],#3
}

code:
  mov ecx,[rax+r9]
  mov eax,[rdi]
  jmp return
  align 4,CC

flag_menu:
  dd 00

address:
  jmp newmem
  nop
return:

[DISABLE]

address:
  db bytes
  // mov ecx,[rax+r9]
  // mov eax,[rdi]
unregistersymbol(flag_menu)
dealloc(newmem)


The second question.
Are the lower 8 bits in 64 bit registers not supported?
Code:
  cmp r15w,00D8
  jne code

Works!!!
Code:
  cmp r15b,D8
  jne code

Returns an error!!!
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Tue Nov 16, 2021 3:39 am    Post subject: Reply with quote

It depends on where you do your code hooking

doKeyPress does the following:
Press down
sleep(110)
Release key

If your code is inside the main game thread, and the game only check if the key is currently down instead of have been pressed (e.g it only checks the least significant bit) then when it checks if the key is down it won't see it, as it's up already

You can try keyDown(0x1b) and the next time the code is executed release the key


it's
Code:

cmp r15l,D8

_________________
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
vovasivy
Cheater
Reputation: 0

Joined: 09 Jun 2021
Posts: 43

PostPosted: Tue Nov 16, 2021 5:54 am    Post subject: Reply with quote

Thanks!
Code:

  cmp r15l,D8    - Works


Unfortunately keyDown, keyUp
Code:
 {$luacode}
      keyDown(0x1B)
      sleep(110)
      keyUp(0x1B)
  {$asm}

It doesn't work!!![/code]
Code:

define(address,"witcher3.exe"+150ECEA)
define(bytes,42 8B 0C 08 8B 07)

[ENABLE]

assert(address,bytes)
alloc(newmem,$1000,"witcher3.exe"+150ECEA)

label(code)
label(return)
label(flag_menu)

registersymbol(flag_menu)

newmem:
  cmp [flag_menu],0
  je code
  mov [flag_menu],0

{$luacode}
  keyDown(0x1B)
  sleep(110)
  keyUp(0x1B)
{$asm}

  cmp r15l,D8
  jne code
  mov [rax+r9],#3
code:
  mov ecx,[rax+r9]
  mov eax,[rdi]
  jmp return
  align 4,CC

flag_menu:
  dd 00

address:
  jmp newmem
  nop
return:

[DISABLE]

address:
  db bytes
  // mov ecx,[rax+r9]
  // mov eax,[rdi]
unregistersymbol(flag_menu)
dealloc(newmem)


I will explain the task:
I need to go to the menu (using the "Esc" key) while in full-screen 3D game mode.
Then move through the menu tree to a certain setting parameter, switch it, and back by pressing the "Esc" key to return to the game.

I made a simple script and it works
Code:

[ENABLE]
{$Lua}
doKeyPress(0x1B)
sleep(200)
doKeyPress(VK_S)
sleep(50)
doKeyPress(VK_S)
sleep(50)
doKeyPress(VK_S)
sleep(50)
doKeyPress(0x0D)
sleep(200)
doKeyPress(VK_S)
sleep(50)
doKeyPress(VK_S)
sleep(50)
doKeyPress(VK_S)
sleep(50)
doKeyPress(VK_S)
sleep(50)
doKeyPress(VK_S)
sleep(50)
doKeyPress(VK_S)
sleep(50)
doKeyPress(0x0D)
sleep(200)
doKeyPress(0x0D)
sleep(300)
doKeyPress(VK_S)
sleep(50)
doKeyPress(0x0D)
sleep(100)
doKeyPress(0x0D)
sleep(100)
doKeyPress(0x1B)
sleep(100)
doKeyPress(0x1B)
sleep(100)
doKeyPress(0x1B)
sleep(100)
doKeyPress(0x1B)
sleep(100)
doKeyPress(0x1B)
{$Asm}

[DISABLE]

And such automation would probably be enough for me.
However, even with a small, random push during the execution of the script, the cursor position changes
and I get to another menu item.
So I found an instruction that sets the cursor to a specific menu item, and then I got stuck.
Maybe someone will help.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Tue Nov 16, 2021 6:08 am    Post subject: Reply with quote

of course it doesn't work. As I said, the key is up at the time the game is checking if the key is down.

You need to keep the key down until the game has checked it, and once it has been processed, you can move the key up

But if you don't want key perfect precision then use a thread
Code:

{$luacode}
createThread(function()
  doKeyPress(0x1B)
end)
{$asm}


_________________
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 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