|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
++METHOS I post too much Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Fri Feb 11, 2022 5:45 pm Post subject: Sending Key Press |
|
|
I have this code:
Code: | newmem_auto_block:
cmp byte ptr [rcx+08],#24
jg block
jmp originalcode_auto_block
block:
{$lua}
doKeyPress(69)
doKeyPress(22531)
{$asm}
jmp originalcode_auto_block |
It does not seem to be working. Do I need to do something else for this to work?
If it turns out that repeating the KeyPress is needed, how would I go about doing that? Just copy/paste it multiple times?
Thanks.
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 34
Joined: 16 Feb 2017 Posts: 1418
|
Posted: Fri Feb 11, 2022 6:18 pm Post subject: |
|
|
Instead of imagining pressing the key,
It is better to give the keypress.
Of course, you specify the pressure removal interval.
Code: | keyDown(69)
keyDown(22531)
sleep(50)
keyUp(69)
keyUp (22531) |
_________________
|
|
Back to top |
|
|
++METHOS I post too much Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Fri Feb 11, 2022 6:33 pm Post subject: |
|
|
Thank you for your help, AylinCE. I really appreciate it.
It seems that the keys are still not getting sent. I am not sure why.
EDIT: I can see that the keys are being sent when I execute the script, but I need them to execute inside of my assembly script once the proper conditions are met after the compare. They keys are not getting pressed once the code jumps to this area in the game.
Thanks.
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 147
Joined: 06 Jul 2014 Posts: 4518
|
Posted: Fri Feb 11, 2022 6:53 pm Post subject: |
|
|
{$lua} blocks are executed when the script is enabled/disabled. They won't run at runtime (e.g. inside injected code).
{$luacode} is probably what you're looking for.
https://forum.cheatengine.org/viewtopic.php?t=618134
If it slows down your game (definitely shouldn't call sleep), doing it asynchronously might help:
Code: | {$luacode}
createTimer(1, function()
doKeyPress(...)
end)
{$asm} |
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
++METHOS I post too much Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Fri Feb 11, 2022 7:19 pm Post subject: |
|
|
Thank you, ParkourPenguin. I really appreciate your help with this.
What you are saying makes a lot of sense based on what I am experiencing.
I tried using luacode, but the keys still do not seem to be getting sent to the target process.
I even tried incorporating both, doKeyPress and keyDown methods, and also even tried removing the timer. Nothing seems to be working.
Thanks.
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 147
Joined: 06 Jul 2014 Posts: 4518
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 465
Joined: 09 May 2003 Posts: 25509 Location: The netherlands
|
Posted: Sat Feb 12, 2022 6:29 am Post subject: |
|
|
keypress only works on the foreground process
what you can try first before you code too much is to use a timer that presses the keys every 5 seconds
then swap to the game and see if the keys get handled
if not, then it's using a special kind of keyhandling and you have to find out another way to make the game see the keys
_________________
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 |
|
|
++METHOS I post too much Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Sat Feb 12, 2022 8:40 am Post subject: |
|
|
Thank you, guys. I really appreciate your help with this.
@ParkourPenguin - The most recent script that you provided is still not passing keys to the target process. I cannot even begin to guess why, since I do not understand 95% of it.
@DB - My understanding of lua is very basic, but when experimenting yesterday, I was able to get the script to pass keys to the target process by incorporating a timer, but it just kept going and going, and I could not stop it. Unfortunately, based on what you guys have told me, I suspect that the keys are just getting sent, regardless of what is happening with the assembly in my script, so rendering it all useless anyway.
I am really surprised that a simple solution does not seem to exist for this.
Thanks.
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 465
Joined: 09 May 2003 Posts: 25509 Location: The netherlands
|
Posted: Sat Feb 12, 2022 9:11 am Post subject: |
|
|
If keypress works then it's simple
your luacode is likely in the same thread that handles keypresses, but doKeyPress releases the key before it continues, so when your luacode returns the keys are up, so the game doesn't see it
use keyDown and keyUp
Code: |
{$luacode}
if shouldpresskey then
keyDown(69)
keyDown(22531)
else
keyUp(22531)
keyUp(69)
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 |
|
|
++METHOS I post too much Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Sat Feb 12, 2022 11:06 am Post subject: |
|
|
Thanks, DB.
Your script is working, sometimes. It is really bizarre.
Similar to the other scripts, the game is slowing down when the luacode is supposed to be executing, so I know that something is happening, which is good. The problem is, it does not always do that for some reason, as if the luacode is not executing. Nothing ever happens when the game does not slow down.
The game does not slow down when using ParkourPenguin's timer createTimer(1, function(), but nothing ever happens when using that. I have tried many different things, but nothing works.
The only time that the game will actually execute the script properly, and function as intended, is if I remove focus from the target, and then move back to the target to put it in focus. But it only works the first time. After that, nothing...unless I remove focus from the target and bring it back into focus again.
The target always slows to a crawl when the code functions properly. It has never happened at full speed.
Also, the only key that seems to work is (69), which is keyboard input for 'E'. The other key (22531) is for controller triangle button...and I have never gotten it to work, no matter what I do. I have changed the game controller settings from keyboard only, controller only and the swap between controller and keyboard option.
I do not think that this is going to work. I understand if you guys do not want to bother more with it. I appreciate all of your help, regardless.
Thanks.
EDIT: I wanted to give ParkourPenguin's most recent script another chance, since I did not test it out enough. It seems to work as intended, but similar to above, it only seems to work when I change focus from the target and bring it back. Similarly, only the keyboard key (69) works, and it only works once. It does not slow the game down, though.
EDIT2: Since I could not get this to work the easy way, I just went ahead and used assembly for everything and made my injections where the game code sends those inputs. It is not ideal, and I would prefer an easier, universal approach, so if anyone else decides to respond to this thread, I will be glad to try something else.
Thanks.
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 34
Joined: 16 Feb 2017 Posts: 1418
|
|
Back to top |
|
|
++METHOS I post too much Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Wed Feb 16, 2022 6:34 pm Post subject: |
|
|
Thanks, AylinCE. It is good to try to expand on this, so I appreciate your help with it.
AylinCE wrote: |
1) Are you sure you are using the correct number for keypress? (22531) | -The code was derived from the CE table. I simply set up a hotkey using the controller button that I wanted, saved the CE table, and opened it in notepad++ to see what CE used. That being said, I think that this is not the real issue, since I know that the keyboard key was correct, and it was not working correctly anyway.
-I will take a look at this and try something when I have more time. Thanks. Looking at this code, however, it seems that it may not be applicable to my situation. As previously pointed out, any lua code would not be executed when I needed it to be unless we use a different approach, since I need the lua code to only run at a specific time, when the assembly code gets executed after the parameters are met.
AylinCE wrote: |
3) It is useful to have a look at this list; | -Thanks. If we are able to get a script working properly, then I will look at this more.
I will update this thread once I have had a chance to take another look.
Thanks, again.
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 34
Joined: 16 Feb 2017 Posts: 1418
|
Posted: Wed Feb 16, 2022 7:29 pm Post subject: |
|
|
It's good to see that the topic isn't bogged down.
I hope you have more options for solution.
Note: Do not turn now for the answer. If there is a solution, you will reply when you update it. I don't want to bother you unnecessarily.
Regards, master.
_________________
|
|
Back to top |
|
|
panraven Grandmaster Cheater Reputation: 57
Joined: 01 Oct 2008 Posts: 953
|
|
Back to top |
|
|
++METHOS I post too much Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Thu Feb 17, 2022 3:07 pm Post subject: |
|
|
-Hello, again. I took another look at this and here is what I determined based on the suggested options that are referenced in that post:
1. The first option is what I ended up going with. I am using the game's code in order to do what I need to do within assembly. I was hoping to avoid this approach because I was looking for something more universal that can be quickly implemented for future targets. The good thing about this approach is that it will work, even when the target is not in focus, but it requires more effort and time and may be unique for all targets.
2. Could not get the second option to work. Even trying to isolate the code so that it only executes at a given time was not working for some reason.
3. The third option requires a 3rd-party application, and would be inconvenient for users.
Thanks so much for your help!
-Unfortunately, I already looked through this site and many others, and I am unable to get the controller inputs to be recognized, no matter which virtual keys I use.
AylinCE wrote: | I hope your options improve further. | -Thanks! I appreciate your help, as always.
-This indeed works. You are too clever, my friend. Thank you so much for sharing this.
Now, the only problem that I have is being unable to get the controller inputs to be recognized. The keyboard input works great, but I get nothing from the controller. I have tried so many different virtual keys, but nothing is working. Fortunately, not many users may elect to change their settings so that keyboard inputs are ignored. This game has that option, however, so it would be good to try to determine what the issue is.
CE is able to recognize the input (22531) which is for Xbox controller button Y (Triangle button for Playstation), but the game does not, for some reason. The 22531 is in decimal format, presumably, but both, decimal and hex versions do not work. I have tried a number of different label-type versions and VK_ versions as well. Not sure what it needs to be.
I will +rep when I am able. I will not forget.
Thank you, everyone, for your help with this. I really appreciate it.
|
|
Back to top |
|
|
|
|
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
|
|