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 


About A FreeER Script tip
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
FIRESKY
Cheater
Reputation: 0

Joined: 01 Mar 2017
Posts: 34

PostPosted: Wed May 01, 2024 9:42 am    Post subject: About A FreeER Script tip Reply with quote

I was testing this script and although it seems to work well
but does not seem possible to change the Value while write on the EDIT BOX because the timer continues obviously to overwrites any typing on EDIT BOX.

The goal would be to write a currency on the Edit Box, the same one used to read the current value and while this is done the timer stops blocking the typing, then resumes normally when you are not writing on the Edit Box


Link to Freer Lua Script: https://forum.cheatengine.org/viewtopic.php?t=611067&sid=3ab79803af0462d5495921a8edd6574c

Quote:
FreeER
CODE:

function CETrainer_CEEdit1Enter(sender)
CEEdit1MR = AddressList.getMemoryRecordByDescription("Name of memory record")
if not CEEdit1MR then print("Failed to find memory record for CEEdit1MR")
else
CEEdit1UpdateTimer = createTimer()
CEEdit1UpdateTimer.Interval = 1000 -- update once a second
CEEdit1UpdateTimer.OnTimer = function(t)
CETrainer.CEEdit1.Text = CEEdit1MR.Value
end

-- called when the user presses enter
CETrainer.CEEdit1.OnEnter = function(sender)
CEEdit1MR.Value = CETrainer.CEEditBox1.Text -- or sender.Text
end
end


Quote:
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 465

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

PostPosted: Wed May 01, 2024 12:40 pm    Post subject: Reply with quote

check if CETrainer.CEEdit1.focused is true, and if it is don't overwrite
_________________
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: 34

Joined: 16 Feb 2017
Posts: 1418

PostPosted: Wed May 01, 2024 1:05 pm    Post subject: Reply with quote

Try this; (For testing purposes.)

Before running the code, make sure there are 2 entries in the address list, as shown in the picture.
Or create two entries and write their descriptions in the relevant place in the code.
(For EdtAddr1 and EdtAddr2.)




Code:
if frm1 then frm1.Destroy() frm1=nil end
frm1=createForm()
frm1.Position="poDesktopCenter"

local CETrainer = {}

CETrainer.CEEdit1 = createEdit(frm1)
CETrainer.CEEdit1.Left=30 CETrainer.CEEdit1.Top=30

CETrainer.CEEdit2 = createEdit(frm1)
CETrainer.CEEdit2.Left=30 CETrainer.CEEdit2.Top=70

----------------- your gui --------------------

if EdtUpdTmr then EdtUpdTmr.Destroy() EdtUpdTmr=nil end
EdtUpdTmr=createTimer(MainForm)
EdtUpdTmr.Interval=1000
EdtUpdTmr.Enabled=false

getMemRecByDesc = getAddressList().getMemoryRecordByDescription
CheatEdt1=getMemRecByDesc("EdtAddr1")
CheatEdt2=getMemRecByDesc("EdtAddr2")

EdtUpdTmr.OnTimer=function()
CETrainer.CEEdit1.Text = CheatEdt1.Value
CETrainer.CEEdit2.Text = CheatEdt2.Value
end

CETrainer.CEEdit1.OnEditingDone=function(sender) -- click Enter
  if CETrainer.CEEdit1.Text~="" then
    CheatEdt1.Value = CETrainer.CEEdit1.Text
    EdtUpdTmr.Enabled=true
  end
end

CETrainer.CEEdit1.OnClick=function(sender)
EdtUpdTmr.Enabled=false
--print("click")
end

CETrainer.CEEdit2.OnEditingDone=function(sender) -- click Enter
  if CETrainer.CEEdit2.Text~="" then
    CheatEdt2.Value = CETrainer.CEEdit2.Text
    EdtUpdTmr.Enabled=true
  end
--print("done")
end

CETrainer.CEEdit2.OnClick=function(sender)
EdtUpdTmr.Enabled=false
--print("click")
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
FIRESKY
Cheater
Reputation: 0

Joined: 01 Mar 2017
Posts: 34

PostPosted: Wed May 01, 2024 1:15 pm    Post subject: Reply with quote

Quote:
Dark Byte



Im try About:


function CETrainer_CEEdit1Enter(sender)
CEEdit1MR = AddressList.getMemoryRecordByDescription("Name of memory record")
if not CEEdit1MR then print("Failed to find memory record for CEEdit1MR")
else
CEEdit1UpdateTimer = createTimer()
CEEdit1UpdateTimer.Interval = 1000 -- update once a second
CEEdit1UpdateTimer.OnTimer = function(t)
CETrainer.CEEdit1.Text = CEEdit1MR.Value

