|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
ByTransient Expert Cheater Reputation: 5
Joined: 05 Sep 2020 Posts: 240
|
Posted: Fri Oct 30, 2020 8:06 am Post subject: |
|
|
This looks so cool.
Good job.
Thanks.
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Fri Oct 30, 2020 9:12 pm Post subject: |
|
|
Thank you
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
kucingkembar Advanced Cheater Reputation: 0
Joined: 08 Oct 2020 Posts: 71
|
Posted: Mon Nov 16, 2020 11:48 pm Post subject: |
|
|
Dear Corroder,
I just recently read this randomly,
sorry for the late reply
I just test it, and it works like the picture,
but how to edit the progress,
I tried
Code: | form1.mypb1.Position = 20 |
and the result
Code: | Error:[string "form1.mypb1.Position = 20
..."]:1: attempt to index a nil value (field 'mypb1') |
please guide me,
and thanks for the hardwork
|
|
Back to top |
|
|
ByTransient Expert Cheater Reputation: 5
Joined: 05 Sep 2020 Posts: 240
|
Posted: Tue Nov 17, 2020 4:10 am Post subject: |
|
|
There is no progress bar precision.
Works fine except for obvious shaking.
For use; Match "barIndex1" to something.
Sample; Like Code: | barIndex1 = aob.count | .
(Add the following usage below the existing code.)
Code: | form1.Show()
local barIndex1=0
mypb2 = createCustomProgressbar(form1, 10, 30, 480, 30, barIndex1, 'pbHorizontal', 13199821, 56556)
if t1 then t1.destroy() end
t1=createTimer() t1.Interval=100 t1.Enabled=false
form1.OnClick=function()
if t1.Enabled==false then
barIndex=0
t1.Enabled=true
else
t1.Enabled=false
end
end
t1.OnTimer=function()
barIndex=tonumber(barIndex) + 1
mypb2 = createCustomProgressbar(form1, 10, 30, 480, 30, barIndex, 'pbHorizontal', 13199821, 56556)
if barIndex==100 then
t1.Enabled=false
showMessage("Progress is complete.")
end
end |
Edit;
The reason for the shaking; We are constantly producing "ProgresBar".
@Corroder, you have to give "Position" manually.
Here is the edited example that works properly;
Code: | function createCustomProgressbar(pb, l, t, w, h, pos, orien, bkColor, barColor)
if pbtext then pbtext.destroy() pbtext=nil end
pbtext = createPaintBox(pb)
local hwnd
local WM_USER = 1024
local PBM_SETBARCOLOR = WM_USER + 9
local PBM_SETBKCOLOR = WM_USER + 7169
pb.setSize(w,h)
pb.Left = l
pb.Top = t
pb.Position = pos
pb.Min = 0
pb.Max = 100
pb.Orientation = orien
--pb.Parent = prnt
hwnd = pb.handle
executeCodeLocalEx('uxtheme.SetWindowTheme', hwnd, "", "")
SendMessage(hwnd, PBM_SETBARCOLOR, 0, bkColor)
SendMessage(hwnd, PBM_SETBKCOLOR, 0, barColor)
local percent = math.floor((pb.Position - pb.Min) / (pb.Max - pb.Min) * 100)
pbtext.Width = pb.Width
pbtext.Height = pb.Height
pbtext.OnPaint = function()
local px = (pbtext.Width - pbtext.Canvas.getTextWidth(tostring(percent))) / 2
local py = (pbtext.Height - pbtext.Canvas.getTextHeight(tostring(percent))) / 2
pbtext.Canvas.Brush.Style = 1
pbtext.Canvas.Pen.Color = 0xffffff
pbtext.Canvas.textOut(px,py, "")
pbtext.Canvas.textOut(px,py, tostring(percent.."%"))
end
end
--- example how to use
if form1 then form1.Destroy() end
form1 = createForm()
form1.setSize(500,450)
form1.Position = 'poScreenCenter'
form1.Caption = 'CE Custom Progressbar'
pb1 = createProgressBar(form1)
-- form name. left, top, width, height, position, orientation, bar color, back color
--mypb1 = createCustomProgressbar(form1, 10, 10, 480, 30, 30, 'pbHorizontal', 16758883, 56556)
--mypb3 = createCustomProgressbar(form1, 40, 120, 30, 300, 95, 'pbVertical', 5219839, 12453)
--mypb4 = createCustomProgressbar(form1, 150, 120, 70, 300, 70, 'pbVertical', 13457769, 13224397)
--mypb5 = createCustomProgressbar(form1, 250, 120, 70, 300, 65, 'pbVertical', 258562, 16777215)
form1.Show()
local barIndex1=0
createCustomProgressbar(pb1, 10, 30, 480, 30, barIndex1, 'pbHorizontal', 13199821, 56556)
if t1 then t1.destroy() end
t1=createTimer() t1.Interval=100 t1.Enabled=false
form1.OnClick=function()
if t1.Enabled==false then
t1.Enabled=true
if barIndex1==100 then
barIndex1=0 end
else
t1.Enabled=false
end
end
t1.OnTimer=function()
barIndex1=tonumber(barIndex1) + 1
createCustomProgressbar(pb1, 10, 30, 480, 30, barIndex1, 'pbHorizontal', 13199821, 56556)
if barIndex1==100 then
t1.Enabled=false
showMessage("Progress is complete.")
end
end |
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Tue Nov 17, 2020 5:38 am Post subject: |
|
|
you see that?.
Just say thank to '@by Transient' to answer and solve @kucingkembar question.
And this is actually how 'a programmer' think kind. Innovating and developing a source code become better one. Great!
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
kucingkembar Advanced Cheater Reputation: 0
Joined: 08 Oct 2020 Posts: 71
|
Posted: Tue Nov 17, 2020 11:08 am Post subject: |
|
|
thank you ByTransient and Corroder,
but can ask you 1 question:
it seems the ByTransient code is constant "createCustomProgressbar" @ interval=100 (0.1 second) , I don't see any destroying "CustomProgressbar" in the code, so I assume in 1 second the code create 10 "CustomProgressbar", I don't know how big each "CustomProgressbar" memory consumed, but will it create dozens of MB ram usage? if I using it for dozens of minutes?,
sorry for the silly question, and thanks for your both code
EDIT: Turn Out this code is "createPaintBox()",
so it does not consume another ram usage,
my current problem is how to destroy it?,
i can destroy the text using
Code: | if pbtext then pbtext.destroy() pbtext=nil end |
but how to destroy the progress bar?
|
|
Back to top |
|
|
ByTransient Expert Cheater Reputation: 5
Joined: 05 Sep 2020 Posts: 240
|
Posted: Tue Nov 17, 2020 12:06 pm Post subject: |
|
|
No.
Existing in the original code;
Code: | pb = createProgressBar(prnt)
pbtext = createPaintBox(pb) |
In the code I last edited, no more "create".
Code: | if pbtext then pbtext.destroy() pbtext=nil end
pbtext = createPaintBox(pb) |
Or, every time it is turned over, it kills what exists and starts it up again.
You also have time to rest the "Timer".
Code: | if barIndex1==100 then
t1.Enabled=false
showMessage("Progress is complete.") |
As a result;
No overlapping code inside "createCustomProgressbar ()".
My advice to you;
If you are worried about the memory load, kill "Timer" once in a while and start it again.
Also search for " ".
Edit;
Here is an addition for destruction;
Code: | if dest==false then
pbtext.destroy() pbtext=nil
pb.visible=false
end |
Usage in code;
Code: | function createCustomProgressbar(pb, l, t, w, h, pos, orien, bkColor, barColor, dest) --dest=destroy (true or false)
if pbtext then pbtext.destroy() pbtext=nil end
pbtext = createPaintBox(pb)
local hwnd
local WM_USER = 1024
local PBM_SETBARCOLOR = WM_USER + 9
local PBM_SETBKCOLOR = WM_USER + 7169
pb.setSize(w,h)
pb.Left = l
pb.Top = t
pb.Position = pos
pb.Min = 0
pb.Max = 100
pb.Orientation = orien
--pb.Parent = prnt
hwnd = pb.handle
executeCodeLocalEx('uxtheme.SetWindowTheme', hwnd, "", "")
SendMessage(hwnd, PBM_SETBARCOLOR, 0, bkColor)
SendMessage(hwnd, PBM_SETBKCOLOR, 0, barColor)
local percent = math.floor((pb.Position - pb.Min) / (pb.Max - pb.Min) * 100)
pbtext.Width = pb.Width
pbtext.Height = pb.Height
pbtext.OnPaint = function()
local px = (pbtext.Width - pbtext.Canvas.getTextWidth(tostring(percent))) / 2
local py = (pbtext.Height - pbtext.Canvas.getTextHeight(tostring(percent))) / 2
pbtext.Canvas.Brush.Style = 1
pbtext.Canvas.Pen.Color = 0xffffff
pbtext.Canvas.textOut(px,py, "")
pbtext.Canvas.textOut(px,py, tostring(percent.."%"))
end
--Progress destroy
if dest==false then
pbtext.destroy() pbtext=nil
pb.visible=false
end
end
--- example how to use
if form1 then form1.Destroy() end
form1 = createForm()
form1.setSize(500,450)
form1.Position = 'poScreenCenter'
form1.Caption = 'CE Custom Progressbar'
pb1 = createProgressBar(form1)
form1.Show()
local barIndex1=0
createCustomProgressbar(pb1, 10, 30, 480, 30, barIndex1, 'pbHorizontal', 13199821, 56556, true)
if t1 then t1.destroy() end
t1=createTimer() t1.Interval=100 t1.Enabled=false
form1.OnClick=function()
if t1.Enabled==false then
t1.Enabled=true
if barIndex1==100 then
barIndex1=0 end
else
t1.Enabled=false
end
end
t1.OnTimer=function()
barIndex1=tonumber(barIndex1) + 1
createCustomProgressbar(pb1, 10, 30, 480, 30, barIndex1, 'pbHorizontal', 13199821, 56556, true)
if barIndex1==100 then
t1.Enabled=false
showMessage("Progress is complete.")
--Progress destroy
createCustomProgressbar(pb1, 10, 30, 480, 30, barIndex1, 'pbHorizontal', 13199821, 56556, false)
end
end |
|
|
Back to top |
|
|
kucingkembar Advanced Cheater Reputation: 0
Joined: 08 Oct 2020 Posts: 71
|
Posted: Tue Nov 17, 2020 1:07 pm Post subject: |
|
|
thank you ByTransient, the code is work as you mentioned,
but when I create another progressbar
Code: |
createCustomProgressbar(pb1, 10, 30, 480, 30, barIndex1, 'pbHorizontal', 13199821, 56556, true)
createCustomProgressbar(pb2, 10, 60, 480, 30, barIndex1, 'pbHorizontal', 13199821, 56556, true)
|
and the result is:
Code: | Error:[string "function createCustomProgressbar(pb, l, t, w,..."]:9: attempt to index a nil value (local 'pb') |
sorry for another silly question, but what do i wrong?,
|
|
Back to top |
|
|
ByTransient Expert Cheater Reputation: 5
Joined: 05 Sep 2020 Posts: 240
|
Posted: Tue Nov 17, 2020 2:56 pm Post subject: |
|
|
Yes, "pbtext1 = createPaintBox (pb)" interrupts previous communication.
If you are using more than one ProgressBar at the same time, you should multiply the code as below.
createCustomProgressbar1 ..2 ..3 etc
and pbtext1 ..2 ..3 etc
Otherwise, stick to the first code if you are going to use it separately.
Code: | function createCustomProgressbar1(pb, l, t, w, h, pos, orien, bkColor, barColor, dest) --createCustomProgressbar1 ..2 ..3 etc
if pbtext1 then pbtext1.destroy() pbtext1=nil end
pbtext1 = createPaintBox(pb)
local hwnd
local WM_USER = 1024
local PBM_SETBARCOLOR = WM_USER + 9
local PBM_SETBKCOLOR = WM_USER + 7169
pb.setSize(w,h)
pb.Left = l
pb.Top = t
pb.Position = pos
pb.Min = 0
pb.Max = 100
pb.Orientation = orien
--pb.Parent = prnt
hwnd = pb.handle
executeCodeLocalEx('uxtheme.SetWindowTheme', hwnd, "", "")
SendMessage(hwnd, PBM_SETBARCOLOR, 0, bkColor)
SendMessage(hwnd, PBM_SETBKCOLOR, 0, barColor)
local percent = math.floor((pb.Position - pb.Min) / (pb.Max - pb.Min) * 100)
pbtext1.Width = pb.Width
pbtext1.Height = pb.Height
pbtext1.OnPaint = function()
local px = (pbtext1.Width - pbtext1.Canvas.getTextWidth(tostring(percent))) / 2
local py = (pbtext1.Height - pbtext1.Canvas.getTextHeight(tostring(percent))) / 2
pbtext1.Canvas.Brush.Style = 1
pbtext1.Canvas.Pen.Color = 0xffffff
pbtext1.Canvas.textOut(px,py, "")
pbtext1.Canvas.textOut(px,py, tostring(percent.."%"))
end
--Progress destroy
if dest==false then
pbtext1.destroy() pbtext1=nil
pb.visible=false
end
end |
Also for a second bar, you must create a second bar.
Code: | pb1 = createProgressBar(form1)
pb2 = createProgressBar(form1)
createCustomProgressbar(pb1, 10, 30, 480, 30, barIndex1, 'pbHorizontal', 13199821, 56556, true)
createCustomProgressbar1(pb2, 10, 80, 480, 30, barIndex1, 'pbHorizontal', 13199821, 56556, true) |
|
|
Back to top |
|
|
kucingkembar Advanced Cheater Reputation: 0
Joined: 08 Oct 2020 Posts: 71
|
Posted: Tue Nov 17, 2020 3:14 pm Post subject: |
|
|
thank you for the hard work, I hope I do not have any similar problem in the future, thank you again
|
|
Back to top |
|
|
kucingkembar Advanced Cheater Reputation: 0
Joined: 08 Oct 2020 Posts: 71
|
Posted: Wed Nov 18, 2020 11:53 am Post subject: |
|
|
about 12 hours ago, I like to upload the resulting picture, but it always timeout, now after 12 hours, it still has timeout when I upload it, so now I will not upload it
this code is the trimmed version of the Corroder code, and I modified it so it will not produce any garbage (i hope, I not that high-leveled programmer ), and I not good at explanation, just run the code so you can see the result:
Code: |
-- set new array: 1 Unique progress bar = 1 Unique text
pbtext = {}
--function to add text at progress bar
function ProgressBarText(ProgressBarName)
local percent = math.floor((ProgressBarName.Position - ProgressBarName.Min) / (ProgressBarName.Max - ProgressBarName.Min) * 100)
if pbtext[ProgressBarName] then pbtext[ProgressBarName].Destroy() end
pbtext[ProgressBarName] = createPaintBox(ProgressBarName)
pbtext[ProgressBarName].Width = ProgressBarName.Width
pbtext[ProgressBarName].Height = ProgressBarName.Height
pbtext[ProgressBarName].OnPaint = function()
px = (pbtext[ProgressBarName].Width - pbtext[ProgressBarName].Canvas.getTextWidth(tostring(percent))) / 2
py = (pbtext[ProgressBarName].Height - pbtext[ProgressBarName].Canvas.getTextHeight(tostring(percent))) / 2
pbtext[ProgressBarName].Canvas.Brush.Style = 1
pbtext[ProgressBarName].Canvas.Pen.Color = 0xffffff
pbtext[ProgressBarName].Canvas.textOut(px, py, tostring(percent .. "%"))
end
end
--function to change progress bar color
function ProgressBarColor(ProgressBarName, BarColor, BGColor)
executeCodeLocalEx("uxtheme.SetWindowTheme", ProgressBarName.handle, "", "")
SendMessage(ProgressBarName.handle, 1024 + 9, 0, BarColor)
SendMessage(ProgressBarName.handle, 1024 + 7169, 0, BGColor)
end
--function to destroy progress bar and their Text
function DestroyProgressBar(ProgressBarName)
if pbtext[ProgressBarName] then pbtext[ProgressBarName].Destroy() end
ProgressBarName.Destroy()
end
--- example how to use
if form1 then form1.Destroy() end
form1 = createForm()
form1.setSize(300, 40)
form1.Position = "poScreenCenter"
form1.Caption = "CE Custom Progressbar"
-- with change color
pb = createProgressBar(form1)
pb.Position = 0
pb.Width = 300
ProgressBarColor(pb, 16758883, 13199821)
ProgressBarText(pb)
-- without change color, the text and progress bar will be destroy after above progressbar (with change color) reach 100%
pb2 = createProgressBar(form1)
pb2.Position = 0
pb2.top = 20
pb2.Width = 300
ProgressBarText(pb2)
--timer start here
if t1 then t1.destroy() end
t1 = createTimer()
t1.Interval = 100
t1.Enabled = true
t1.OnTimer = function()
pb.Position = pb.Position + 2
ProgressBarText(pb)
pb2.Position = pb2.Position + 1
ProgressBarText(pb2)
if pb.Position >= 100 then
t1.Enabled = false
DestroyProgressBar(pb2)
showMessage("Progress is complete.")
end
end
|
anyway @Corroder how you determined the "bar color" and the "back color"?, is there any "calculator" or formula of it?
|
|
Back to top |
|
|
ByTransient Expert Cheater Reputation: 5
Joined: 05 Sep 2020 Posts: 240
|
|
Back to top |
|
|
kucingkembar Advanced Cheater Reputation: 0
Joined: 08 Oct 2020 Posts: 71
|
Posted: Wed Nov 18, 2020 12:34 pm Post subject: |
|
|
thanks for the reply ByTransient, but both links are dead, I just want to ask, I quite familiar with 0xZZYYXX (RBG or GBR), but this code (16777215) seems 8 digits, and do not contain any A-F character from hexadecimal, what this code called?
EDIT: Silly me, the code is the decimal version of hexadecimal, sorry
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Wed Nov 18, 2020 1:08 pm Post subject: |
|
|
I am use MS Access Color and the format is Decimal (integer).
Here the function to convert RGB color value to MS Access color value (decimal integer) in 256 window color system.
Example Color White:
in hex = 0xffffff
in RGB = 255,255,255
un Dec = 16777215
In MS Access Color (Dec)
Code: | function RGB2Dec(Red,Green,Blue)
local msaccess_color
if Red > 256 or Green > 256 or Blue > 256 then
msaccess_color = -1
else
msaccess_color = (Blue * 2 ^ 16) + (Green * 2 ^ 8) + Red
end
print(math.floor(msaccess_color))
end
RGB2Dec(255,255,255) -- white
-- result is 16777215 = white
RGB2Dec(0,128,0) -- green
-- result is 32768 = green
|
you can check here for the result is true or false : http://www.endprod.com/colors/
Ans just info, almost games using decimal code / ms access color code for the game system color, especially flash game.
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
kucingkembar Advanced Cheater Reputation: 0
Joined: 08 Oct 2020 Posts: 71
|
Posted: Wed Nov 18, 2020 1:53 pm Post subject: |
|
|
thank you Corroder for the color explanation and the code, I using it without any problem now
|
|
Back to top |
|
|
|
|
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
|
|