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 


Key press lasts too long

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

Joined: 07 Apr 2016
Posts: 82
Location: U.S

PostPosted: Fri Oct 07, 2016 2:26 pm    Post subject: Key press lasts too long Reply with quote

When doing the script
Code:
   createHotkey(function(hk)
                         if ballx > p1x then
   keyDown(VK_RIGHT)
                 sleep(1)
        keyUp(VK_RIGHT)
        elseif ballx < p1x then
     keyDown(VK_LEFT)
                sleep(1)
        keyUp(VK_LEFT)
        return
        end
  end, VK_Q)

The code works, but when the ballx is < or > it's still pressing the other key instead of what it should for about 4 times, and it also presses it multiple times when i only want it to press once for if ballx is < press Left once, > press right once, etc.
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Fri Oct 07, 2016 3:38 pm    Post subject: Reply with quote

Use doKeyPress() instead of keyDown(), sleep(), and keyUp()?
Back to top
View user's profile Send private message
microsoftv
Advanced Cheater
Reputation: 0

Joined: 07 Apr 2016
Posts: 82
Location: U.S

PostPosted: Fri Oct 07, 2016 3:52 pm    Post subject: Reply with quote

Zanzer wrote:
Use doKeyPress() instead of keyDown(), sleep(), and keyUp()?

Thanks for replying, but I already tried that and it didn't work.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Fri Oct 07, 2016 4:22 pm    Post subject: Reply with quote

Look into:
Code:

setGlobalKeyPollInterval(integer): Sets the global keypoll interval. The interval determines the speed of how often CE checks if a key has been pressed or not. Lower is more accurate, but eats more cpu power
setGlobalDelayBetweenHotkeyActivation(integer): Sets the minimum delay between the activation of the same hotey in milliseconds. Affects all hotkeys that do not set their own minimum delay


e.g:
setGlobalKeyPollInterval(1)
setGlobalDelayBetweenHotkeyActivation(1)

Or set those delay on the hotkeys themselves (property DelayBetweenActivate )

(It will eat up some cpu power)

_________________
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
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