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 


Trainer demo in image png

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

Joined: 27 Jul 2016
Posts: 124

PostPosted: Tue Jan 23, 2018 6:42 am    Post subject: Trainer demo in image png Reply with quote

Hello.
I want product interface in image png Very Happy
Is there a way to help me do that?
Back to top
View user's profile Send private message
Sting9x
Expert Cheater
Reputation: 0

Joined: 27 Jul 2016
Posts: 124

PostPosted: Thu Jan 25, 2018 6:21 am    Post subject: Reply with quote

Help me please Sad
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Thu Jan 25, 2018 6:25 am    Post subject: Reply with quote

um... make your form transparent and use an image of your interface?
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Thu Jan 25, 2018 7:11 am    Post subject: Transparent PNG Reply with quote

FreeER wrote:
um... make your form transparent and use an image of your interface?


In this coding Form is transparent in white color.
How do we change this to pink instead of white?
White coincides with some keys.
For example, the CheckBox box is transparent and can not be activated.

Code:
function makeFormTransparent(form)

  if form==nil then return false end

  colorkey = colorkey or 0xFFFFFF
  alpha = alpha or 0xFF
  flag = flag or 1

  if cheatEngineIs64Bit()~=0 or cheatEngineIs32Bit() then

    handle = readQwordLocal(userDataToInteger(form)+0x538)

    script = [[
    alloc(thread,128)
    createthread(thread)
    thread:
    lea rsp,[rsp-40]
    mov rcx,handle
    mov edx,FFFFFFEC
    call user32.GetWindowLongA
    mov r8d,eax
    or r8d,00080000
    mov rcx,handle
    mov edx,FFFFFFEC
    call user32.SetWindowLongA
    mov rcx,handle
    mov edx,00FFFFFF  //color white
    mov r8d,000000FF
    mov r9d,00000001
    call user32.SetLayeredWindowAttributes
    lea rsp,[rsp+40]
    ret
    ]]

    script=script:gsub('handle', string.format('%X',handle))

    autoAssemble(script,true)
  else

    handle = bAnd( readQwordLocal(userDataToInteger(form)+0x330) , 0xFFFFFFFF)

    script = [[
    alloc(thread,128)
    createthread(thread)
    thread:

    push -14
    push handle
    call user32.GetWindowLongA
    or eax,80000
    push eax
    push -14
    push handle
    call user32.SetWindowLongA
    push 01
    push 000000FF
    push 00FFFFFF
    push handle
    call user32.SetLayeredWindowAttributes

    ret
    ]]

    script=script:gsub('handle', string.format('%X',handle)):gsub('colorkey', string.format('%X',colorkey))
    script=script:gsub('alpha', string.format('%X',alpha)):gsub('flag', string.format('%X',flag))
    autoAssemble(script,true)
  end
end

LWA_COLORKEY = 1
LWA_ALPHA = 2


White and Black colors overlap.
Could you please translate the encoding to the less frequently used one?
Thank you.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Thu Jan 25, 2018 8:48 am    Post subject: Reply with quote

This can be simplified a lot now since CE has support for setLayeredAttributes on WinControl objects (note win7 and earlier only support it on forms not other WinControl objects)

This seemed to work for me.
Code:
LWA_COLORKEY = 1
LWA_ALPHA = 2
function makeFormTransparent(form, colorkey, alpha, flag)
  -- make sure we have a valid form
  if form==nil or not f.className or f.className ~= 'TCEForm' then return false end
  -- set default values if not given
  colorkey = colorkey or 0x00FFFFFF
  alpha = alpha or 0xFF
  flag = flag or LWA_COLORKEY
  -- set attributes
  form.setLayeredAttributes(colorkey, alpha, flag)
end

function makeColor(r,g,b)
  local colorBitShiftRed = 0
  local colorBitShiftBlue = 16
  local colorBitShiftGreen = 8
  local function clamp(value, min, max) return math.min(math.max(value, min), max) end
  r = clamp(r, 0, 255);  g = clamp(g, 0, 255);  b = clamp(b, 0, 255);
  return (r << colorBitShiftRed) | (g << colorBitShiftGreen) | (b << colorBitShiftBlue)
end

-- example
local hotpink = makeColor(255,105,180)
local f = CETrainer -- your form name
f.Color = hotpink -- make sure the form actually has the same color
-- in case it was modified in the form editor and not in the code
makeFormTransparent(f, hotpink)


If you needed to use the AA scripts because you're in an older version of CE which doesn't support it then you'd replace the constant values in the script like "00FFFFFF //color white" with unique identifiers like "theColorKey" and use gsub eg. script=script:gsub('theColorKey', string.format('%X',colorkey)) (looks like someone intended to do that but didn't actually finish since it still has the constant values in the script(s) lol)
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Thu Jan 25, 2018 9:12 am    Post subject: Reply with quote

FreeER wrote:
This can be simplified a lot now since CE has support for setLayeredAttributes on WinControl objects (note win7 and earlier only support it on forms not other WinControl objects)

This seemed to work for me.
[code]LWA_COLORKEY = 1
LWA_ALPHA = 2
function makeFormTransparent(form, colorkey, alpha, flag)
-- make sure we have a valid form
if form==nil or not f.className or f.className ~= 'TCEForm' then return false end
-- set default values if not given
colorkey = colorkey or 0x00FFFFFF
alpha = alpha or 0xFF
flag = flag or LWA_COLORKEY
-- set attributes
form.setLayeredAttributes(colorkey, alpha, flag)
end