if CETrainer.ActiveControl.CEEdit1 == true then -----------------------> but think this statment don't work
CEEdit1UpdateTimer.Enabled=false
else
if CETrainer.ActiveControl.CEEdit1 == false then ---------------------->
CEEdit1UpdateTimer.Enabled=true
end
end
end


-- called when the user presses enter
CETrainer.CEEdit1.OnEnter = function(sender)
CEEdit1MR.Value = CETrainer.CEEditBox1.Text -- or sender.Text
end
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 34

Joined: 16 Feb 2017
Posts: 1418

PostPosted: Wed May 01, 2024 1:39 pm    Post subject: Reply with quote

Code:
function CETrainer_CEEdit1Enter(sender)
CEEdit1MR = AddressList.getMemoryRecordByDescription("Name of memory record")
if not CEEdit1MR then print("Failed to find memory record for CEEdit1MR")
else
CEEdit1UpdateTimer = createTimer()
CEEdit1UpdateTimer.Interval = 1000 -- update once a second
CEEdit1UpdateTimer.OnTimer = function(t)
CETrainer.CEEdit1.Text = CEEdit1MR.Value

if CETrainer.ActiveControl.CEEdit1 == true then -----------------------> but think this statment don't work
CEEdit1UpdateTimer.Enabled=false
else
if CETrainer.ActiveControl.CEEdit1 == false then ---------------------->
CEEdit1UpdateTimer.Enabled=true
end
end
end


The above code doesn't seem ok.
There are missing controls (end).

also try activecontrol like this:

Code:
if CETrainer.ActiveControl==CEEdit1 then

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

Joined: 01 Mar 2017
Posts: 34

PostPosted: Wed May 01, 2024 7:54 pm    Post subject: Reply with quote

Quote:
AylinCE
Dark Byte
Quote:
FreeER


Hey guys I'm trying to follow your advice on this FreeER script
but to no avail, so I was trying to tweak it a bit.

The script seems to work, however the problem remains, if I try to write to CEEDIT1 it is immediately overwritten by the timer,
I think I'm on the right track but something is missing....

Dark Byte suggested creating a focus on CEEDIT1, which is what I've been trying to do from the beginning but without success,
maybe I don't know how to write a statement based on the focus.

In any case, the idea would be more or less like this, or in any case a simple script like this,
So how should it be compiled correctly this FreeER script to block the timer only when I write on CEEDIT1?

PS: AylinCE i have try too your TIP: CETrainer.ActiveControl == CEEdit1 but nothing.

I also thought maybe I'm doing the wrong Event to link it to, now it's linked (OnEnter) but idk.



Code:
EDIT1_ON = 0

function EDITBOX1(sender)
CEEdit1MR = AddressList.getMemoryRecordByDescription("NAME MEM") ----> EVENT (OnEnter)
CEEdit1UpdateTimer = createTimer()
CEEdit1UpdateTimer.Interval = 1000 -- update once a second
CEEdit1UpdateTimer.OnTimer = function(t)
CETrainer.CEEdit1.Text = CEEdit1MR.Value
end

if EDIT1_ON == 1 then
t.Enabled=false
else
if CETrainer.ActiveControl == CEEdit1 then
--if CETrainer.CEEdit1.SetFocus() then -----------------> or ??? DARKBYTE TIPS ???  IDK about how write the focus statment.
EDIT1_ON = 1
else
if CETrainer.ActiveControl ~= CEEdit1 then
   --if CETrainer.CEEdit1.SetFocus() then -------------> or ??? DARKBYTE TIPS ???  IDK about how write the focus statment.
EDIT1_ON = 0
CETrainer.CEEdit1.OnEnter = function(TRY1)
CEEdit1MR.Value = CETrainer.CEEdit1.Text
end
end
end
end
EDIT1_ON = 0
end
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 34

Joined: 16 Feb 2017
Posts: 1418

PostPosted: Wed May 01, 2024 9:13 pm    Post subject: Reply with quote

You cannot follow this script.
The timer will never stop and will generate a new timer each time this code is referenced.
So it will continue writing to the "Editbox".
So the timer you want to stop will generate a question "Which one?"
Execute this code 5 times and you will generate 5 timers!

Code:
EDIT1_ON = 0

