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 


Game not Reading Virtual Key Presses?

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

Joined: 19 Jun 2015
Posts: 22

PostPosted: Fri May 06, 2016 1:51 pm    Post subject: Game not Reading Virtual Key Presses? Reply with quote

Hi there so I've been trying to build a quick lua script that will press a few buttons and fill a few values in between button presses.

I seem to have some trouble with the game not reading the key presses.

I am running on a 1 second timer

Code:
    keyDown(13)
    sleep(50)
    keyUp(13)


until a menu change is detected.

When I go to windows it is pressing enter every second however when I go back to the game it doesn't seem to work. Has anyone encountered an issue like this?

The Game is WWE 2K16 for reference.
Back to top
View user's profile Send private message
Redouane
Master Cheater
Reputation: 3

Joined: 05 Sep 2013
Posts: 363
Location: Algeria

PostPosted: Sun May 08, 2016 5:26 am    Post subject: Re: Game not Reading Virtual Key Presses? Reply with quote

pozzum wrote:
Hi there so I've been trying to build a quick lua script that will press a few buttons and fill a few values in between button presses.

I seem to have some trouble with the game not reading the key presses.

I am running on a 1 second timer

Code:
    keyDown(13)
    sleep(50)
    keyUp(13)


until a menu change is detected.

When I go to windows it is pressing enter every second however when I go back to the game it doesn't seem to work. Has anyone encountered an issue like this?

The Game is WWE 2K16 for reference.


use doKeyPress instead.
Code:
doKeyPress(VK_RETURN)

in a timer, something like this:
Code:
t = createTimer(false);
t.Interval,t.onTimer = 1000,function(_t)
return doKeyPress(VK_RETURN);
end


Another way would be to use sendMessage/postMessage to send a WM_KEYDOWN + WM_KEYUP to the target process (https://msdn.microsoft.com/en-us/library/windows/desktop/ff468861%28v=vs.85%29.aspx https://msdn.microsoft.com/en-us/library/windows/desktop/ms644950%28v=vs.85%29.aspx), not sure on how these messages are handled, but I've read that applications sometimes use peekMessage to handle keyboard events.
Back to top
View user's profile Send private message
pozzum
Newbie cheater
Reputation: 0

Joined: 19 Jun 2015
Posts: 22

PostPosted: Sun May 08, 2016 1:35 pm    Post subject: Re: Game not Reading Virtual Key Presses? Reply with quote

Redouane wrote:
pozzum wrote:
Hi there so I've been trying to build a quick lua script that will press a few buttons and fill a few values in between button presses.

I seem to have some trouble with the game not reading the key presses.

I am running on a 1 second timer

Code:
    keyDown(13)
    sleep(50)
    keyUp(13)


until a menu change is detected.

When I go to windows it is pressing enter every second however when I go back to the game it doesn't seem to work. Has anyone encountered an issue like this?

The Game is WWE 2K16 for reference.


use doKeyPress instead.
Code:
doKeyPress(VK_RETURN)

in a timer, something like this:
Code:
t = createTimer(false);
t.Interval,t.onTimer = 1000,function(_t)
return doKeyPress(VK_RETURN);
end


Another way would be to use sendMessage/postMessage to send a WM_KEYDOWN + WM_KEYUP to the target process (https://msdn.microsoft.com/en-us/library/windows/desktop/ff468861%28v=vs.85%29.aspx https://msdn.microsoft.com/en-us/library/windows/desktop/ms644950%28v=vs.85%29.aspx), not sure on how these messages are handled, but I've read that applications sometimes use peekMessage to handle keyboard events.


So I switched from dokeypress to the keydown / keyup both actually send the key to the system (if I go to notepad it will make new lines or type the characters)

So using sendmessage/postmessage is that something doable in lua or do I have to do assembly I'm not really sure, most of the programming I see for it is in C#. I imagine there would be some differences in the syntax and how things are defined.

I have a temporary hardware fix but it's limiting the usefulness of what I'm trying to do.
Back to top
View user's profile Send private message
Redouane
Master Cheater
Reputation: 3

Joined: 05 Sep 2013
Posts: 363
Location: Algeria

PostPosted: Mon May 09, 2016 4:41 am    Post subject: Re: Game not Reading Virtual Key Presses? Reply with quote

pozzum wrote:

So I switched from dokeypress to the keydown / keyup both actually send the key to the system (if I go to notepad it will make new lines or type the characters)

So using sendmessage/postmessage is that something doable in lua or do I have to do assembly I'm not really sure, most of the programming I see for it is in C#. I imagine there would be some differences in the syntax and how things are defined.

I have a temporary hardware fix but it's limiting the usefulness of what I'm trying to do.


Of course, SendMessage is something to do in ASM, it's not hard to translate an example that uses the Windows API to ASM, again, I've never used that function, but if you have some code in another language, then maybe I can translate.
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 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