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 


Automatic pressing of the Space key

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
LAGARIUM1
How do I cheat?
Reputation: 0

Joined: 08 Jul 2022
Posts: 8

PostPosted: Fri Jul 08, 2022 12:48 pm    Post subject: Automatic pressing of the Space key Reply with quote

How do I make a LUA script simulate pressing the Space key?, I need when I press the Shift key once and unpress the Shift and that the Space key was pressed once and then unpressed.
Back to top
View user's profile Send private message
LAGARIUM1
How do I cheat?
Reputation: 0

Joined: 08 Jul 2022
Posts: 8

PostPosted: Fri Jul 08, 2022 1:25 pm    Post subject: Reply with quote

And how correctly to insert this script into my script?

Code:

[ENABLE]
{$LUA}
function SpeedHack1()
boost = 2.4

if (readBytes('[_Speed1]') ~= nil) then
writeFloat ('[_Speed1]',readFloat('[_Speed1]')*boost)
writeFloat ('[_Speed1]+4',readFloat('[_Speed1]+4')*boost)

end
end
hk1 = createHotkey(SpeedHack1,VK_W, VK_SHIFT)



{$ASM}
[DISABLE]
{$LUA}
hk1.destroy()
{$ASM}
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 32

Joined: 16 Feb 2017
Posts: 1249

PostPosted: Fri Jul 08, 2022 2:05 pm    Post subject: Reply with quote

Maybe I misunderstood.

Your wish; simulate a keypress?

Ignore the first code I posted and let's expand a bit more:

keypress;
Code:
keyDown(VK_SPACE)
keyUp(VK_SPACE)



Code:
[ENABLE]
{$LUA}
function SpeedHack1()
boost = 2.4

if (readBytes('[_Speed1]') ~= nil) then
writeFloat ('[_Speed1]',readFloat('[_Speed1]')*boost)
writeFloat ('[_Speed1]+4',readFloat('[_Speed1]+4')*boost)
--keyDown(VK_SPACE)
--keyUp(VK_SPACE)
end
end
hk1 = createHotkey(SpeedHack1,VK_W, VK_SHIFT)



{$ASM}
[DISABLE]
{$LUA}
hk1.destroy()

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
LAGARIUM1
How do I cheat?
Reputation: 0

Joined: 08 Jul 2022
Posts: 8

PostPosted: Fri Jul 08, 2022 2:22 pm    Post subject: Reply with quote

[quote="AylinCE"]Maybe I misunderstood.

Your wish; simulate a keypress?


yes, I need to simulate auto pressing SPACE after when the Shift key is released, for example, I accelerate the car on Shift and after pressing Shift, I need to press Space automatically.
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 32

Joined: 16 Feb 2017
Posts: 1249

PostPosted: Fri Jul 08, 2022 3:19 pm    Post subject: Reply with quote

Maybe something like this.

Code:
[ENABLE]
{$LUA}

--if syntaxcheck then return end

if upTim1 then upTim1.Destroy() upTim1=nil end
upTim1=createTimer() upTim1.Interval=10 upTim1.Enabled=false

if upTim2 then upTim2.Destroy() upTim2=nil end
upTim2=createTimer() upTim2.Interval=10 upTim2.Enabled=false

function SpeedHack1()
boost = 2.4

if (readBytes('[_Speed1]') ~= nil) then
writeFloat ('[_Speed1]',readFloat('[_Speed1]')*boost)
writeFloat ('[_Speed1]+4',readFloat('[_Speed1]+4')*boost)

--shift pres check start
upTim1.Enabled=true

end
end
hk1 = createHotkey(SpeedHack1,VK_W, VK_SHIFT)


upTim1.onTimer=function()
 if isKeyPressed(VK_SHIFT) then upTim2.Enabled=true
  --print(1)
  upTim1.Enabled=false
 end
end


