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 


Send Keypress w/No Focus [Resolved]

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

Joined: 30 Mar 2016
Posts: 15

PostPosted: Thu Mar 31, 2016 9:10 pm    Post subject: Send Keypress w/No Focus [Resolved] Reply with quote

I am needing to have the O key sent to an application that has no focus.
I know how to use hWnd/SendMessage in VB.Net/C#/C++, but want to have it done via Lua. How can I send a keypress to the application that I'm attached to, without having focus on the application. Either AA or Lua will be fine, I just need help.

Alright, so I can define the keys in my CT script:
Code:

define(KEY_NORMAL,0)
define(KEY_EXTENDED,1)

//The 11 is the key code from MSDN
define(VK_CONTROL,11)

define(HoldCTRL,0)

define(CTRLKey,VK_CONTROL)
define(CTRLKeyType,KEY_EXTENDED)

define(ReloadKey,'R')
define(ReloadKeyType,KEY_NORMAL)

What do I do, from here, or is there a better way? Assuming I need to use the window handle, somehow, and simulate a keypress. How would I get the hwnd and use SendMessage, if that would work? Keys being CTRL and R. Also, the kepresses need to be looped at 100ms intervals; so it needs to keep pressing as long as the box is checked.


Last edited by Derpicus on Sat Apr 02, 2016 7:06 am; edited 1 time in total
Back to top
View user's profile Send private message
Derpicus
Newbie cheater
Reputation: 1

Joined: 30 Mar 2016
Posts: 15

PostPosted: Sat Apr 02, 2016 5:27 am    Post subject: This post has 1 review(s) Reply with quote

I managed to find the solution to this, myself. Very Happy

Since it was based on direct-x, I had to push keycodes to the function used to process them. It works pretty simply, like this (after defining the keycode).
Code:

mov esi,[*Pointer*]
mov ecx,[esi+A4]
push edx
push 00
call *Pointer*
ret

*Pointer*:
jmp WhateverName
db 90 90 90 90 90
Ret:


Also a simple jmp. If anyone needs help with this, simply let me know and if I have the same game, I'll help you!
Back to top
View user's profile Send private message
pozzum
Newbie cheater
Reputation: 0

Joined: 19 Jun 2015
Posts: 22

PostPosted: Sat Apr 02, 2016 10:08 am    Post subject: Reply with quote

You happen to have wwe 2K16? I've been thinking of starting a project requiring key presses while not in focus and If this possible for that game that'd be awesome
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