function EDITBOX1(sender)
CEEdit1MR = AddressList.getMemoryRecordByDescription("NAME MEM") ----> EVENT (OnEnter)
CEEdit1UpdateTimer = createTimer()
CEEdit1UpdateTimer.Interval = 1000 -- update once a second
CEEdit1UpdateTimer.OnTimer = function(t)
CETrainer.CEEdit1.Text = CEEdit1MR.Value
end

if EDIT1_ON == 1 then
t.Enabled=false
else
if CETrainer.ActiveControl == CEEdit1 then
--if CETrainer.CEEdit1.SetFocus() then -----------------> or ??? DARKBYTE TIPS ???  IDK about how write the focus statment.
EDIT1_ON = 1
else
if CETrainer.ActiveControl ~= CEEdit1 then
   --if CETrainer.CEEdit1.SetFocus() then -------------> or ??? DARKBYTE TIPS ???  IDK about how write the focus statment.
EDIT1_ON = 0
CETrainer.CEEdit1.OnEnter = function(TRY1)
CEEdit1MR.Value = CETrainer.CEEdit1.Text
end
end
end
end
EDIT1_ON = 0
end


I guess you didn't try the first code I gave you.

https://forum.cheatengine.org/viewtopic.php?p=5789403#5789403

What this code does:

1) A timer writes the relevant value to the "Edit_box" boxes.
2) Click on Edit_box and the timer will stop.
3) When you press the Enter key (while on Edit_box), it writes (Pushes) the value in Edit_box to the address value and the timer continues to run.

Click Edit_box to stop the timer. (Timer stop code is available in Edit_box.OnClick event.)

Press the "Enter" key to replace the value you wrote in the edit_box with the value in the address list. (This option is defined in the Edit_box.OnEditingDone function.)

Try the code, see the image in the relevant comment.
Then, let's make corrections on the current code, whatever you want.

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

Joined: 01 Mar 2017
Posts: 34

PostPosted: Thu May 02, 2024 12:34 pm    Post subject: Reply with quote

Hey AylinCE, But yes great! the script is certainly excellent with some modifications, honestly initially I thought it was something to be used exclusively with 2 CEEDIT.

Anyway, I was to search the correct lua form for this statments

in order to broaden the possibilities, but it seems that some statements are not fully considered probably because they were written incorrectly, I was looking for something like,


Code:
if CETrainer.ActiveControl==CEEdit1 then

if CETrainer.CEEdit1.ActiveControl == true then

if CETrainer.CEEdit1.focused == true then

if CETrainer.FocusCheck==CEEdit1 then

if CETrainer.bringToFront() then

if CETrainer.FormStyle='fsSystemStayOnTop' == true then



you know the correct write for this, or in any case something that provides the same statement to broaden the possibilities.
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 34

Joined: 16 Feb 2017
Posts: 1418

PostPosted: Thu May 02, 2024 1:15 pm    Post subject: Reply with quote

Try your questions on this form.
Don't forget; The name of this form is: "frm1", use your form name in your code.

Code:
if frm1 then frm1.Destroy() frm1=nil end
frm1=createForm()
frm1.Position="poDesktopCenter"

local CETrainer = {}

CETrainer.CEEdit1 = createEdit(frm1)
CETrainer.CEEdit1.Left=30 CETrainer.CEEdit1.Top=30

CETrainer.CEEdit2 = createEdit(frm1)
CETrainer.CEEdit2.Left=30 CETrainer.CEEdit2.Top=70

CETrainer.CEButton1 = createButton(frm1)
CETrainer.CEButton1.Left=130 CETrainer.CEButton1.Top=50
CETrainer.CEButton1.Caption="Focused"

CETrainer.CEButton2 = createButton(frm1)
CETrainer.CEButton2.Left=130 CETrainer.CEButton2.Top=120
CETrainer.CEButton2.Caption="Front"

CETrainer.Pnl1 = createPanel(frm1)
CETrainer.Pnl1.Left=20 CETrainer.Pnl1.Top=160
CETrainer.Pnl1.Color=0x00ff00

CETrainer.Pnl2 = createPanel(frm1)
CETrainer.Pnl2.Left=140 CETrainer.Pnl2.Top=160
CETrainer.Pnl2.Color=0x00ffff
----------------- your gui --------------------

CETrainer.CEEdit1.Text=11
CETrainer.CEEdit2.Text=12

