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 


Transparent Form [Lua plugin]

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
mgr.inz.Player
I post too much
Reputation: 167

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sat Dec 26, 2015 1:05 pm    Post subject: Transparent Form [Lua plugin] This post has 1 review(s) Reply with quote

Something similar to
http://forum.cheatengine.org/viewtopic.php?t=558001

Usage:
Code:
UDF1.BorderStyle = 'bsNone'
UDF1.Visible=true
makeFormTransparent(UDF1)



Effect:

(I didn't have time to make better design)





Below code will add makeFormTransparent function. Tested with CE6.4.

Lua plugin source:
Code:
function makeFormTransparent(form)

  form.Color = 0xFFFFFF

  if cheatEngineIs64Bit() 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))

    autoAssemble(script,true)
  end
end



When you want to release a trainer (CT, CETRAINER, EXE) paste above script at the top.


Attached plugin and examples below:



transparent.lua
 Description:
plugin, paste it in autorun folder

Download
 Filename:  transparent.lua
 Filesize:  1.27 KB
 Downloaded:  609 Time(s)


makeFormTransparent - Full.CETRAINER
 Description:

Download
 Filename:  makeFormTransparent - Full.CETRAINER
 Filesize:  47.8 KB
 Downloaded:  733 Time(s)


makeFormTransparent - Full.CT
 Description:

Download
 Filename:  makeFormTransparent - Full.CT
 Filesize:  47.8 KB
 Downloaded:  911 Time(s)


makeFormTransparent.CETRAINER
 Description:
example (rely on autorun lua plugin)

Download
 Filename:  makeFormTransparent.CETRAINER
 Filesize:  46.53 KB
 Downloaded:  709 Time(s)


makeFormTransparent.CT
 Description:
example (rely on autorun lua plugin)

Download
 Filename:  makeFormTransparent.CT
 Filesize:  46.53 KB
 Downloaded:  892 Time(s)


_________________


Last edited by mgr.inz.Player on Sat Dec 26, 2015 1:25 pm; edited 3 times in total
Back to top
View user's profile Send private message MSN Messenger
lolAnonymous
Expert Cheater
Reputation: 1

Joined: 19 Jul 2015
Posts: 154

PostPosted: Sat Dec 26, 2015 1:21 pm    Post subject: Reply with quote

Thanks A lot bro love u Smile Wink
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 385

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

PostPosted: Sat Dec 26, 2015 3:00 pm    Post subject: Reply with quote

an alternate method is
formname.SetShape(bitmap)
where bitmap has the exact same dimensions as the form and contains an image of the visible parts of the form.
it's not as easy as one color being transparent though (but it's probably more compatible with future CE versions. E.g when there's a lcl library update)

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

Joined: 31 Aug 2013
Posts: 305

PostPosted: Sat Dec 26, 2015 7:54 pm    Post subject: Reply with quote

Very very thanks. Razz Very Happy
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 76

Joined: 29 Oct 2010
Posts: 3676

PostPosted: Sat Dec 26, 2015 9:22 pm    Post subject: Reply with quote

Good job, mgr.inz.Player.

Actually, .png file can work better for transparency, in lieu of using white background...but maybe it's because of photoshop:

White background:


Transparent background (png):


The labels do not show well with no background...this holds true, regardless of font face and font size. I wonder if it would be possible to eliminate the excess white fuzz around the text?

Also, I wonder if true transparency without forcing alphablend is possible?




In the example above, partial transparency of png image is recognized for the form after activating LUA and changing the ShowInTaskBar settings. The changes are not permanent, however, upon compiling of exe...just the result of some bug.

I wonder how you were able to eliminate the wide fuzz around your image?


Last edited by ++METHOS on Sat Dec 26, 2015 9:27 pm; edited 1 time in total
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 167

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sat Dec 26, 2015 9:26 pm    Post subject: Reply with quote

@Dark Byte, true. It can stop working.
Luckily, there's getCEVersion() function I can use for future CE versions.


Also, I made this patch (makes white color transparent):
http://pastebin.com/MRh8LiSS

If anyone wants to compile CE version with build-in TransparentNow().



@++METHOS, photoshop uses some kind of anti-aliasing.

You have to use, wait for it, Microsoft Paint Very Happy
Result saved as png file, without alpha channel.

_________________
Back to top
View user's profile Send private message MSN Messenger
++METHOS
I post too much
Reputation: 76

