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 


Form designer Top/Left properties

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Razi
Expert Cheater
Reputation: 1

Joined: 17 Jan 2018
Posts: 202

PostPosted: Fri Jan 26, 2024 5:52 pm    Post subject: Form designer Top/Left properties Reply with quote

Is it possible to add a function to the designer so that we can write in the Top/Left properties of the control element in the following format, for example: 189 - 47 or 189 + 47. In order not to count it in the mind.
Or is it possible to add a function so that we can write in the Top/Left properties in the designer in this format: top + 10 or x + 10? For example, when we select in the designer 50 controls on the form, with different Top value, and write in the Top property: top - 100 or x - 100,
to move all selected elements 100 pixels higher. This would significantly accelerate the work with the elements in the designer, if it is possible to add such function.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Sat Jan 27, 2024 5:20 am    Post subject: Reply with quote

i can look into it but it's a standard component. i think it's better to use the anchor editor and adjust the positions there. (border distance top and left)

your way doesn't work well with different DPI systems

_________________
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
AylinCE
Grandmaster Cheater Supreme
Reputation: 32

Joined: 16 Feb 2017
Posts: 1260

PostPosted: Sat Jan 27, 2024 3:33 pm    Post subject: Reply with quote

This code can create a menu for you to start with.
But to start creating button 1 and 2 functions, we will wait for @DarkByte to provide code example to process all selected items with a "for" loop.

If we can list all selected objects with the "for" loop, it will be easier to add calculations and change.
If this code is defined, we will ask @DarkByte for an example.

Note: I added the menu to LuaScript, you need to activate the menu every time you open the Form Designer.
Otherwise, Form Designer does not register a new menu.

Code:
function crtEdit11()
if toolEdt1 then toolEdt1.Destroy() end
if toolBtn1 then toolBtn1.Destroy() end
if toolBtn2 then toolBtn2.Destroy() end

cnt1 = MainForm.FormDesigner -- "ToolBar1" object select list bar!
cnt2 = MainForm.FormDesigner.ToolBar1

toolEdt1 = createEdit(cnt2)
toolEdt1.Width = 50
toolEdt1.Left = cnt2.Width - toolEdt1.Width

toolBtn1 = createButton(cnt2)
toolBtn1.Align = alNone
toolBtn1.AutoSize=false
toolBtn1.Width = 50
toolBtn1.Left = toolEdt1.Left + toolEdt1.Width + 10
toolBtn1.Height = 20
toolBtn1.Caption = "AllLeft"

toolBtn2 = createButton(cnt2)
toolBtn2.AutoSize=false
toolBtn2.Align = "alNone"
toolBtn2.Width = 50
toolBtn2.Left = toolBtn1.Left + toolBtn1.Width + 10
toolBtn2.Height = 20
toolBtn2.Caption = "AllTop"
end

--###########################################--

if childitem then childitem.Destroy() end

designmenuitem=MainForm.frmAutoInject.Menu.Items

childitem=createMenuItem(designmenuitem)
menuItem_setCaption(childitem,"AddDesignerEdit")

menuItem_add(designmenuitem, childitem)

loggmenuitem=createMenuItem(childitem)
menuItem_setCaption(loggmenuitem, "CreateLeftTopEdit")
menuItem_add(childitem, loggmenuitem)
menuItem_onClick(loggmenuitem, crtEdit11)

_________________
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
Razi
Expert Cheater
Reputation: 1

Joined: 17 Jan 2018
Posts: 202

PostPosted: Sat Jan 27, 2024 6:47 pm    Post subject: Reply with quote

Or maybe we can display in the designer by how many pixels we move the controls manually with the mouse? For example: When we drag selected controls in the designer using the mouse, display a label near the mouse pointer or selected controls, which will show how many pixels we move the controls from the current position. As a result, we will know exactly how many pixels we move the selected controls.
Also, if one control is selected, we can display by how many pixels we move the selected control and also display the new expected position of the control. For example: If the control is at position: Left: 132, Top: 170 and we drag the control 12 pixels to the left and 20 pixels to the top, then display in the label: x:-12, y:-20; Left:120, Top:150.
The same can be done when we place a control from the designer on the form. The label can display the coordinates where the control will be placed.