--In your case try this:
--if CETrainer.ActiveControl==CEEdit2 then
-- CETrainer.ActiveControl=CEEdit1

CETrainer.CEButton1.OnClick=function()
 if CETrainer.ActiveControl==CETrainer.CEEdit2 then
   CETrainer.CEEdit1.setFocus()
   CETrainer.ActiveControl=CETrainer.CEEdit1
 else
   CETrainer.CEEdit2.setFocus()
   CETrainer.ActiveControl=CETrainer.CEEdit2
 end
end

local frontt = 2

CETrainer.CEButton2.OnClick=function() -- or sendToBack()
  if frontt==2 then
    CETrainer.Pnl1.BringToFront()
    frontt=1
  else
    CETrainer.Pnl2.BringToFront()
    frontt=2
  end
end

if frm1.FormStyle==fsSystemStayOnTop then -- your form: CETrainer.FormStyle
 print(1,frm1.FormStyle)
else
 print(2,frm1.FormStyle) -- my form (frm1=fsNormal) (default)
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
FIRESKY
Cheater
Reputation: 0

Joined: 01 Mar 2017
Posts: 34

PostPosted: Sat May 04, 2024 10:41 am    Post subject: Reply with quote

Hey
Quote:
AylinCE


I'll update you a bit on the result of your advice and the new experiments I was trying to integrate into your script, assuming that it already works correctly and I've found the correct forms for the statements, I haven't yet managed to find a correct formula to integrate with one statement that says:

- If the CETrainer is not in the foreground = Then the Timer MUST ENABLE (So it read the game)
- If the CETrainer is in the foreground = Then the Timer MUST DISABLE (So i can edit my value without worry about the timer overwriting it, although I can do it in other ways)
(Obviously to be integrated into your previous script).

The final aim would be to:
Have CEEDIT read the currency while the game is in focus / FOREGROUND

But if the CETRAINER is in the foreground then the timer is disabled, and therefore it is possible to write on the EDIT button.


Of course I have already done this through focus and correct statment, but I would now like to try to do it through a statment between CETTRAINER in FOREGROUND and CETRAINER NOT IN FOREGROUND.

So what already happens on CHEAT ENGINE with music came to mind, and its self-generated code which obviously works perfectly, and I thought, why not take it as a basis to integrate into our CEEDIT reading script.

Example:



-------------------------------------------------------------> EXEMPLE FORM A CODE AUTO GENERATED FROM CE ENGINE

Code:
XMFILE=findTableFile('TRAINER')
xmplayer.playXM(XMFILE)

