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 


Set a hotkey for the selected address

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
vsub
Newbie cheater
Reputation: 0

Joined: 08 Jun 2019
Posts: 10

PostPosted: Sat Jun 22, 2019 10:41 am    Post subject: Set a hotkey for the selected address Reply with quote

Not the usual way,that takes too much time

Is there is a way to set a hotkey that work on any selected code without having to add it every time when I want to check something

Usually when I want to change some skill\equipment or something else on some game,I find the address and then add a hotkey but when I want to do that for some other address,I have to either use different hotkey or delete the old one first from the previews code so the value does not change there

Something like this
Select a code,switch to the game and use Numpad+ and Numpad- to increase\decrease the value by 1
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Sun Jun 23, 2019 1:31 pm    Post subject: Reply with quote

maybe use a lua script something like
Code:

{$lua}
if syntaxcheck then return end -- do nothing on add/edit/syntax checking
[ENABLE]
for i=0, memrec.Count-1 do
  local mr = memrec.Child[i]
  mr.Value = tonumber(mr.Value) + 1 -- tonumber because it's a string
end
local t = createTimer()
t.Interval = 10
t.OnTimer = function(t) memrec.Active = false t.destroy() end
[DISABLE]


then set a hotkey on that and nest anything you want to change under it (so that it's indented) and when you hit the hotkey it'll toggle the script which loops over all the children and adds 1 to the current value.

Of course you'll have to move/delete anything you don't want changed but... there's really no way around that besides having something prompt you somehow for the address every single time you want to use it.

You can of course have a second script that decreases, though... in that case you may want to use a separate header and treat it as the main memrec and loop over it's children rather than duplicating the addresses under each script. eg
Code:
{$lua}
if syntaxcheck then return end -- do nothing on add/edit/syntax checking
[ENABLE]
-- use to disable script
local t = createTimer()
t.Interval = 10
t.OnTimer = function(t) memrec.Active = false t.destroy() end

-- overwrite memrec to refer to header with nested addresses to change
local memrec = AddressList.getMemoryRecordByDescription('ToChange')
for i=0, memrec.Count-1 do
  local mr = memrec.Child[i]
  mr.Value = tonumber(mr.Value) + 1 -- tonumber because it's a string
end
[DISABLE]

I don't think there's anyway to tell which hotkey was pressed in the script... though you could use the more generic createHotkey lua function to create them then you'd activate the script once to setup two hotkeys which run a lua function to loop over the children and change the values. The former method(s) wouldn't require manually activating the script, simply setting up the addresses to change and pressing the hotkey saved in the table, the latter would need the user to run the script to create the hotkeys (as well as setup the addresses to change if they didn't want the default). example
Code:
{$lua}
if syntaxcheck then return end -- do nothing on add/edit/syntax checking
[ENABLE]
-- utility function to avoid duplicating code
function modifyChildren(memrec, delta)
  for i=0, memrec.Count-1 do
    local mr = memrec.Child[i]
    mr.Value = tonumber(mr.Value) + delta -- tonumber because it's a string
  end
end
-- hotkey creation
PlusHotkey = createHotkey(function() modifyChildren(memrec, 1) end, VK_F2)
MinusHotkey = createHotkey(function() modifyChildren(memrec, -1) end, VK_F3)
-- not sure what numpad names are off the top of my head
[DISABLE]
-- prevent the hotkeys from working after script is disabled
PlusHotkey.destroy()
MinusHotkey.destroy()


hopefully one of those are helpful lol

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
vsub
Newbie cheater
Reputation: 0

Joined: 08 Jun 2019
Posts: 10

PostPosted: Mon Jun 24, 2019 8:01 am    Post subject: Reply with quote

Thanks for the reply
Sorry if you already posted a solution for this(I am new to lua)but how about this

Can this be done with lua
When I press a specific hotkey(lets say *(multiply)),a script is executed that add the hotkeys numpad+ and numpad- to the selected code and when I press it again,disables the hotkey
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Mon Jun 24, 2019 9:22 am    Post subject: Reply with quote

Sure something like this should work
Code:
{$lua}
--if syntaxcheck then return end
[ENABLE]
function ChangeMemrecByDelta(mr,delta) if mr then mr.Value = tonumber(mr.Value) + delta end end
LastSelectedMR = nil
LastSelectedMRColor = nil
IncrementingHotkey = createHotkey(function() ChangeMemrecByDelta(LastSelectedMR, 1) end, VK_ADD)
DecrementingHotkey = createHotkey(function() ChangeMemrecByDelta(LastSelectedMR, -1) end, VK_SUBTRACT)
HotkeyCreatingHotkey = createHotkey(function()
  if LastSelectedMR and LastSelectedMRColor then LastSelectedMR.Color = LastSelectedMRColor end
  LastSelectedMR = AddressList.SelectedRecord
  if LastSelectedMR then
    LastSelectedMRColor = LastSelectedMR.Color
    LastSelectedMR.Color = 0x0000FF -- little endian, BGR
  end
end, VK_MULTIPLY)

[DISABLE]
if LastSelectedMR then LastSelectedMR.Color = LastSelectedMRColor end
IncrementingHotkey.destroy()
DecrementingHotkey.destroy()
HotkeyCreatingHotkey.destroy()

It could be simplified a bit if you just modified whatever the selected record is but that'd also mean you'd have to keep whatever you wanted to be changing selected in CE whenever you wanted to use the hotkey


I did try using the memrec.createHotkey method but it didn't really seem to be working for me so I switched to lua's generic ones pretty quickly. To disable either press the hotkey without anything selected or just disable the script

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
vsub
Newbie cheater
Reputation: 0

Joined: 08 Jun 2019
Posts: 10

PostPosted: Mon Jun 24, 2019 10:02 am    Post subject: Reply with quote

Thanks.
One stupid question....how exactly to use that code
When I do Table=>Show Chat Table Lua Script and execute the script,I get an error

[Window Title]
Error

[Content]
[string "{$lua}
..."]:1: unexpected symbol near '{'

[OK]

I get the same thing if I place the file in the autorun folder
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Tue Jun 25, 2019 1:32 pm    Post subject: Reply with quote

It should just work in an AA script, you can try copy pasting this into CE itself
Code:
<?xml version="1.0" encoding="utf-8"?>
<CheatTable>
  <CheatEntries>
    <CheatEntry>
      <ID>0</ID>
      <Description>"Auto Assemble script"</Description>
      <LastState/>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>{$lua}
--if syntaxcheck then return end
[ENABLE]
function ChangeMemrecByDelta(mr,delta) if mr then mr.Value = tonumber(mr.Value) + delta end end
LastSelectedMR = nil
LastSelectedMRColor = nil
IncrementingHotkey = createHotkey(function() ChangeMemrecByDelta(LastSelectedMR, 1) end, VK_ADD)
DecrementingHotkey = createHotkey(function() ChangeMemrecByDelta(LastSelectedMR, -1) end, VK_SUBTRACT)
HotkeyCreatingHotkey = createHotkey(function()
  if LastSelectedMR and LastSelectedMRColor then LastSelectedMR.Color = LastSelectedMRColor end
  LastSelectedMR = AddressList.SelectedRecord
  if LastSelectedMR then
    LastSelectedMRColor = LastSelectedMR.Color
    LastSelectedMR.Color = 0x0000FF -- little endian, BGR
  end
end, VK_MULTIPLY)

[DISABLE]
if LastSelectedMR then LastSelectedMR.Color = LastSelectedMRColor end
IncrementingHotkey.destroy()
DecrementingHotkey.destroy()
HotkeyCreatingHotkey.destroy()
</AssemblerScript>
    </CheatEntry>
  </CheatEntries>
</CheatTable>


sorry for delay, my email refuses to accept that CE notification emails are not junk and I haven't manually checked junk/spam mail or the forums until now

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
vsub
Newbie cheater
Reputation: 0

Joined: 08 Jun 2019
Posts: 10

PostPosted: Wed Jun 26, 2019 9:24 am    Post subject: Reply with quote

Thanks,this makes it so much easier.
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 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