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 


Mimic Go to Address

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Game Hacking Dojo
Master Cheater
Reputation: 1

Joined: 17 Sep 2023
Posts: 250

PostPosted: Wed Oct 09, 2024 6:44 pm    Post subject: Mimic Go to Address Reply with quote

I hate the go-to address option and want to make my own. Is there a way I can mimic the functionality of going to the address (for both memory view and assembly)?
Back to top
View user's profile Send private message Visit poster's website
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4706

PostPosted: Thu Oct 10, 2024 12:06 am    Post subject: This post has 1 review(s) Reply with quote

Code:
local addr = inputQuery('Go to address', 'Set the disassembler and hex view to this address:', '')
if not addr then return end
addr = getAddress(addr)  -- needed - the symbol handler isn't queried automatically

local mv = getMemoryViewForm()
mv.DisassemblerView.TopAddress = addr
mv.HexadecimalView.Address = addr

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Game Hacking Dojo
Master Cheater
Reputation: 1

Joined: 17 Sep 2023
Posts: 250

PostPosted: Thu Oct 10, 2024 10:08 am    Post subject: Reply with quote

Thank you, that made me make this form:

Code:
local function go_to_address()
  local form_colour = "0x242424"     --BGR
  local bevel_colour = "0x404040"    --BGR
  local font_colour = "0xBBBBBB"     --BGR
  local spacing = 8

  -- Create main window
  local form = createForm(false)
  form.Caption = "Go to address"
  form.AutoSize = true
  form.Constraints.MinHeight = 92
  form.Constraints.MinWidth = 360
  form.Constraints.MaxWidth = 1300
  form.Font.Color = font_colour

  -- Create main panel
  local main_panel = createPanel(form)
  main_panel.Align = alClient
  main_panel.ClientHeight = form.ClientHeight
  main_panel.ClientWidth = form.ClientWidth
  main_panel.BevelColor = form_colour

  -- Create input box
  local inputbox = createEdit(main_panel)
  inputbox.Align = alTop
  inputbox.BorderSpacing.top = 20
  inputbox.BorderSpacing.Left = 4
  inputbox.BorderSpacing.Right = 4

  -- Create button panel
  local button_panel = createPanel(form)
  button_panel.ClientHeight = 40
  button_panel.Align = alBottom
  button_panel.BevelColor = form_colour

  -- Create go button
  local go_button = createButton(button_panel)
  go_button.Caption = "Go"
  go_button.Align = alRight
  go_button.Constraints.MinWidth = 64
  go_button.Constraints.MinHeight = 19
  go_button.AutoSize = true
  go_button.BorderSpacing.around = spacing
  go_button.OnCLick = function()
    local address = getAddress(inputbox.text)
    getMemoryViewForm().DisassemblerView.TopAddress = address
    form.close()
  end

  -- Create cancel button
  local cancel_button = createButton(button_panel)
  cancel_button.Caption = "Cancel"
  cancel_button.Align = alRight
  cancel_button.Constraints.MinWidth = 64
  cancel_button.Constraints.MinHeight = 19
  cancel_button.AutoSize = true
  cancel_button.BorderSpacing.around = spacing
  cancel_button.OnClick = function() form.close() end

  -- Create offset checkbox
  local offset_checkbox = createCheckBox(button_panel)
  local initial_input = ""
  offset_checkbox.Caption = "Module/Symbol & Offset"
  offset_checkbox.Align = alLeft
  offset_checkbox.Constraints.MinWidth = 200
  offset_checkbox.Constraints.MaxHeight = 19
  offset_checkbox.BorderSpacing.around = spacing
  offset_checkbox.setAllowGrayed(true)
  offset_checkbox.onChange = function()
    if inputbox.text == "" then return end    --safety check
    if offset_checkbox.state ~= cbUnchecked then
      if offset_checkbox.state == cbGrayed then
        initial_input = inputbox.text:gsub("%s+$", "")
        inputbox.text = getNameFromAddress(inputbox.text, true, false)
      end
      if offset_checkbox.state == cbChecked then
        inputbox.text = getNameFromAddress(inputbox.text, true, true)
      end
    end
    if offset_checkbox.state == cbUnchecked then
      inputbox.text = initial_input
    end
  end

  form.showModal()
end

go_to_address()


Is there a way to change the main bar colour to dark?
If I use the checkbox and close the form using cancel I get an access violation error printed in the Lua engine

I solved the access violation error by adding a safety check

And I think this form is so much better than the original one despite it not saving history. Also, the way it shows the address at the top even if it's within view unlike the original.



Screenshot 2024-10-10 192441.png
 Description:
 Filesize:  4.97 KB
 Viewed:  3792 Time(s)

Screenshot 2024-10-10 192441.png


