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 


Check if key pressed once

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

Joined: 22 Jun 2021
Posts: 237

PostPosted: Wed Oct 27, 2021 5:32 am    Post subject: Check if key pressed once Reply with quote

I wanted to make this,but idk how to
Like in c++ and c i can use
Code:
getAsyncKeyState()

_________________
void(*Haxing)(int Game)
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater
Reputation: 5

Joined: 02 Sep 2011
Posts: 537
Location: 0x90

PostPosted: Wed Oct 27, 2021 6:38 am    Post subject: Reply with quote

This should work as intended.
Code:

isKeyPressed(key) : returns true if the specified key is currently pressed
Back to top
View user's profile Send private message
Frouk
Expert Cheater
Reputation: 1

Joined: 22 Jun 2021
Posts: 237

PostPosted: Wed Oct 27, 2021 6:42 am    Post subject: Reply with quote

LeFiXER wrote:
This should work as intended.
Code:

isKeyPressed(key) : returns true if the specified key is currently pressed

i'm using timer,while and repeat are freezing cheat engine

_________________
void(*Haxing)(int Game)
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater
Reputation: 5

Joined: 02 Sep 2011
Posts: 537
Location: 0x90

PostPosted: Wed Oct 27, 2021 7:19 am    Post subject: Reply with quote

If you had while/repeat in another thread that have specific criteria to ensure an infinite loop isn't going to happen then you should be okay to use that. Note that other threads can't access the GUI.

If you're using a timer instead, set a flag once the key is pressed and have the timer check the condition of the flag.
Back to top
View user's profile Send private message
Frouk
Expert Cheater
Reputation: 1

Joined: 22 Jun 2021
Posts: 237

PostPosted: Wed Oct 27, 2021 8:14 am    Post subject: Reply with quote

tried but failing
_________________
void(*Haxing)(int Game)
Back to top
View user's profile Send private message
Flux.
Advanced Cheater
Reputation: 0

Joined: 10 Nov 2016
Posts: 74
Location: Another World - N5X2 106311411+2123518

PostPosted: Sat Oct 30, 2021 2:16 pm    Post subject: Reply with quote

Hello Frouk,
I wanted to have a go at this.
This is what i came up with, everytime z is pressed you should hear a beep!
Code:
{$lua}
[ENABLE]

timer = createTimer(nil)
timer.setInterval = 1000
timer.OnTimer = function()
isk = isKeyPressed(VK_Z)
  if isk == true then beep()
  end
end

[DISABLE]
timer.destroy()
timer=nil
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 422

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

PostPosted: Sat Oct 30, 2021 5:00 pm    Post subject: Reply with quote

createHotkey for that one key may work as it also responses to the 'pressed since last check'
_________________
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
Flux.
Advanced Cheater
Reputation: 0

Joined: 10 Nov 2016
Posts: 74
Location: Another World - N5X2 106311411+2123518

PostPosted: Sun Oct 31, 2021 3:32 am    Post subject: Reply with quote

Here is a quick key test using a hotkey, which beeps when pressing z.
Code:
{$lua}
[ENABLE]
HK = createHotkey(beep,VK_Z)

[DISABLE]
if HK then HK.Destroy(); HK=nil end
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