upTim2.onTimer=function()
 if not isKeyPressed(VK_SHIFT) then
  keyDown(VK_SPACE)
  keyUp(VK_SPACE)
  --print(2)
  upTim2.Enabled=false
 end
end

{$ASM}

[DISABLE]

{$LUA}
hk1.destroy()
upTim1.Destroy()
upTim2.Destroy()

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past


Last edited by AylinCE on Sat Jul 09, 2022 11:33 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
LAGARIUM1
How do I cheat?
Reputation: 0

Joined: 08 Jul 2022
Posts: 8

PostPosted: Sat Jul 09, 2022 12:03 am    Post subject: Reply with quote

[quote="AylinCE"]Maybe something like this.

I have an error when I add the script if I ignore the error, then the script works equally, but I would like to understand why the error
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Sat Jul 09, 2022 12:20 am    Post subject: Reply with quote

there is no `if syntaxcheck then return end` in the disable part. That's why it errors
_________________
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
LAGARIUM1
How do I cheat?
Reputation: 0

Joined: 08 Jul 2022
Posts: 8

PostPosted: Thu Jul 14, 2022 5:04 am    Post subject: Reply with quote

[quote="AylinCE"]Maybe something like this.

How do I add the Shift button to my script so that when I press the Shift button, the player will speed up?

this script works, but crookedly, and after turning off the script the game goes away
Code:

[ENABLE]

aobscanmodule(SpeedHack9,GTA5.exe,F3 44 0F 58 61 70) // should be unique
alloc(newmem,$1000,SpeedHack9)

label(code)
label(return)
label(Multiplier)
label(Multiplier1)
label(skip)

registersymbol(SpeedHack9)
registersymbol(Multiplier)
registersymbol(Multiplier1)

newmem:

push rax
push rbx
push rdx
push rsi
push rdi
push rbp
push r8
push r9
push r10
push r11
push r12
push r13
push r14
push r15
push rcx

 xor r10,r10
 push rcx
mov r11,1
mov rcx,'W'
call GetAsyncKeyState

  mov r11,10
  mov rcx,10
  call GetAsyncKeyState
add rsp,08
test ax,8000

pop rcx
test r10,r10
jz skip

cmp rcx+D4],(float)60
 jne @f

addss xmm12,[rcx+70]
fld dword [rcx+70]
  fmul dword [Multiplier]
  fstp dword [rcx+70]
@@:

cmp rcx+D4],(float)60
 jne @f
addss xmm13,[rcx+74]
fld dword [rcx+74]
  fmul dword [Multiplier1]
  fstp dword [rcx+74]

@@:
code:
addss xmm12,[rcx+70]

  jmp return
  Multiplier:
dd (float)1.1
 Multiplier1:
dd (float)1.1


SpeedHack9:
  jmp newmem
  nop
return:
skip:
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rbp
pop rdi
pop rsi
pop rdx
pop rbx
pop rax

[DISABLE]

SpeedHack9:
db F3 44 0F 58 61 70

unregistersymbol(SpeedHack9)
unregistersymbol(Multplier)
unregistersymbol(Multplier1)

