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 


Execute / trigger a hotkey

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
tomsolo
Newbie cheater
Reputation: 1

Joined: 20 Dec 2011
Posts: 18

PostPosted: Fri May 25, 2012 7:07 am    Post subject: Execute / trigger a hotkey Reply with quote

Hi there.

I tried using the memoryrecordhotkey_doHotkey(hotkey) command when initaliaze the trainer, but this is not working if use a generated/saved exe.

It's a bug or my fault?

Code:
RequiredCEVersion=6.2
if (getCEVersion==nil) or (getCEVersion()<RequiredCEVersion) then
  messageDialog('Please install Cheat Engine '..RequiredCEVersion, mtError, mbOK)
  closeCE()
end
addresslist=getAddressList()
memrec0=addresslist_getMemoryRecordByID(addresslist,0)

memrec0_hotkey0=memoryrecord_getHotkeyByID(memrec0,0)

function onHotkey0(Hotkey)
  cheatcomponent_setActive(CETrainer_CHEAT0, true, 1500)
  if gBeepOnAction then
    beep()
  end
end

memoryrecordhotkey_onHotkey(memrec0_hotkey0,onHotkey0)
memoryrecordhotkey_doHotkey(memrec0_hotkey0)
control_setVisible(CETrainer_SEPERATOR, false)

strings_add(getAutoAttachList(), "firefox.exe")
gBeepOnAction=false
form_show(CETrainer)
function AboutClick()
  showMessage(gAboutText)
end
gAboutText=[[This trainer was made by Cheat Engine]]

function CloseClick()
  closeCE()
  return caFree
end


Regards
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: Fri May 25, 2012 7:35 am    Post subject: Reply with quote

Does it work if you save it as a .ct and execute the lua code ?

Actually nevermind I see your problem, you are calling memoryrecordhotkey_doHotkey before cheat engine has even attached to the game (it hasn't even been added to the autoattach timer)

use openProcess("firefox.exe"), or use a timer that calls doHotkey after a second, or create the "function onOpenProcess(processid)" that gets called whenever ce opens a process (like the autoattach)

_________________
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
tomsolo
Newbie cheater
Reputation: 1

Joined: 20 Dec 2011
Posts: 18

PostPosted: Fri May 25, 2012 7:50 am    Post subject: Reply with quote

The order is indifferent, i tried pasting as last row but the command non executed. (The gui is working, but the address still unchanged.)

Here is the CETRAINER file (the address is a random writeable, maybe need changing).

If lua executed in CE is working, just as standalone no.
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: Fri May 25, 2012 7:55 am    Post subject: Reply with quote

As I said, you're doing the onHotkey command before the process has been opened (registering the process to the autoattach timer doesn't immediately open the process)

I've uploaded a version where it calls openProcess (and while not needed right now, reinitializeSymbolhandler() in case you decide to use aa scripts/modulename+offset addresses later)

Note that if firefox is not loaded it might give an error (not sure, haven't tested that situation)

_________________
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
tomsolo
Newbie cheater
Reputation: 1

Joined: 20 Dec 2011
Posts: 18

PostPosted: Fri May 25, 2012 7:58 am    Post subject: Reply with quote

Gotcha.

Need both this and now working... Smile

Code:

RequiredCEVersion=6.2
if (getCEVersion==nil) or (getCEVersion()<RequiredCEVersion) then
  messageDialog('Please install Cheat Engine '..RequiredCEVersion, mtError, mbOK)
  closeCE()
end
addresslist=getAddressList()
memrec0=addresslist_getMemoryRecordByID(addresslist,0)

memrec0_hotkey0=memoryrecord_getHotkeyByID(memrec0,0)

function onHotkey0(Hotkey)
  cheatcomponent_setActive(CETrainer_CHEAT0, true, 1500)
  if gBeepOnAction then
    beep()
  end
end

memoryrecordhotkey_onHotkey(memrec0_hotkey0,onHotkey0)
control_setVisible(CETrainer_SEPERATOR, false)

strings_add(getAutoAttachList(), "firefox.exe")
openProcess("firefox.exe")
gBeepOnAction=false
form_show(CETrainer)
function AboutClick()
  showMessage(gAboutText)
end
gAboutText=[[This trainer was made by Cheat Engine]]

function CloseClick()
  closeCE()
  return caFree
end

memoryrecordhotkey_doHotkey(memrec0_hotkey0)


Dark Byte wrote:
As I said, you're doing the onHotkey command before the process has been opened (registering the process to the autoattach timer doesn't immediately open the process)

I've uploaded a version where it calls openProcess (and while not needed right now, reinitializeSymbolhandler() in case you decide to use aa scripts/modulename+offset addresses later)

Note that if firefox is not loaded it might give an error (not sure, haven't tested that situation)


thanks!
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