function makeColor(r,g,b)
local colorBitShiftRed = 0
local colorBitShiftBlue = 16
local colorBitShiftGreen = 8
local function clamp(value, min, max) return math.min(math.max(value, min), max) end
r = clamp(r, 0, 255); g = clamp(g, 0, 255); b = clamp(b, 0, 255);
return (r << colorBitShiftRed) | (g << colorBitShiftGreen) | (b << colorBitShiftBlue)
end



-- Test
myform = createForm()

local hotpink = makeColor(255,105,180)
local f = myform -- CETrainer -- your form name
f.Color = hotpink -- make sure the form actually has the same color
-- in case it was modified in the form editor and not in the code
makeFormTransparent(f, hotpink)

if form made by code then give : "Error:[string "myform = createForm()
..."]:7: attempt to index a nil value (global 'f')

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Thu Jan 25, 2018 9:16 am    Post subject: Reply with quote

ah, oops. I added an extra check to the makeFormTransparent function to make sure it was an actual form and used f rather than the form name it takes as an argument, which worked in my testing since I used the global variable f for testing Smile

full code and example:
Code:
LWA_COLORKEY = 1
LWA_ALPHA = 2
function makeFormTransparent(form, colorkey, alpha, flag)
-- make sure we have a valid form
if form==nil or not form.className or form.className ~= 'TCEForm' then return false end
-- set default values if not given
colorkey = colorkey or 0x00FFFFFF
alpha = alpha or 0xFF
flag = flag or LWA_COLORKEY
-- set attributes
form.setLayeredAttributes(colorkey, alpha, flag)
end

function makeColor(r,g,b)
local colorBitShiftRed = 0
local colorBitShiftBlue = 16
local colorBitShiftGreen = 8
local function clamp(value, min, max) return math.min(math.max(value, min), max) end
r = clamp(r, 0, 255); g = clamp(g, 0, 255); b = clamp(b, 0, 255);
return (r << colorBitShiftRed) | (g << colorBitShiftGreen) | (b << colorBitShiftBlue)
end


myform = createForm()

local hotpink = makeColor(255,105,180)
local f = myform -- CETrainer -- your form name
f.Color = hotpink -- make sure the form actually has the same color
-- in case it was modified in the form editor and not in the code
makeFormTransparent(f, hotpink)


edit: to make it a bit more generic for the verions/OSs that support more than forms you culd change the check from

Code:
-- make sure we have a valid form
if form==nil or not form.className or form.className ~= 'TCEForm' then
  return false
end
to
Code:
-- make sure we have a valid WinControl
if form==nil or not inheritsFromWinControl(form) then
  return false
end
Though in that case it should probably be renamed to something like makeWinControlTransparent rather than implying it only works for forms Smile
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Thu Jan 25, 2018 5:11 pm    Post subject: Thank you. Reply with quote

Thank you.
Thank you for your ideas.
The main color was white.
Now the main color is Blue (SkyBlue)
Here's the corrected code:

Code:
function makeFormTransparent(form)

  if form==nil then return false end

  colorkey = colorkey or 0xFFFFFF
  alpha = alpha or 0xFF
  flag = flag or 1

  if cheatEngineIs64Bit()~=0 or cheatEngineIs32Bit() then

    handle = readQwordLocal(userDataToInteger(form)+0x538)

    script = [[
    alloc(thread,128)
    createthread(thread)
    thread:
    lea rsp,[rsp-40]
    mov rcx,handle
    mov edx,FFFFFFEC
    call user32.GetWindowLongA
    mov r8d,eax
    or r8d,00080000
    mov rcx,handle
    mov edx,FFFFFFEC
    call user32.SetWindowLongA
    mov rcx,handle
    mov edx,87CEEB  //color white
    mov r8d,000000FF
    mov r9d,00000001
    call user32.SetLayeredWindowAttributes
    lea rsp,[rsp+40]
    ret
    ]]

    script=script:gsub('handle', string.format('%X',handle))

    autoAssemble(script,true)
  else

    handle = bAnd( readQwordLocal(userDataToInteger(form)+0x330) , 0xFFFFFFFF)

    script = [[
    alloc(thread,128)
    createthread(thread)
    thread:

    push -14
    push handle
    call user32.GetWindowLongA
    or eax,80000
    push eax
    push -14
    push handle
    call user32.SetWindowLongA
    push 01
    push 000000FF
    push 87CEEB
    push handle
    call user32.SetLayeredWindowAttributes

    ret
    ]]

    script=script:gsub('handle', string.format('%X',handle)):gsub('colorkey', string.format('%X',colorkey))
    script=script:gsub('alpha', string.format('%X',alpha)):gsub('flag', string.format('%X',flag))
    autoAssemble(script,true)
  end
end

LWA_COLORKEY = 1
LWA_ALPHA = 2


Added to the end of the form:

Code:
UDF1.BorderStyle = 'bsNone'
UDF1.Visible=true
UDF1.Color = 0x87CEEB
UDF1.Constraints.MinWidth = UDF1.CEImage1.Width
UDF1.Constraints.MinHeight = UDF1.CEImage1.Height
UDF1.setLayeredAttributes (0x0000FF, 240, 3)
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Thu Jan 25, 2018 5:50 pm    Post subject: Reply with quote

There's no white color in the code I gave unless you don't give it a color... so give it the color you want to change, I even provided a simple makeColor function.


and no, in my testing the checkbox won't turn pink/transparent.


https://www.dropbox.com/s/s6l8qc57wh3f3jg/test.CT?dl=0
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 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