Last edited by Razi on Sun Jan 28, 2024 12:58 pm; edited 2 times in total
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 32

Joined: 16 Feb 2017
Posts: 1260

PostPosted: Sat Jan 27, 2024 10:28 pm    Post subject: Reply with quote

If the code below is activated from the Lua Script menu (Form Designer must be open.)
You can make the object it is on move up, down, left and right in one step with the mouse wheel forward-backward and Ctrl+Mouse Wheel movements.

Since moves are +1, it would be more descriptive to list 2 labels as Left and Top instead of 4 labels.

Of course, there is no need to select and click objects. Just hover the mouse arrow over it and move the wheel.

Code:
cnt1 = MainForm.FormDesigner -- "ToolBar1" object select list bar!
cnt2 = MainForm.FormDesigner.ToolBar1
--[[
Wheel forward: The object will go up.
Wheel back: The object will go down.
Ctrl + Wheel forward: The object will move to the right.
Ctrl + Wheel back: The object will move left.
]]
function crtEdit11()

if toolEdt1 then toolEdt1.Destroy() end
if toolTmr1 then toolTmr1.Destroy() end

toolEdt1 = createEdit(cnt2)
toolEdt1.Width = 120
toolEdt1.Left = cnt2.Width - toolEdt1.Width + 10

frmName11 = string.match(cnt1.Caption, ":(.*)")
loadstring([[cntForm11 = (]] .. frmName11 .. [[ or nil)]])()

toolTmr1=createTimer(MainForm)
toolTmr1.Interval=30
toolTmr1.Enabled=false

local cntrlName11 = ""
local cntrlCount11 = 0

function dragEffect11(name11)
     name11.OnMouseWheelDown=function()
      if isKeyPressed(VK_CONTROL) then
        name11.Left=tonumber(name11.Left) - 1
      else
        name11.Top=tonumber(name11.Top) + 1
      end
        toolEdt1.Text = name11.Name..": "..name11.Left.." / "..name11.Top
     end
     name11.OnMouseWheelUp=function()
      if isKeyPressed(VK_CONTROL) then
        name11.Left=tonumber(name11.Left) + 1
      else
        name11.Top=tonumber(name11.Top) - 1
      end
        toolEdt1.Text = name11.Name..": "..name11.Left.." / "..name11.Top
     end
end
function updateClk11()
cntrlCount11=cntForm11.ComponentCount

  for i = 0, cntForm11.ComponentCount - 1 do
    cntrlName11 = cntForm11.Component[i]
    print(cntrlName11.Name)
    dragEffect11(cntrlName11)
  end
end

function checkClk11()
cnt1 = MainForm.FormDesigner
frmName11 = string.match(cnt1.Caption, ":(.*)")
loadstring([[cntForm11 = (]] .. frmName11 .. [[ or nil)]])()
 CompCount = cntForm11.ComponentCount
 --print(CompCount)
 if tonumber(CompCount)>tonumber(cntrlCount11) then -- add list new object
  updateClk11()
 end
end

toolTmr1.OnTimer=checkClk11
toolTmr1.Enabled=true

end

--###########################################--

if childitem then childitem.Destroy() end

designmenuitem=MainForm.frmAutoInject.Menu.Items

childitem=createMenuItem(designmenuitem)
menuItem_setCaption(childitem,"AddDesignerEdit")

menuItem_add(designmenuitem, childitem)

loggmenuitem=createMenuItem(childitem)
menuItem_setCaption(loggmenuitem, "CreateLeftTopEdit")
menuItem_add(childitem, loggmenuitem)
menuItem_onClick(loggmenuitem, crtEdit11)

_________________
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
Razi
Expert Cheater
Reputation: 1

Joined: 17 Jan 2018
Posts: 202

PostPosted: Mon Jan 29, 2024 10:55 am    Post subject: Reply with quote

AylinCE wrote:
If the code below is activated from the Lua Script menu (Form Designer must be open.)
there is no need to select and click objects. Just hover the mouse arrow over it and move the wheel.