function focusCheck(sender)
  if (CETrainer.isForegroundWindow(CETrainer)) then  ---------------> (This seems to be the part that indicates whether the TRAINER is in the foreground...
    if (xmplayer.isPlaying()==false) then ------------------------------> (But what would be the correct formula to tell him if he is NOT in the foreground? "if (CETrainer.isNotForegroundWindow(CETrainer))" or lol IDK)
      xmplayer.resume()
    end
  else
    if (xmplayer.isPlaying()) then
      xmplayer.pause()
    end
  end
end

focusTimer=createTimer(nil)
focusTimer.onTimer=focusCheck
focusTimer.Interval=250
focusTimer.Enabled=true






-----------------------------------------------------------> EXEMPLE WHAT I WAS TRY RIGHT NOW.

Code:
function focusCheck2(sender)  ----------------------------------------> (Also What Event Can Be Better?)
MEMTEST = getAddressList().getMemoryRecordByDescription
script1 = MEMTEST("BLA BLA")

if (CETrainer.isForegroundWindow(CETrainer)) then
if (TimerAA.Enabled()==false) then
TimerAA.Enabled()
end
else
if (TimerAA.Enabled()) then
TimerAA.Enabled()
end
end
end


TimerAA=createTimer(nil)
TimerAA.onTimer=focusCheck2
TimerAA.Interval=100
TimerAA.Enabled=true
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 34

Joined: 16 Feb 2017
Posts: 1418

PostPosted: Sat May 04, 2024 2:01 pm    Post subject: Reply with quote

Coding a window-oriented test:

If the focus is on the Trainer, the timer will stop, otherwise the timer will run.

Your timer for printing the value to "CEEdit1": TimerAA
Your function is: startMsg()

Code:
-- When the Lua Engine window opens, disable "Show on 'print'" and test with the Lua Engine window open.

local ctpid = 0
--Get the trainer window ID.
if ctpid==0 then ctpid = getForegroundProcess() end
print(ctpid)

if tmr22 then tmr22.Destroy() tmr22=nil end
tmr22=createTimer()
tmr22.Interval=1000
tmr22.Enabled=false

if TimerAA then TimerAA.Destroy() TimerAA=nil end
TimerAA=createTimer()
TimerAA.Interval=1000
TimerAA.Enabled=false

msgIndex = 0

function startMsg()
 msgIndex = tonumber(msgIndex) + 1
print(msgIndex)
end

function foregroundW1()
--print(ctpid)
    pd = getForegroundProcess()
    if tonumber(pd)==tonumber(ctpid) then
      TimerAA.Enabled=true
    else
     print("pd: "..pd.."  -  ctpid: "..ctpid)
     TimerAA.Enabled=false
    end
end

tmr22.OnTimer=function()
foregroundW1()
end

TimerAA.OnTimer=startMsg
tmr22.Enabled=true


With a shorter, single timer, your code would look like this:

With window focus;
Code:
local ctpid = 0
--Get the trainer window ID.
if ctpid==0 then ctpid = getForegroundProcess() end
--print(ctpid)

if TimerAA then TimerAA.Destroy() TimerAA=nil end
TimerAA=createTimer()
TimerAA.Interval=1000
TimerAA.Enabled=false

MEMTEST = getAddressList().getMemoryRecordByDescription
script1 = MEMTEST("BLA BLA")

function writeValueEdt1()
--print(ctpid)
    pd = getForegroundProcess()
    if tonumber(pd)~=tonumber(ctpid) then
     CETrainer.CEEdit1.Text=script1.Value
    end
end

TimerAA.OnTimer=writeValueEdt1
TimerAA.Enabled=true

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

Joined: 01 Mar 2017
Posts: 34

PostPosted: Sat May 04, 2024 4:16 pm    Post subject: Reply with quote

Great tip AylinCE, ll start right away by trying this one that seems right for me,
everything seems to work fine but when I go back to modify the CEEdit the timer still runs and doesn't allow me to write in the CEEDIT,

should I put it in some "EVENT"? I'm probably missing some information from you while I try this.

Also when you say with:
"With window focus;" What do you mean?



Code:
local ctpid = 0
--Get the trainer window ID.
if ctpid==0 then ctpid = getForegroundProcess() end
--print(ctpid)

if TimerAA then TimerAA.Destroy() TimerAA=nil end
TimerAA=createTimer()
TimerAA.Interval=1000
TimerAA.Enabled=false

MEMTEST = getAddressList().getMemoryRecordByDescription
script1 = MEMTEST("BLA BLA")

function writeValueEdt1()
--print("IS FOREGROUND") ---------------------------> Not Print (So not read if the CETrainer is s in BACKGROUND or FOREGROUND.
    pd = getForegroundProcess()
    if tonumber(pd)~=tonumber(ctpid) then
--print("NOT is FOREGROUND") ----------------------> Print only this. both if CETRAINER is in BACKGROUND or FOREGROUND, IDK.
     CETrainer.CEEdit1.Text=script1.Value
    end
end

TimerAA.OnTimer=writeValueEdt1
TimerAA.Enabled=true



PS: Running some tests with "PRINT" in CElua it would seem that it does not recognize when the CETTRAINER is in the foreground from when it is in the background, it PRINT only the part NOT is FOREGROUND.


Last edited by FIRESKY on Sat May 04, 2024 5:47 pm; edited 1 time in total
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 34

Joined: 16 Feb 2017
Posts: 1418

PostPosted: Sat May 04, 2024 5:46 pm    Post subject: Reply with quote

Code:
if frm1 then frm1.Destroy() frm1=nil end
frm1=createForm()
frm1.Position="poDesktopCenter"
frm1.Height=80
local CETrainer = {}

CETrainer.CEEdit1 = createEdit(frm1)
CETrainer.CEEdit1.Left=30 CETrainer.CEEdit1.Top=30

----------------- your gui --------------------

CETrainer.CEEdit1.Text=11

MEMTEST = getAddressList().getMemoryRecordByDescription
script1 = MEMTEST("BLA BLA")

CETrainer.CEEdit1.OnChange=function()
  if CETrainer.CEEdit1.Text~="" then
    script1.Value=CETrainer.CEEdit1.Text
  end
end

local ctpid = 0
--Get the trainer window ID.
if ctpid==0 then ctpid = getForegroundProcess() end
print(ctpid)

if TimerAA then TimerAA.Destroy() TimerAA=nil end
TimerAA=createTimer()
TimerAA.Interval=1000
TimerAA.Enabled=false

function writeValueEdt1()
--print(ctpid)
    pd = getForegroundProcess()
    if tonumber(pd)~=tonumber(ctpid) then
     CETrainer.CEEdit1.Text=script1.Value
    end
end

TimerAA.OnTimer=writeValueEdt1
TimerAA.Enabled=true




Use the above code in a standalone CE window as shown in the image and test the results.

When the script is activated, it takes the action of the window. (MainForm or CETrainer or UDF1)

Code:
if ctpid==0 then ctpid = getForegroundProcess() end


The scheduler will only stop writing the value from the address list to CEEdit if the MainForm or CETrainer or Form is in focus (i.e. the window is at the top):
Code:
function writeValueEdt1()
--print(ctpid)
    pd = getForegroundProcess()
    if tonumber(pd)~=tonumber(ctpid) then
     CETrainer.CEEdit1.Text=script1.Value
    end
end

.
This will allow you to write the new value to the address in the address list:
Code:
CETrainer.CEEdit1.OnChange=function()
  if CETrainer.CEEdit1.Text~="" then
    script1.Value=CETrainer.CEEdit1.Text
  end
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
FIRESKY
Cheater
Reputation: 0

Joined: 01 Mar 2017
Posts: 34

PostPosted: Sat May 04, 2024 6:58 pm    Post subject: Reply with quote

OMG AylinCE this all seems perfect! But just a doubt here:
The highlighted part actually changes the currency in play and seems to be essential because if I remove it then the timer continues to overwrite the CEEDIT.

Let me explain better, I just want to write in the CEEDIT but not for it to change the currency in the game,
this is because to do so I will use a separate button to do other things, which I wouldn't want to combine with this script if possible.

Basically I just want to be able to write without anything being modified in the game (At least until I execute the button in another function), everything else is perfect, but it would seem that this string is essential, so I can only write in edit without that this currency is modified in game?


CETrainer.CEEdit1.OnChange=function()
if CETrainer.CEEdit1.Text~="" then
script1.Value=CETrainer.CEEdit1.Text -------> (NOTE THIS STRING)
end
end


Another doubt arose in my mind, if the timer stops if I have the CETrainer in focus / in the foreground, and my game in windows mode in background, how does the timer overwrite the CEEDIT again if I remove this string
Code:
script1.Value=CETrainer.CEEdit1.Text
that modifies the code in game?

(Always obviously because I don't want the currency to be modified in game, but only written in edit with this part of the script).
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 34

Joined: 16 Feb 2017
Posts: 1418

PostPosted: Sun May 05, 2024 4:38 am    Post subject: Reply with quote

Now the script will change the value of the button.

And the timer is form-oriented.
When you get to the Trainer or CE the timer will stop.
If you switch to the game or notebook, the timer will continue to run.

Code:
if frm1 then frm1.Destroy() frm1=nil end
frm1=createForm()
frm1.Position="poDesktopCenter"
frm1.Height=80
local CETrainer = {}

CETrainer.CEEdit1 = createEdit(frm1)
CETrainer.CEEdit1.Left=30 CETrainer.CEEdit1.Top=30

CETrainer.CEButton1 = createButton(frm1)
CETrainer.CEButton1.Left=130 CETrainer.CEButton1.Top=29
CETrainer.CEButton1.Caption="Change"
----------------- your gui --------------------

CETrainer.CEEdit1.Text=11

MEMTEST = getAddressList().getMemoryRecordByDescription
script1 = MEMTEST("BLA BLA")

CETrainer.CEButton1.OnClick=function()
  if CETrainer.CEEdit1.Text~="" then
    script1.Value=CETrainer.CEEdit1.Text
  end
end

local ctpid = 0
--Get the trainer window ID.
if ctpid==0 then ctpid = getForegroundProcess() end
print(ctpid)

if TimerAA then TimerAA.Destroy() TimerAA=nil end
TimerAA=createTimer()
TimerAA.Interval=1000
TimerAA.Enabled=false

function writeValueEdt1()
--print(ctpid)
    pd = getForegroundProcess()
    if tonumber(pd)~=tonumber(ctpid) then
     CETrainer.CEEdit1.Text=script1.Value
    end
end

TimerAA.OnTimer=writeValueEdt1
TimerAA.Enabled=true

_________________
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
Goto page 1, 2  Next
Page 1 of 2

 
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