Joined: 29 Oct 2010
Posts: 3676

PostPosted: Sat Dec 26, 2015 11:29 pm    Post subject: Reply with quote

mgr.inz.Player wrote:
You have to use, wait for it, Microsoft Paint Very Happy

Shocked ...I will try it out. Very Happy

P.S. The example that you provided in the OP would've worked great for my double dragon trainer. Very Happy I would like to create a better interface when I have time. I think the transparency will be quite useful. Thanks!
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 167

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Wed Dec 30, 2015 4:33 pm    Post subject: Reply with quote

@++METHOS
Quote:
The labels do not show well with no background


For labels, you can use this:
Code:
UDF1.CELabel1.Font.Quality = 'fqNonAntialiased'



@ALL, update.

Slightly different FormLayeredAttributes function:
Code:
function FormLayeredAttributes(form,colorkey,alpha,flag)

  if form==nil then return false end

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

  if cheatEngineIs64Bit() 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,colorkey
    mov r8d,alpha
    mov r9d,flag
    call user32.SetLayeredWindowAttributes
    lea rsp,[rsp+40]
    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)
  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 flag
    push alpha
    push colorkey
    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





Code:
UDF1.BorderStyle = 'bsNone'
UDF1.Visible=true
UDF1.Color = 0xFFFFFF
UDF1.Constraints.MinWidth = UDF1.CEImage1.Width
UDF1.Constraints.MinHeight = UDF1.CEImage1.Height

FormLayeredAttributes(UDF1, UDF1.Color, 240, LWA_COLORKEY + LWA_ALPHA)



FormLayeredAttributes.CT
 Description:

Download
 Filename:  FormLayeredAttributes.CT
 Filesize:  48.48 KB
 Downloaded:  1021 Time(s)


_________________
Back to top
View user's profile Send private message MSN Messenger
Dark Byte
Site Admin
Reputation: 385

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

PostPosted: Sat Jan 02, 2016 5:58 pm    Post subject: Reply with quote

In 6.5 you can use formname.setLayeredAttributes(Color, Alpha, flags)
_________________
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
webcondepot
How do I cheat?
Reputation: 0

Joined: 23 Apr 2016
Posts: 3

PostPosted: Sat Apr 23, 2016 8:10 am    Post subject: How can i make red transparent Reply with quote

How can i make red transparent

Last edited by webcondepot on Sun Apr 24, 2016 4:58 am; edited 1 time in total
Back to top
View user's profile Send private message AIM Address
mgr.inz.Player
I post too much
Reputation: 167

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sat Apr 23, 2016 10:11 am    Post subject: Reply with quote

just use setLayeredAttributes method added in CE6.5

Like this:
Code:
formname.setLayeredAttributes(0x0000FF, 240, 3)



PS: Do not quote other people's whole post. Please edit your previous post.

_________________
Back to top
View user's profile Send private message MSN Messenger
webcondepot
How do I cheat?
Reputation: 0

Joined: 23 Apr 2016
Posts: 3

PostPosted: Sun Apr 24, 2016 5:18 am    Post subject: Reply with quote

mgr.inz.Player wrote:
just use setLayeredAttributes method added in CE6.5

Like this:
Code:
formname.setLayeredAttributes(0x0000FF, 240, 3)



PS: Do not quote other people's whole post. Please edit your previous post.


Not working bro.



2016-04-24 at 18-29-13.png
 Description:
 Filesize:  308.28 KB
 Viewed:  17153 Time(s)

2016-04-24 at 18-29-13.png


Back to top
View user's profile Send private message AIM Address
Aylin
Grandmaster Cheater
Reputation: 10

Joined: 16 Feb 2017
Posts: 643

PostPosted: Tue Jan 23, 2018 4:47 pm    Post subject: CheckBox Backgraund Transparent! Reply with quote

...

*********************************
This example worked nicely.
I created many transparent trainer.
But on some computers,
The CheckBox box is transparent and can not be enabled.
Is it possible to make an adjustment for this?
Thanks for sharing this fun.


Last edited by Aylin on Sat Sep 05, 2020 5:42 am; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
movss
Cheater
Reputation: 0

Joined: 10 Feb 2018
Posts: 38

PostPosted: Sat Feb 10, 2018 3:14 pm    Post subject: Reply with quote

tks ,,it's useful
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