Sorry for late answer. The code shows an error when the designer is closed. And the code does not work when the mouse pointer is not over the control.
I did it like this, but the code does not work with controls without OnKeyPress event and writes numbers to the CEEdit, CEComboBox controls.
Code:
cnt1 = MainForm.FormDesigner -- "ToolBar1" object select list bar!
cnt2 = MainForm.FormDesigner.ToolBar1

function crtEdit11()

if toolEdt1 then toolEdt1.Destroy() end
if toolTmr1 then toolTmr1.Destroy() end

toolEdt1 = createEdit(cnt2)
toolEdt1.Width = 120
toolEdt1.Left = cnt2.Width - toolEdt1.Width + 10

frmName11 = string.match(cnt1.Caption, ":(.*)")
loadstring([[cntForm11 = (]] .. frmName11 .. [[ or nil)]])()

toolTmr1=createTimer(MainForm)
toolTmr1.Interval=500
toolTmr1.Enabled=false

local cntrlName11 = ""
local cntrlCount11 = 0

function dragEffect11(name11)
     name11.OnKeyPress=function(sender, key)
      if isKeyPressed(VK_NUMPAD8) then
        name11.Top=tonumber(name11.Top) - 10
      elseif isKeyPressed(VK_NUMPAD2) then
        name11.Top=tonumber(name11.Top) + 10
      elseif isKeyPressed(VK_NUMPAD4) then
        name11.Left=tonumber(name11.Left) - 10
      elseif isKeyPressed(VK_NUMPAD6) then
        name11.Left=tonumber(name11.Left) + 10
      end
        toolEdt1.Text = name11.Name..": "..name11.Left.." / "..name11.Top
     return key
     end
end

function updateClk11()
cntrlCount11=cntForm11.ComponentCount

  for i = 0, cntForm11.ComponentCount - 1 do
    cntrlName11 = cntForm11.Component[i]
    print(cntrlName11.Name)
    dragEffect11(cntrlName11)
  end
end

function checkClk11()
cnt1 = MainForm.FormDesigner
if cnt1 ~= nil then
frmName11 = string.match(cnt1.Caption, ":(.*)")
loadstring([[cntForm11 = (]] .. frmName11 .. [[ or nil)]])()
 CompCount = cntForm11.ComponentCount
 --print(CompCount)
 if tonumber(CompCount)>tonumber(cntrlCount11) then -- add list new object
  updateClk11()
 end
end
end

toolTmr1.OnTimer=checkClk11
toolTmr1.Enabled=true

end

if childitem then childitem.Destroy() end

designmenuitem=MainForm.frmAutoInject.Menu.Items

childitem=createMenuItem(designmenuitem)
menuItem_setCaption(childitem,"AddDesignerEdit")

menuItem_add(designmenuitem, childitem)

loggmenuitem=createMenuItem(childitem)
menuItem_setCaption(loggmenuitem, "CreateLeftTopEdit")
menuItem_add(childitem, loggmenuitem)
menuItem_onClick(loggmenuitem, crtEdit11)


If you put CELabel1 on the form UDF1, the following code will show the coordinates where the control will be placed.
Code:
t=createTimer(UDF1, true)
t.Interval=50
t.OnTimer=function()
local posx, posy = getMousePos()
UDF1_CELabel1.Caption = 'x:'..posx - UDF1.Left-4 ..', y:'..posy - UDF1.Top-30
end
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 32

Joined: 16 Feb 2017
Posts: 1260

PostPosted: Mon Jan 29, 2024 9:19 pm    Post subject: Reply with quote

The best way to select controls seems to be the mouse wheel.

And it is useful to use arrow signs to avoid printing unnecessary keystrokes (Number etc.).

Also, since the code is tied to a timer, code can be added to stop the timer when editing is finished.

Code:
local cnt1=""
local cnt2=""

function crtEdit11()

  if MainForm.FormDesigner==nil then
    showMessage("Open the Form Designer first!")
  else
    cnt1 = MainForm.FormDesigner
    cnt2 = MainForm.FormDesigner.ToolBar1

if toolEdt1 then toolEdt1.Destroy() end
if toolTmr1 then toolTmr1.Destroy() end

toolEdt1 = createEdit(cnt2)
toolEdt1.Width = 180
toolEdt1.Left = cnt2.Width - toolEdt1.Width + 10

