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 


Switching window focus with lua

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

Joined: 26 Feb 2018
Posts: 1

PostPosted: Mon Feb 26, 2018 2:48 pm    Post subject: Switching window focus with lua Reply with quote

So I am pretty much a lua noob. But I've written a fairly basic cheat table for an old desktop game, added a form with some buttons and stuff and its going well. Now here's where I hit a problem, every time I hit one of those buttons, the game loses focus and the form gains focus which is a problem because the game stops processing (basically freezes) when it doesn't have focus, and then resumes when focus is returned to the game (by clicking on the game window). I want the game to keep running when I click one of my forms buttons so the way I see it I have two choices:

1.) In the button click event handler switch focus back to the game window.

So far I've tried sending keyboard presses and mouse presses to the game in hopes they would return focus to the game and those didn't work.

2.) Prevent this window from gaining focus, but still process the mouseclick event

I think this is what windows on-screen keyboard does but I'm not sure how to approach this method.


Basically in an ideal world I would like to click a button on my form and have the game window maintain (or after a short time regain) focus.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Mon Feb 26, 2018 7:44 pm    Post subject: Reply with quote

You might be able to find something easy in Microsoft's Windows API Index. Otherwise, hook the window procedure and return MA_NOACTIVATE for WM_MOUSEACTIVATE messages. The hookWndProc CE Lua function will let you monitor messages but not define a return value (as far as I can tell), so you'll have to do that yourself.

Hotkeys would be easier.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
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