Posted: Mon Feb 26, 2018 2:48 pm Post subject: Switching window focus with lua
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.
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.
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