dealloc(newmem
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 32

Joined: 16 Feb 2017
Posts: 1249

PostPosted: Fri Jul 15, 2022 1:07 pm    Post subject: Reply with quote

I have an idea for this but I have to be at my pc to test it. This may be possible tomorrow.

The following method comes to mind:
use 2 scripts. write your script to the first one. Write the shortcut code in the second script and put the command that will activate the first script in the shortcut function.

Code:
local al = getAddressList()
keyScript = al.getMemoryRecordByDescription('SpeedHack script name')
keyScript.Active = true


----------------------------------------------

EDIT :

You should test the code.
Copy and paste into the address list.
Activate the Key-Start script and use the hotkey. If all goes well, your "speedHack9" script will be active and deactivated if you want.

Note: I am not using ASM commands or scripts. I'm not familiar with that subject.
For more ASM topics go here:
https://forum.cheatengine.org/viewforum.php?f=15

For more LUA topics here:
https://forum.cheatengine.org/viewforum.php?f=126

And here is the archive you may find useful:
https://forum.cheatengine.org/search.php

See, join. Wink

-----------------------------------------------
Code:
<?xml version="1.0" encoding="utf-8"?>
<CheatTable>
  <CheatEntries>
    <CheatEntry>
      <ID>0</ID>
      <Description>"speedHack (Key-Start)"</Description>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>[ENABLE]
{$LUA}

--if syntaxcheck then return end

if upTim1 then upTim1.Destroy() upTim1=nil end
upTim1=createTimer() upTim1.Interval=10 upTim1.Enabled=false

if upTim2 then upTim2.Destroy() upTim2=nil end
upTim2=createTimer() upTim2.Interval=10 upTim2.Enabled=false

function SpeedHack1()
--boost = 2.4

--if (readBytes('[_Speed1]') ~= nil) then
--writeFloat ('[_Speed1]',readFloat('[_Speed1]')*boost)
--writeFloat ('[_Speed1]+4',readFloat('[_Speed1]+4')*boost)
local al = getAddressList()
keyScript = al.getMemoryRecordByDescription("SpeedHack9")
keyScript.Active = true
--shift pres check start
upTim1.Enabled=true
end

hk1 = createHotkey(SpeedHack1,VK_W, VK_SHIFT)


upTim1.onTimer=function()
 if isKeyPressed(VK_SHIFT) then upTim2.Enabled=true
  --print(1)
  upTim1.Enabled=false
 end
end


upTim2.onTimer=function()
 if not isKeyPressed(VK_SHIFT) then
  keyDown(VK_SPACE)
  keyUp(VK_SPACE)
  --print(2)
  -- speedHack9 de active?
  --local al = getAddressList()
  --keyScript = al.getMemoryRecordByDescription("SpeedHack9")
  --keyScript.Active = false
  upTim2.Enabled=false
 end
end

{$ASM}

[DISABLE]

{$LUA}
hk1.destroy()
upTim1.Destroy()
upTim2.Destroy()
</AssemblerScript>
    </CheatEntry>
    <CheatEntry>
      <ID>1</ID>
      <Description>"SpeedHack9"</Description>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>[ENABLE]

aobscanmodule(SpeedHack9,GTA5.exe,F3 44 0F 58 61 70) // should be unique
alloc(newmem,$1000,SpeedHack9)

label(code)
label(return)
label(Multiplier)
label(Multiplier1)
label(skip)

registersymbol(SpeedHack9)
registersymbol(Multiplier)
registersymbol(Multiplier1)

newmem:

push rax
push rbx
push rdx
push rsi
push rdi
push rbp
push r8
push r9
push r10
push r11
push r12
push r13
push r14
push r15
push rcx

 xor r10,r10
 push rcx
mov r11,1
mov rcx,'W'
call GetAsyncKeyState

  mov r11,10
  mov rcx,10
  call GetAsyncKeyState
add rsp,08
test ax,8000

pop rcx
test r10,r10
jz skip

cmp rcx+D4],(float)60
 jne @f

addss xmm12,[rcx+70]
fld dword [rcx+70]
  fmul dword [Multiplier]
  fstp dword [rcx+70]
@@:

cmp rcx+D4],(float)60
 jne @f
addss xmm13,[rcx+74]
fld dword [rcx+74]
  fmul dword [Multiplier1]
  fstp dword [rcx+74]

@@:
code:
addss xmm12,[rcx+70]

  jmp return
  Multiplier:
dd (float)1.1
 Multiplier1:
dd (float)1.1


SpeedHack9:
  jmp newmem
  nop
return:
skip:
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rbp
pop rdi
pop rsi
pop rdx
pop rbx
pop rax

[DISABLE]

SpeedHack9:
db F3 44 0F 58 61 70

unregistersymbol(SpeedHack9)
unregistersymbol(Multplier)
unregistersymbol(Multplier1)