Back to top
View user's profile Send private message Visit poster's website
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1528

PostPosted: Thu Oct 10, 2024 1:41 pm    Post subject: Reply with quote

Just an idea.

Code:
function go_to_address()
if gt_addr1 then gt_addr1.Destroy() gt_addr1=nil end
DP1=getScreenDPI()/96
gt_addr1=createForm()
gt_addr1.height=130*DP1 gt_addr1.width=400*DP1
gt_addr1.PopupMode=0 gt_addr1.caption="AylinCE"
gt_addr1.Position="poDesktopCenter" gt_addr1.ShowInTaskBar="stAlways"
gt_addr1.BorderStyle="bsNone"
gt_addr1.setLayeredAttributes(0x000100, 255, LWA_COLORKEY | LWA_ALPHA )
gt_addr1.Color=0x000100

-------------------------
local gta_frm1 = {}
----------------------- gta_frm1.m_pnl1 ----- 
gta_frm1.m_pnl1=createPanel(gt_addr1)
gta_frm1.m_pnl1.AutoSize=false
gta_frm1.m_pnl1.height=25*DP1 gta_frm1.m_pnl1.width=390*DP1 gta_frm1.m_pnl1.left=5*DP1 gta_frm1.m_pnl1.top=7*DP1
gta_frm1.m_pnl1.caption=""
gta_frm1.m_pnl1.Cursor = -22
gta_frm1.m_pnl1.Color=0
gta_frm1.m_pnl1.Font.Style="fsBold" gta_frm1.m_pnl1.Font.Color=0xffffff
gta_frm1.m_pnl1.OnMouseDown=function() gt_addr1.DragNow() end
-----------------------
----------------------- gta_frm1.lg_img1 ----- 
gta_frm1.lg_img1=createImage(gta_frm1.m_pnl1)
gta_frm1.lg_img1.AutoSize=false
gta_frm1.lg_img1.height=21*DP1 gta_frm1.lg_img1.width=21*DP1 gta_frm1.lg_img1.left=5*DP1 gta_frm1.lg_img1.top=2*DP1
gta_frm1.lg_img1.Font.Style="fsBold" gta_frm1.lg_img1.Font.Size=0*DP1
gta_frm1.lg_img1.Stretch=true
gta_frm1.lg_img1.Picture=MainForm.Icon
-----------------------
----------------------- gta_frm1.mn_tt1 ----- 
gta_frm1.mn_tt1=createLabel(gta_frm1.m_pnl1)
gta_frm1.mn_tt1.AutoSize=true
gta_frm1.mn_tt1.height=20*DP1 gta_frm1.mn_tt1.width=93*DP1 gta_frm1.mn_tt1.left=35*DP1 gta_frm1.mn_tt1.top=3*DP1
gta_frm1.mn_tt1.caption="Go to Addres"
gta_frm1.mn_tt1.alignment="taLeftJustify"
gta_frm1.mn_tt1.Font.Style="fsBold" gta_frm1.mn_tt1.Font.Size=11*DP1
-----------------------
----------------------- gta_frm1.mn_tt2 ----- 
gta_frm1.mn_tt2=createLabel(gta_frm1.m_pnl1)
gta_frm1.mn_tt2.AutoSize=false
gta_frm1.mn_tt2.height=20*DP1 gta_frm1.mn_tt2.width=20*DP1 gta_frm1.mn_tt2.left=320*DP1 gta_frm1.mn_tt2.top=3*DP1
gta_frm1.mn_tt2.caption="-"
gta_frm1.mn_tt2.Font.Name="Courier New" gta_frm1.mn_tt2.Cursor = -21
gta_frm1.mn_tt2.Font.Style="fsBold" gta_frm1.mn_tt2.Font.Size=20*DP1
-----------------------
----------------------- gta_frm1.mn_tt3 ----- 
gta_frm1.mn_tt3=createLabel(gta_frm1.m_pnl1)
gta_frm1.mn_tt3.AutoSize=false
gta_frm1.mn_tt3.height=20*DP1 gta_frm1.mn_tt3.width=20*DP1 gta_frm1.mn_tt3.left=365*DP1 gta_frm1.mn_tt3.top=3*DP1
gta_frm1.mn_tt3.caption="X"
gta_frm1.mn_tt3.alignment="taCenter" gta_frm1.mn_tt3.Cursor = -21
gta_frm1.mn_tt3.Font.Style="fsBold" gta_frm1.mn_tt3.Font.Size=11*DP1
-----------------------
----------------------- gta_frm1.m_pnl2 ----- 
gta_frm1.m_pnl2=createPanel(gt_addr1)
gta_frm1.m_pnl2.AutoSize=false
gta_frm1.m_pnl2.height=51*DP1 gta_frm1.m_pnl2.width=390*DP1 gta_frm1.m_pnl2.left=5*DP1 gta_frm1.m_pnl2.top=33*DP1
gta_frm1.m_pnl2.Color=0
gta_frm1.m_pnl2.Font.Style="fsBold" gta_frm1.m_pnl2.Font.Color=0xffffff
-----------------------
----------------------- gta_frm1.inputbox ----- 
gta_frm1.inputbox=createEdit(gta_frm1.m_pnl2)
gta_frm1.inputbox.AutoSize=false
gta_frm1.inputbox.height=23*DP1 gta_frm1.inputbox.width=380*DP1 gta_frm1.inputbox.left=5*DP1 gta_frm1.inputbox.top=14*DP1
gta_frm1.inputbox.text=""
gta_frm1.inputbox.color=0
gta_frm1.inputbox.Font.Style="fsBold" gta_frm1.inputbox.Font.Size=11*DP1
-----------------------
----------------------- gta_frm1.m_pnl3 ----- 
gta_frm1.m_pnl3=createPanel(gt_addr1)
gta_frm1.m_pnl3.AutoSize=false
gta_frm1.m_pnl3.height=35*DP1 gta_frm1.m_pnl3.width=390*DP1 gta_frm1.m_pnl3.left=5*DP1 gta_frm1.m_pnl3.top=85*DP1
gta_frm1.m_pnl3.caption=""
gta_frm1.m_pnl3.Color=0
gta_frm1.m_pnl3.Font.Style="fsBold" gta_frm1.m_pnl3.Font.Color=0xffffff
-----------------------
----------------------- gta_frm1.offset_checkbox ----- 
gta_frm1.offset_checkbox=createCheckBox(gta_frm1.m_pnl3)
gta_frm1.offset_checkbox.AutoSize=false
gta_frm1.offset_checkbox.height=24*DP1 gta_frm1.offset_checkbox.width=24*DP1 gta_frm1.offset_checkbox.left=7*DP1 gta_frm1.offset_checkbox.top=6*DP1
gta_frm1.offset_checkbox.alignment="taRightJustify"
gta_frm1.offset_checkbox.Font.Style="fsBold" gta_frm1.offset_checkbox.Font.Size=11*DP1
gta_frm1.offset_checkbox.caption=""
-----------------------
----------------------- gta_frm1.mn_tt1 ----- 
gta_frm1.mn_tt11=createLabel(gta_frm1.m_pnl3)
gta_frm1.mn_tt11.AutoSize=false
gta_frm1.mn_tt11.height=18*DP1 gta_frm1.mn_tt11.width=160*DP1 gta_frm1.mn_tt11.left=27*DP1 gta_frm1.mn_tt11.top=8*DP1
gta_frm1.mn_tt11.caption=" Module/Symbol & Offset"
gta_frm1.mn_tt11.cursor = -21
gta_frm1.mn_tt11.Font.Style="fsBold" gta_frm1.mn_tt11.Font.Size=10*DP1
-----------------------
----------------------- gta_frm1.go_button ----- 
gta_frm1.go_button=createPanel(gta_frm1.m_pnl3)
gta_frm1.go_button.AutoSize=false
gta_frm1.go_button.height=22*DP1 gta_frm1.go_button.width=70*DP1 gta_frm1.go_button.left=230*DP1 gta_frm1.go_button.top=7*DP1
gta_frm1.go_button.caption="Go"
gta_frm1.go_button.alignment="2"
gta_frm1.go_button.Font.Style="fsBold" gta_frm1.go_button.Font.Size=0*DP1
-----------------------
----------------------- gta_frm1.cancel_button ----- 
gta_frm1.cancel_button=createPanel(gta_frm1.m_pnl3)
gta_frm1.cancel_button.AutoSize=false
gta_frm1.cancel_button.height=22*DP1 gta_frm1.cancel_button.width=70*DP1 gta_frm1.cancel_button.left=315*DP1 gta_frm1.cancel_button.top=7*DP1
gta_frm1.cancel_button.caption="Cancel"
gta_frm1.cancel_button.alignment="2"
gta_frm1.cancel_button.Font.Style="fsBold" gta_frm1.cancel_button.Font.Size=0*DP1
-----------------------
gt_addr1.Visible=false
-----------------------