frmName11 = string.match(cnt1.Caption, ":(.*)")
loadstring([[cntForm11 = (]] .. frmName11 .. [[ or nil)]])()

toolTmr1=createTimer(MainForm)
toolTmr1.Interval=50
toolTmr1.Enabled=false

local cntrlName11 = ""
local cntrlCount11 = 0
local name11 = ""

function dragEffect11()
   if name11~="" then
    --print("name11.Name: "..name11.Name)
      if isKeyPressed(VK_UP) then
        name11.Top=tonumber(name11.Top) - 1
      elseif isKeyPressed(VK_DOWN) then
        name11.Top=tonumber(name11.Top) + 1
      elseif isKeyPressed(VK_LEFT) then
        name11.Left=tonumber(name11.Left) - 1
      elseif isKeyPressed(VK_RIGHT) then
        name11.Left=tonumber(name11.Left) + 1
      end
        toolEdt1.Text = name11.Name..": "..name11.Left.." / "..name11.Top
   end
end

function downEffect11(name12)
local nm11 = ""
     name12.OnMouseWheelDown=function(sender)
    nm11 = name12
     name11 = nm11
     --print("name11: "..sender.Name)
     toolEdt1.Text = name11.Name..": "..name11.Left.." / "..name11.Top
    end
end

function updateClk11()
cntrlCount11=cntForm11.ComponentCount
  for i = 0, cntForm11.ComponentCount - 1 do
    cntrlName11 = cntForm11.Component[i]
    print(cntrlName11.Name)
    downEffect11(cntrlName11)
  end
end

function checkClk11()
cnt1 = MainForm.FormDesigner
if cnt1 ~= nil then
frmName11 = string.match(cnt1.Caption, ":(.*)")
loadstring([[cntForm11 = (]] .. frmName11 .. [[ or nil)]])()
 CompCount = cntForm11.ComponentCount
 --print(CompCount)
 if tonumber(CompCount)>tonumber(cntrlCount11) then -- add list new object
  updateClk11()
 else
   if name11=="" then updateClk11() name11=cntForm11 end
    dragEffect11()
 end
end
end

toolTmr1.OnTimer=checkClk11
toolTmr1.Enabled=true
  end
end

if childitem then childitem.Destroy() end

designmenuitem=MainForm.frmAutoInject.Menu.Items

childitem=createMenuItem(designmenuitem)
menuItem_setCaption(childitem,"AddDesignerEdit")

menuItem_add(designmenuitem, childitem)

loggmenuitem=createMenuItem(childitem)
menuItem_setCaption(loggmenuitem, "CreateLeftTopEdit")
menuItem_add(childitem, loggmenuitem)
menuItem_onClick(loggmenuitem, crtEdit11)

_________________
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
Razi
Expert Cheater
Reputation: 1

Joined: 17 Jan 2018
Posts: 202

PostPosted: Tue Jan 30, 2024 1:33 am    Post subject: Reply with quote

AylinCE wrote:
And it is useful to use arrow signs to avoid printing unnecessary keystrokes (Number etc.)

It's better now. What remains to be done is to be able to move several selected controls and to display how many pixels we have moved the selected controls.
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 32

Joined: 16 Feb 2017
Posts: 1260

PostPosted: Tue Jan 30, 2024 11:27 am    Post subject: Reply with quote

I still don't understand why the "x,y" instructions are necessary.
Ultimately, "Left and Top" reveals its place in the form.

Some usage ideas;
Drop a few complex objects into the form with the form designer.
Select them all with "Shift + Mouse Click".
Go back to the form designer and assign the numbers for "Height, Left, Top, and Width" to help you align them all at once.

Of course; If you are going to use the code below to edit objects other than the "Form Designer", forget my warnings and comments above.

Added: Move all.
Select multiple controls with Ctrl+Mouse Wheel and move all selected ones with arrow signs.
Also, if the form designer is closed, the move state is closed.

Code:
function crtEdit11()

  if MainForm.FormDesigner==nil then
    if toolTmr1 then toolTmr1.Destroy() end
    showMessage("Open the Form Designer first!")
  else
local cnt1=""
local cnt2=""
    cnt1 = MainForm.FormDesigner
    cnt2 = MainForm.FormDesigner.ToolBar1

