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 


How do I detect if Form is Active/Selected?

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

Joined: 15 Dec 2016
Posts: 31

PostPosted: Sun Jan 24, 2021 4:38 pm    Post subject: How do I detect if Form is Active/Selected? Reply with quote

I maybe asking this incorrectly as I don't know what to look for. I have created a Form. I have a menu and you and can use the arrow keys to move up and down the list. Which works perfectly. However when a different Window is selected like your web browser. The arrow keys sill work to move around the menu. How can I make is so that the arrow keys only work when the Form Window has been clicked on is the Active Window.


Code:
if (isKeyPressed(VK_UP)) then
elseif (isKeyPressed(VK_DOWN)) then
end


Thanks!
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25824
Location: The netherlands

PostPosted: Sun Jan 24, 2021 5:07 pm    Post subject: Reply with quote

it's beter to use the keydown event of the form

but you can use form.isForegroundWindow() for that

_________________
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
View user's profile Send private message MSN Messenger
daspamer
Grandmaster Cheater Supreme
Reputation: 54

Joined: 13 Sep 2011
Posts: 1588

PostPosted: Mon Jan 25, 2021 1:29 am    Post subject: Reply with quote

Alternatively you may use OnActivate and OnDeactivate methods.

Code:

local isFormActive = false;
form.OnActivate = function(sender)
   isFormActive = true; -- or use form.tag ...
end
form.OnDeactivate = function(sender)
   isFormActive = false;
end

_________________
I'm rusty and getting older, help me re-learn lua.
Back to top
View user's profile Send private message Visit poster's website
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