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 


Hitler please don't ignore

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

Joined: 05 Nov 2017
Posts: 39
Location: Behind the keyboard

PostPosted: Sun Dec 01, 2019 2:02 am    Post subject: Hitler please don't ignore Reply with quote

I've made a lua script that constantly checks for health and if it is lower than max then it will send a keypress for medicine to use in this case 'Q'
Script is just fine I've tested in lua engine it presses Q automatically when health is low but this doesn't work in game
mouse events work fine but not the vk_codes
What is the problem??
Does anybody else has or had this problem???

EDIT
HERE'S THE SCRIPT
Code:

{$lua}
[ENABLE]
if syntaxcheck then return end

AutoHealth_thread = createNativeThread(function (thread)
  thread.freeOnTerminate(false)
  thread.Name = 'AutoHealth_thread'
  local health
  while not thread.Terminated do
        writeInteger('[[[[[[[[[["ACU.exe"+05221638]+64]+00]+78]+100]+00]+A8]+08]+28]+88]+28', 5)
        local health = readInteger('[[[[[[[[[["ACU.exe"+0508B548]+18]+28]+48]+188]+00]+10]+148]+10]+68]+10')
        if health < 70 then
           keyDown('Q')
           sleep(10)
           keyUp('Q')
        end
  end
end)

[DISABLE]
if AutoHealth_thread then
   AutoHealth_thread.terminate()
   AutoHealth_thread.waitfor()
   AutoHealth_thread.destroy()
   AutoHealth_thread=nil
end

_________________
TH3 UND3N14BL3


Last edited by SEKTION on Mon Dec 02, 2019 8:57 am; edited 1 time in total
Back to top
View user's profile Send private message
Dieguardian
How do I cheat?
Reputation: 0

Joined: 30 Nov 2019
Posts: 4

PostPosted: Mon Dec 02, 2019 7:51 am    Post subject: Reply with quote

Huh?
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Mon Dec 02, 2019 8:39 am    Post subject: Re: Corroder please don't ignore Reply with quote

S3KT10N wrote:
I've made a lua script......
Does anybody else has or had this problem???


Post your script here, so peoples able to help you.

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Mon Dec 02, 2019 11:59 am    Post subject: Reply with quote

Use keybd_event function

Code:

function keybd_event(VK)
   assert(type(VK)=='number', 'invalid key');
   return ExecuteCodeLocalEx('keybd_event',VK,0,0,0) and ExecuteCodeLocalEx('keybd_event',VK,0,2,0);
end

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919


Last edited by DaSpamer on Tue Dec 03, 2019 9:15 am; edited 1 time in total
Back to top
View user's profile Send private message
SEKTION
Cheater
Reputation: 0

Joined: 05 Nov 2017
Posts: 39
Location: Behind the keyboard

PostPosted: Tue Dec 03, 2019 2:32 am    Post subject: Reply with quote

DaSpamer wrote:
Use keybd_event function

Code:

function keybd_event(VK)
   assert(type(VK)=='number', 'invalid key');
   return ExecuteCodeLocalEx('keybd_event',VK,0,0,0)) and ExecuteCodeLocalEx('keybd_event',VK,0,2,0);
end


so should I use it as is and call the function with key value cuz thats what i did at first and script won't compile saying it expects an end somewhere (also do we need ; in lua??)

then i altered it and somehow got it to compile but cheat engine freezes

and then i read somewhere that for keybd_event you have to define keys manually so i did and call it with keybd_event, script does compile but gives error on activating saying 'attempt to call global nil value'

_________________
TH3 UND3N14BL3
Back to top
View user's profile Send private message
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Tue Dec 03, 2019 9:14 am    Post subject: Reply with quote

Sorry had a typo
Code:

function keybd_event(VK)
   assert(type(VK)=='number', 'invalid key');
   return ExecuteCodeLocalEx('keybd_event',VK,0,0,0) and ExecuteCodeLocalEx('keybd_event',VK,0,2,0);
end

put this outside your native thread function (after syntaxcheck..)

and call it like
Code:

keybd_event(VK_LWIN) -- Left Window button... opens start menu in windows


And for you case replace
Code:

           keyDown('Q')
           sleep(10)
           keyUp('Q')

with
Code:

           keybd_event(VK_Q)

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
SEKTION
Cheater
Reputation: 0

Joined: 05 Nov 2017
Posts: 39
Location: Behind the keyboard

PostPosted: Tue Dec 03, 2019 1:35 pm    Post subject: Reply with quote

Thanks
it compiles and activates successfully but it has the same effect as mine
It automates Q keypress outside the game with no problem but not in the game Crying or Very sad

_________________
TH3 UND3N14BL3
Back to top
View user's profile Send private message
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Tue Dec 03, 2019 3:16 pm    Post subject: Reply with quote

Perhaps take a look at SendInput
_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
SEKTION
Cheater
Reputation: 0

Joined: 05 Nov 2017
Posts: 39
Location: Behind the keyboard

PostPosted: Wed Dec 04, 2019 11:45 am    Post subject: Reply with quote

Very thanks for your time Very Happy

Code:

local hWndNotepad = findWindow('Notepad');
local hWndChild = getWindow(hWndNotepad, 5); -- Get the child edit control..

sendMessage(hWndChild, 0x0100, 0x48, 0); -- Send WM_KEYDOWN
sendMessage(hWndChild, 0x0101, 0x48, 0); -- Send WM_KEYUP
sendMessage(hWndChild, 0x0102, 0x48, 0); -- Send WM_CHAR


I found this in other thread when looking for sendInput but can't find anything useful related to sendInput
I tried this but this also doesn't work Sad
If anybody aware of some other method which is not blocked by game or know about a tut of sendInput in lua,would you be so kind to point me to it?
many thanks!!!

_________________
TH3 UND3N14BL3
Back to top
View user's profile Send private message
Lee_Cia_ik
How do I cheat?
Reputation: 0

Joined: 03 Nov 2008
Posts: 1

PostPosted: Thu Dec 05, 2019 2:55 am    Post subject: Reply with quote

Question why there is my id called on the topic. and every signature. Question
Back to top
View user's profile Send private message Yahoo Messenger
atom0s
Moderator
Reputation: 199

Joined: 25 Jan 2006
Posts: 8518
Location: 127.0.0.1

PostPosted: Thu Dec 05, 2019 4:40 am    Post subject: Reply with quote

Lee_Cia_ik wrote:
Question why there is my id called on the topic. and every signature. Question


https://forum.cheatengine.org/viewtopic.php?t=473706

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
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