if toolEdt1 then toolEdt1.Destroy() end
if toolTmr1 then toolTmr1.Destroy() end

toolEdt1 = createEdit(cnt2)
toolEdt1.Width = 180
toolEdt1.Left = cnt2.Width - toolEdt1.Width + 10

frmName11 = string.match(cnt1.Caption, ":(.*)")
loadstring([[cntForm11 = (]] .. frmName11 .. [[ or nil)]])()

toolTmr1=createTimer(MainForm)
toolTmr1.Interval=50
toolTmr1.Enabled=false

local cntrlName11 = ""
local cntrlCount11 = 0
local name11 = ""
local cntrTbl11 = {}

function tblClear(t)
 if type(t)=="table" then
   for i,k in pairs(t) do
     t[i] = nil
   end
 end
return t
end

function allTblMove(tbl,ops)
  for i,k in pairs(tbl) do
    sleep(100)
    if ops==1 then k.Top=tonumber(k.Top) - 1
     elseif ops==2 then k.Top=tonumber(k.Top) + 1
     elseif ops==3 then k.Left=tonumber(k.Left) - 1
     elseif ops==4 then k.Left=tonumber(k.Left) + 1
    end
     print("\n"..k.Name..".Left="..k.Left.."\n"..k.Name..".Top="..k.Top)
  end
end

function dragEffect11()
  if #cntrTbl11~=0 then
   if isKeyPressed(VK_UP) then
     allTblMove(cntrTbl11,1)
    elseif isKeyPressed(VK_DOWN) then
     allTblMove(cntrTbl11,2)
    elseif isKeyPressed(VK_LEFT) then
     allTblMove(cntrTbl11,3)
    elseif isKeyPressed(VK_RIGHT) then
     allTblMove(cntrTbl11,4)
   end
  else
   if name11~="" then
      if isKeyPressed(VK_UP) then
        name11.Top=tonumber(name11.Top) - 1
      elseif isKeyPressed(VK_DOWN) then
        name11.Top=tonumber(name11.Top) + 1
      elseif isKeyPressed(VK_LEFT) then
        name11.Left=tonumber(name11.Left) - 1
      elseif isKeyPressed(VK_RIGHT) then
        name11.Left=tonumber(name11.Left) + 1
      end
        toolEdt1.Text = name11.Name..": "..name11.Left.." / "..name11.Top
   end
  end
end

