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 


(solved) doKeyPress pauses/freezes the game for few seconds!

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

Joined: 24 Dec 2006
Posts: 76

PostPosted: Mon Mar 23, 2015 8:07 pm    Post subject: (solved) doKeyPress pauses/freezes the game for few seconds! Reply with quote

Hi

I had this cool idea for my trainer to "speak out" the in game hack events.
example, if enemy upgraded his weapon. a voice says "enemy is upgrading weapons"

I am using "VoiceAttack" program for text to speech, each voice event is triggered by a hotkey.

this is were doKeyPress come into picture. Lua will do doKeyPress("K") and VoiceAttack will capture it and speak out the event associated with "K"

unfortunately, doKeyPress seems to pause the game for few seconds every time is being executed.
when I remove it, my programs runs flawlessly.
note: these events are not aggressive, one every minute or so

does anyone have any idea why the freeze?

or a better question.
do you have a better way to make Lua do text to speech?

thanks


Last edited by ta_trainer on Mon Mar 23, 2015 9:01 pm; edited 1 time in total
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Mon Mar 23, 2015 8:23 pm    Post subject: Reply with quote

Is it pausing just long enough to finish speaking? Is this task not asynchronous?
Back to top
View user's profile Send private message
ta_trainer
Advanced Cheater
Reputation: 0

Joined: 24 Dec 2006
Posts: 76

PostPosted: Mon Mar 23, 2015 8:31 pm    Post subject: Reply with quote

Zanzer wrote:
Is it pausing just long enough to finish speaking? Is this task not asynchronous?


This does not apply here because the voice comes out from VoiceAttack software which is a separate process from CE
CE simulates key press and VoiceAttack captures it

SOLVED:
take out the doKeyPress in a seperate thread then terminate it
so, in Lua, call doKeyPress_thread instead of doKeyPress

Code:
function doKeyPress_thread(key)
    globalkey = key
    tk=createTimer(nil);
    timer_setInterval(tk,100)
    timer_onTimer(tk,keythread)
end

function keythread(tk)
   doKeyPress(globalkey)
   object_destroy(tk)
end
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Tue Mar 24, 2015 2:41 am    Post subject: Reply with quote

that shouldn't solve it as a timer is not a thread. it still runs inside the main thread, and destroying tk won't stop the current thread. It just stops it from calling it again

perhaps your issue is somewhere else (e. g a loop inside the main thread)

_________________
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
ta_trainer
Advanced Cheater
Reputation: 0

Joined: 24 Dec 2006
Posts: 76

PostPosted: Tue Mar 24, 2015 12:12 pm    Post subject: Reply with quote

Dark Byte wrote:
that shouldn't solve it as a timer is not a thread. it still runs inside the main thread, and destroying tk won't stop the current thread. It just stops it from calling it again

perhaps your issue is somewhere else (e. g a loop inside the main thread)


thanks for the input, actually, the script has no loops but breakpoints like this:

Code:
BuildingUpgrade = 0x12345678
debug_setBreakpoint(BuildingUpgrade)

function debugger_onBreakpoint()
    if (EIP == BuildingUpgrade) then
         if (the enemy is upgrading ...etc) then
          doKeyPress("D") --this key will invoke VoiceAttach to do text to speech "Warning, enemy is upgrading...etc"
         end
        return 1
    end
end


The doPressKey being in BP inline with the code flow is slowing it down, even through it is not frequently matched up.

I see your point about not being in a separate thread, but the proposed solution seemed to work.
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