dealloc(newmem)
</AssemblerScript>
    </CheatEntry>
  </CheatEntries>
</CheatTable>

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
LAGARIUM1
How do I cheat?
Reputation: 0

Joined: 08 Jul 2022
Posts: 8

PostPosted: Sat Jul 16, 2022 10:02 am    Post subject: Reply with quote

[quote="AylinCE"]I have an idea for this but I have to be at my pc to test it. This may be possible tomorrow.

seems to work

If you're wondering how it works for me, search YouTube for gta-5 velocity SpeedHac
Back to top
View user's profile Send private message
sbryzl
Master Cheater
Reputation: 6

Joined: 25 Jul 2016
Posts: 252

PostPosted: Sat Jul 16, 2022 10:20 am    Post subject: Reply with quote

Haven't tried the code sample but typically all the registers are popped before returning from code cave instead of after. Doing it after probably overwrites important game code likely leading to crashes.
Back to top
View user's profile Send private message
LAGARIUM1
How do I cheat?
Reputation: 0

Joined: 08 Jul 2022
Posts: 8

PostPosted: Tue Aug 02, 2022 12:01 am    Post subject: Reply with quote

[quote="AylinCE"]Maybe something like this.

Can you somehow limit the value so that it does not increase if the value is for example 2 then so that it does not increase further and only the value remains 2?
Code:

[ENABLE]
{$LUA}
function SpeedHack1()
boost = 0

if (readBytes('[Speed1]') ~= nil) then
writeFloat ('[Speed1]+230',readFloat('[Speed1]+230')*boost)
writeFloat ('[Speed1]+238',readFloat('[Speed1]+238')*boost)

end
end
hk1 = createHotkey(SpeedHack1,VK_SPACE)

function SpeedHack1()
boost = 2.5
if (readBytes('[Speed1]') ~= nil) then
writeFloat ('[Speed1]+230',readFloat('[Speed1]+230')*boost)
writeFloat ('[Speed1]+238',readFloat('[Speed1]+238')*boost)
end
end
hk2 = createHotkey(SpeedHack1,VK_W, VK_SHIFT)

{$ASM}
[DISABLE]
{$LUA}
hk1.destroy()
hk2.destroy()
{$ASM}
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1055
Location: 0x90

PostPosted: Tue Aug 02, 2022 5:55 am    Post subject: Reply with quote

You just need if..then logic:
Code:

[ENABLE]
{$LUA}
function SpeedHack1()
  boost = 0

  if (readBytes('[Speed1]') ~= nil) then
    --// Read current speed value, if it is 2 or more then exit function
    local current_speed = readFloat('[Speed1]+230')
    if current_speed >= 2 then return end
 
    writeFloat ('[Speed1]+230',readFloat('[Speed1]+230')*boost)
    writeFloat ('[Speed1]+238',readFloat('[Speed1]+238')*boost)
  end
end
hk1 = createHotkey(SpeedHack1,VK_SPACE)

// Duplicate function below

function SpeedHack1()
boost = 2.5
if (readBytes('[Speed1]') ~= nil) then
writeFloat ('[Speed1]+230',readFloat('[Speed1]+230')*boost)
writeFloat ('[Speed1]+238',readFloat('[Speed1]+238')*boost)
end
end
hk2 = createHotkey(SpeedHack1,VK_W, VK_SHIFT)

{$ASM}
[DISABLE]
{$LUA}
hk1.destroy()
hk2.destroy()
Back to top
View user's profile Send private message
LAGARIUM1
How do I cheat?
Reputation: 0

Joined: 08 Jul 2022
Posts: 8

PostPosted: Tue Aug 02, 2022 7:14 am    Post subject: Reply with quote

[quote="LeFiXER"]You just need if..then logic:

No it does not work the way I need, I need when I press the Shift key the car accelerated by 2 values and so drove on holding down the Shift key and did not drive harder.
Back to top
View user's profile Send private message
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