function panelClickEffect(item2)
item2.BevelColor=clDefault
item2.Color=0

item2.OnMouseMove=function() item2.BevelColor=0x757575 end
item2.OnMouseLeave=function() item2.BevelColor=clDefault end

item2.OnMouseDown=function() item2.Color=0x616161 end
item2.OnMouseUp=function() item2.Color=0 end
end

panelClickEffect(gta_frm1.go_button)
panelClickEffect(gta_frm1.cancel_button)

------------------------
------------------------

gta_frm1.mn_tt3.OnMouseMove=function() gta_frm1.mn_tt3.Color=0x616161 end
gta_frm1.mn_tt3.OnMouseLeave=function() gta_frm1.mn_tt3.Color=0 end

gta_frm1.mn_tt2.OnMouseMove=function() gta_frm1.mn_tt2.Color=0x616161 end
gta_frm1.mn_tt2.OnMouseLeave=function() gta_frm1.mn_tt2.Color=0 end

gta_frm1.mn_tt11.OnMouseMove=function() gta_frm1.mn_tt11.Color=0x616161 end
gta_frm1.mn_tt11.OnMouseLeave=function() gta_frm1.mn_tt11.Color=0 end

gta_frm1.mn_tt2.OnClick=function()
gt_addr1.WindowState = "wsMinimized"
end