function downEffect11(name12)
local nm11 = ""
     name12.OnMouseWheelDown=function(sender)
      sleep(150)
      if isKeyPressed(VK_CONTROL) then
        cntrTbl11[#cntrTbl11 + 1] = name12
      else
       nm11 = name12
       name11 = nm11
       tblClear(cntrTbl11)
       toolEdt1.Text = name11.Name..": "..name11.Left.." / "..name11.Top
      end
    end
end

function updateClk11()
cntrlCount11=cntForm11.ComponentCount
  for i = 0, cntForm11.ComponentCount - 1 do
    cntrlName11 = cntForm11.Component[i]
    print(cntrlName11.Name)
    downEffect11(cntrlName11)
  end
end

function checkClk11()
cnt1 = MainForm.FormDesigner
if cnt1 ~= nil then
frmName11 = string.match(cnt1.Caption, ":(.*)")
loadstring([[cntForm11 = (]] .. frmName11 .. [[ or nil)]])()
 CompCount = cntForm11.ComponentCount
 --print(CompCount)
 if tonumber(CompCount)>tonumber(cntrlCount11) then -- add list new object
  updateClk11()
  tblClear(cntrTbl11)
 else
  if #cntrTbl11==0 then
   if name11=="" then updateClk11() name11=cntForm11 end
    dragEffect11()
  else
   name11=""
    dragEffect11()
  end
 end
end
end

toolTmr1.OnTimer=checkClk11
toolTmr1.Enabled=true
  end
end

if childitem then childitem.Destroy() end

designmenuitem=MainForm.frmAutoInject.Menu.Items

childitem=createMenuItem(designmenuitem)
menuItem_setCaption(childitem,"AddDesignerEdit")

menuItem_add(designmenuitem, childitem)

loggmenuitem=createMenuItem(childitem)
menuItem_setCaption(loggmenuitem, "CreateLeftTopEdit")
menuItem_add(childitem, loggmenuitem)
menuItem_onClick(loggmenuitem, crtEdit11)

_________________
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
Razi
Expert Cheater
Reputation: 1

Joined: 17 Jan 2018
Posts: 202

PostPosted: Wed Jan 31, 2024 12:16 pm    Post subject: Reply with quote

AylinCE wrote:
I still don't understand why the "x,y" instructions are necessary.
Ultimately, "Left and Top" reveals its place in the form.

It is not necessary, it is more informative.
The following code suits me. Thanks for the help.
Code:
local cnt1=""
local cnt2=""

function crtEdit11()

  if MainForm.FormDesigner==nil then
    showMessage("Open the Form Designer first!")
  else
    cnt1 = MainForm.FormDesigner
    cnt2 = MainForm.FormDesigner.ToolBar1

if toolEdt1 then toolEdt1.Destroy() end
if toolTmr1 then toolTmr1.Destroy() end

toolEdt1 = createEdit(cnt2)
toolEdt1.Width = 180
toolEdt1.Left = cnt2.Width - toolEdt1.Width + 10

frmName11 = string.match(cnt1.Caption, ":(.*)")
loadstring([[cntForm11 = (]] .. frmName11 .. [[ or nil)]])()

toolTmr1=createTimer(MainForm)
toolTmr1.Interval=500
toolTmr1.Enabled=false

local cntrlName11 = ""
local cntrlCount11 = 0
local name11 = ""

function downEffect11(name12)
local nm11 = ""
     name12.OnChangeBounds=function(sender)
     nm11 = name12
     name11 = nm11
     --print("name11: "..sender.Name)
     toolEdt1.Text = name11.Name..": "..name11.Left.." / "..name11.Top..' ('..name11.Left-posx..','..name11.Top-posy..')'
     posx=name11.Left
     posy=name11.Top
     end

    name12.OnEnter=function(sender)
    nm11 = name12
    name11 = nm11
    toolEdt1.Text = name11.Name..": "..name11.Left.." / "..name11.Top
    posx=name11.Left
    posy=name11.Top
    end
end

function updateClk11()
cntrlCount11=cntForm11.ComponentCount
  for i = 0, cntForm11.ComponentCount - 1 do
    cntrlName11 = cntForm11.Component[i]
    --print(cntrlName11.Name)
    downEffect11(cntrlName11)
  end
end

function checkClk11()
cnt1 = MainForm.FormDesigner
if cnt1 ~= nil then
frmName11 = string.match(cnt1.Caption, ":(.*)")
loadstring([[cntForm11 = (]] .. frmName11 .. [[ or nil)]])()
 CompCount = cntForm11.ComponentCount
 --print(CompCount)
 if tonumber(CompCount)>tonumber(cntrlCount11) then -- add list new object
  updateClk11()
 else
   if name11=="" then updateClk11() name11=cntForm11 end
 end
end
end

toolTmr1.OnTimer=checkClk11
toolTmr1.Enabled=true
  end
end

if childitem then childitem.Destroy() end

designmenuitem=MainForm.frmAutoInject.Menu.Items

childitem=createMenuItem(designmenuitem)
menuItem_setCaption(childitem,"AddDesignerEdit")

menuItem_add(designmenuitem, childitem)

loggmenuitem=createMenuItem(childitem)
menuItem_setCaption(loggmenuitem, "CreateLeftTopEdit")
menuItem_add(childitem, loggmenuitem)
menuItem_onClick(loggmenuitem, crtEdit11)
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 32

Joined: 16 Feb 2017
Posts: 1260

PostPosted: Sun Feb 04, 2024 1:20 pm    Post subject: Reply with quote

Probably "OnEnter" will provide you with missing control steps.
It will not work for controls such as "Panel", "Label".
"OnMouseWheelDown" seems to work better.

I also rearranged the "posx" and "posy" readers.
Now it is more efficient and if you select two controls consecutively, it is possible to see the "top" and "left" differences between them.

And it is still a project open to development.
Good luck.

Code:
local cnt1=""
local cnt2=""

function crtEdit11()

  if MainForm.FormDesigner==nil then
    showMessage("Open the Form Designer first!")
  else
    cnt1 = MainForm.FormDesigner
    cnt2 = MainForm.FormDesigner.ToolBar1

if toolEdt1 then toolEdt1.Destroy() end
if toolTmr1 then toolTmr1.Destroy() end

toolEdt1 = createEdit(cnt2)
toolEdt1.Width = 180
toolEdt1.Left = cnt2.Width - toolEdt1.Width + 10

frmName11 = string.match(cnt1.Caption, ":(.*)")
loadstring([[cntForm11 = (]] .. frmName11 .. [[ or nil)]])()

toolTmr1=createTimer(MainForm)
toolTmr1.Interval=100
toolTmr1.Enabled=false

local cntrlName11 = ""
local cntrlCount11 = 0
local name11 = ""
local posx=0
local posy=0

function dragEffect11()
   if name11~="" then
     sleep(100)
      if isKeyPressed(VK_UP) then
        name11.Top=tonumber(name11.Top) - 1
     toolEdt1.Text = name11.Name..": "..name11.Left.." / "..name11.Top..' ('..name11.Left-posx..','..name11.Top-posy..')'
      elseif isKeyPressed(VK_DOWN) then
        name11.Top=tonumber(name11.Top) + 1
     toolEdt1.Text = name11.Name..": "..name11.Left.." / "..name11.Top..' ('..name11.Left-posx..','..name11.Top-posy..')'
      elseif isKeyPressed(VK_LEFT) then
        name11.Left=tonumber(name11.Left) - 1
     toolEdt1.Text = name11.Name..": "..name11.Left.." / "..name11.Top..' ('..name11.Left-posx..','..name11.Top-posy..')'
      elseif isKeyPressed(VK_RIGHT) then
        name11.Left=tonumber(name11.Left) + 1
     toolEdt1.Text = name11.Name..": "..name11.Left.." / "..name11.Top..' ('..name11.Left-posx..','..name11.Top-posy..')'
      end
     --posx=name11.Left
     --posy=name11.Top
   end
end

function downEffect11(name12)
local nm11 = ""
     name12.OnChangeBounds=function(sender)
     local nm11 = name12
     name11 = nm11
     toolEdt1.Text = name11.Name..": "..name11.Left.." / "..name11.Top..' ('..name11.Left-posx..','..name11.Top-posy..')'

     end
    name12.OnMouseWheelDown=function(sender)
    --name12.OnEnter=function(sender)
    local nm11 = name12
    name11 = nm11
     toolEdt1.Text = name11.Name..": "..name11.Left.." / "..name11.Top..' ('..name11.Left-posx..','..name11.Top-posy..')'
       posx=name11.Left
       posy=name11.Top
    end
end

function updateClk11()
cntrlCount11=cntForm11.ComponentCount
  for i = 0, cntForm11.ComponentCount - 1 do
    cntrlName11 = cntForm11.Component[i]
    --print(cntrlName11.Name)
    downEffect11(cntrlName11)
  end
end

function checkClk11()
cnt1 = MainForm.FormDesigner
  if cnt1 ~= nil then
    frmName11 = string.match(cnt1.Caption, ":(.*)")
    loadstring([[cntForm11 = (]] .. frmName11 .. [[ or nil)]])()
     CompCount = cntForm11.ComponentCount
     --print(CompCount)
     if tonumber(CompCount)>tonumber(cntrlCount11) then -- add list new object
      updateClk11()
     end
       dragEffect11()
  else
      if toolTmr1 then toolTmr1.Destroy() end
  end
end

toolTmr1.OnTimer=checkClk11
toolTmr1.Enabled=true
  end
end

if childitem then childitem.Destroy() end

designmenuitem=MainForm.frmAutoInject.Menu.Items

childitem=createMenuItem(designmenuitem)
menuItem_setCaption(childitem,"AddDesignerEdit")

menuItem_add(designmenuitem, childitem)

loggmenuitem=createMenuItem(childitem)
menuItem_setCaption(loggmenuitem, "CreateLeftTopEdit")
menuItem_add(childitem, loggmenuitem)
menuItem_onClick(loggmenuitem, crtEdit11)

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