gta_frm1.mn_tt3.OnClick=function()
gt_addr1.Close()
end

gta_frm1.cancel_button.OnClick=function()
gt_addr1.Close()
end


  gta_frm1.go_button.OnCLick = function()
  if gta_frm1.inputbox.text == "" then return end
    local address = getAddress(gta_frm1.inputbox.text)
    getMemoryViewForm().DisassemblerView.TopAddress = address
    gt_addr1.Close()
  end

  gta_frm1.offset_checkbox.onChange = function()
    if gta_frm1.inputbox.text == "" then return end    --gta_frm1.offset_checkbox.state=0 return end
    if gta_frm1.offset_checkbox.state ~= cbUnchecked then
      if gta_frm1.offset_checkbox.state == cbGrayed then
        local initial_input = gta_frm1.inputbox.text:gsub("%s+$", "")
        gta_frm1.inputbox.text = getNameFromAddress(gta_frm1.inputbox.text, true, false)
      end
      if gta_frm1.offset_checkbox.state == cbChecked then
        gta_frm1.inputbox.text = getNameFromAddress(gta_frm1.inputbox.text, true, true)
      end
    end
    if gta_frm1.offset_checkbox.state == cbUnchecked then
      gta_frm1.inputbox.text = initial_input
    end
  end

  gta_frm1.mn_tt11.OnClick=function()
    if gta_frm1.offset_checkbox.state==0 then
      gta_frm1.offset_checkbox.state=1
    else
      gta_frm1.offset_checkbox.state=0
    end
  end

gt_addr1.showModal()

end

go_to_address()
--############################################################################--
--############################################################################--



ek1.PNG
 Description:
 Filesize:  15.39 KB
 Viewed:  3774 Time(s)

ek1.PNG



_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Game Hacking Dojo
Master Cheater
Reputation: 1

Joined: 17 Sep 2023
Posts: 250

PostPosted: Thu Oct 10, 2024 1:53 pm    Post subject: Reply with quote

That's cool. Thank you for the insight )
I'll try to understand what's going on here

But also I'm looking for a way to disable the original hotkey "Ctrl+G" so I could use the same one for my box

I've used:
Code:
getMemoryViewForm().Gotoaddress1.ShortCut = ""   --didn't help destroying the hotkey
getMemoryViewForm().Gotoaddress1.destroy()
getMemoryViewForm().Goto1.ShortCut = ""   --didn't help destroying the hotkey
getMemoryViewForm().Goto1.destroy()


I don't know what to do and I have to do it
Back to top
View user's profile Send private message Visit poster's website
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1528

PostPosted: Thu Oct 10, 2024 2:57 pm    Post subject: Reply with quote

Code:
function go_to_address()
print("hello")
end

mv_dppm = getMemoryViewForm().DisassemblerView.PopupMenu.Items --.[0] --.DoClick()

mv_dppm[0].Shortcut = "Ctrl+G"

mv_dppm[0].OnClick=function()
 go_to_address()
end

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Game Hacking Dojo
Master Cheater
Reputation: 1

Joined: 17 Sep 2023
Posts: 250

PostPosted: Thu Oct 10, 2024 3:24 pm    Post subject: Reply with quote

Thank you I made it ))
This was my approach to a sustainable script

Code:
for i = 0, getMemoryViewForm().DisassemblerView.PopupMenu.items.count - 1 do
   local item = getMemoryViewForm().DisassemblerView.PopupMenu.items[i]
   if item.name == "Gotoaddress1" then item.OnClick = function() go_to_address("disassembler") end end
end

for i = 0, getMemoryViewForm().HexadecimalView.PopupMenu.items.count - 1 do
   local item = getMemoryViewForm().HexadecimalView.PopupMenu.items[i]
   if item.name == "Goto1" then item.OnClick = function() go_to_address("memory_view") end end
end
Back to top
View user's profile Send private message Visit poster's website
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