|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
.lua Expert Cheater Reputation: 1
Joined: 13 Sep 2018 Posts: 189
|
Posted: Sat Dec 10, 2022 2:47 am Post subject: How to use API UpdateLayeredWindow |
|
|
How to use this API?
Description: |
|
Filesize: |
15.95 KB |
Viewed: |
1916 Time(s) |
|
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1257
|
|
Back to top |
|
|
.lua Expert Cheater Reputation: 1
Joined: 13 Sep 2018 Posts: 189
|
Posted: Sat Dec 10, 2022 4:49 am Post subject: |
|
|
I just don't understand the form of the parameter and how to write it in lua code
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1257
|
Posted: Sat Dec 10, 2022 11:44 am Post subject: |
|
|
It's an excerpt from @Corroder's code.
This can give you some usage ideas.
Code: | function GetModuleHandle(lpModuleName)
return executeCodeLocal("kernel32.GetModuleHandleA", lpModuleName)
end
function CreateWindow(oControl, oClass, oName, oHwnd, oDWStyle, nleft, ntop, nwidth, nheight)
return executeCodeLocalEx("user32.CreateWindowExA", 0, oClass, oName, oDWStyle, nleft, ntop, nwidth, nheight, oHwnd, 0, 0, 0)
end
function LoadIcon(hInstance, lpIconName)
return executeCodeLocalEx("user32.LoadIconA", lpIconName)
end
function _SendMessage(hWnd, Msg, wParam, lParam)
return executeCodeLocalEx("user32.SendMessageA",hWnd, Msg, wParam, lParam)
end
function LoadImage(hInst, lpszName, uType, cxDesired, cyDesired, fuLoad)
return executeCodeLocalEx("user32.LoadImageA", hInst, lpszName, uType, cxDesired, cyDesired, fuLoad)
end
function SetWindowLong(hWnd, nIndex, dwNewLong)
return executeCodeLocalEx("user32.SetWindowLongPtrA", hWnd, nIndex, dwNewLong)
end
function GetWindowLong(prmlngWindowHandle, prmlngIndex)
return executeCodeLocalEx("user32.GetWindowLongA", prmlngWindowHandle, prmlngIndex)
end
function CallWindowProc(hWnd, Msg, wParam, lParam)
return executeCodeLocalEx("user32.CallWindowProcA", lpPrevWndFunc, hWnd, Msg, wParam, lParam)
end
function RegisterClass(lpwcx)
return executeCodeLocalEx("user32.RegisterClassW", lpwcx)
end
function SetWindowLongW(hWnd, nIndex, dwCallBack)
return executeCodeLocalEx("user32.SetWindowLongW", hWnd, nIndex, dwCallBack)
end
function CallWindowProcW(wndproc, hWnd, Msg, wParam, lParam)
return executeCodeLocalEx("user32.CallWindowProcW", wndproc, hWnd, Msg, wParam, lParam)
end
--Window Style
WS_VISIBLE = 0x10000000
WS_BORDER = 0x00800000
WS_CHILD = 0x40000000
-- Window Message
WM_LBUTTONUP = 0x0202
WM_LBUTTONDOWN = 0x020
WM_COMMAND = 0x111
-- Button Style
BS_TEXT = 0x00000000
BS_BOTTOM = 0x00000800
BS_TOP = 0x00000400
BS_LEFT = 0x00000100
BS_RIGHT = 0x00000200
BM_SETIMAGE = 0xF7
BS_BITMAP = 0x00000080
BS_DEFPUSHBUTTON = 0x00000001
GWL_WNDPROC = -4
IMAGE_BITMAP = 0
IMAGE_ICON = 1
LR_LOADFROMFILE = 16
LR_DEFAULTCOLOR = 0x00000000
LR_CREATEDIBSECTION = 8192
LR_DEFAULTSIZE = 64
--------------------------------------------------------------------------------
if f then f.destroy() end
f = createForm()
f.Height = 70
f.Width = 230
f.Position = 'poScreenCenter'
f.Caption = 'Test Winapi'
f.Show()
local happy = 'f:\\happy.bmp'
local sad = 'f:\\sad.bmp'
local hButton1, hButton2
--local hInstance = GetModuleHandle(nil)
-- Create Happy Button
hButton1 = CreateWindow(0, "Button", "Happy", f.Handle, WS_VISIBLE + WS_BORDER + WS_CHILD | BS_TEXT | BS_BOTTOM,
10, 10, 100, 50, 10000, hInstance, 0)
hBitmap1 = LoadImage(hInstance, happy, IMAGE_BITMAP, 30, 30, LR_LOADFROMFILE | LR_DEFAULTCOLOR)
_SendMessage(hButton1, BM_SETIMAGE, IMAGE_BITMAP, hBitmap)
-- Create Sad Button
hInstance2 = GetModuleHandle(nil)
hButton2 = CreateWindow(0, "Button", "Sad", f.Handle, WS_VISIBLE + WS_BORDER + WS_CHILD | BS_TEXT | BS_TOP,
120, 10, 100, 50, 0, hInstance2, 0)
hBitmap2 = LoadImage(hInstance2, sad, IMAGE_BITMAP, 25, 25, LR_LOADFROMFILE | LR_DEFAULTCOLOR)
_SendMessage(hButton2, BM_SETIMAGE, IMAGE_BITMAP, hBitmap2) |
_________________
|
|
Back to top |
|
|
.lua Expert Cheater Reputation: 1
Joined: 13 Sep 2018 Posts: 189
|
Posted: Sat Dec 10, 2022 1:13 pm Post subject: |
|
|
AylinCE wrote: | It's an excerpt from @Corroder's code.
This can give you some usage ideas. |
The parameters in this API have pointer structure types, which I really don't understand
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1257
|
Posted: Sat Dec 10, 2022 3:12 pm Post subject: |
|
|
The examples found are to give you ideas.
CE lua activation and its APIs are examples that will enable you to use it.
The query you will find in CE Lua of the existing codes in your question (search the code below).
I think you'll be able to get somewhere with the examples above.
Good encodings.
Code: | executeCodeLocalEx() |
_________________
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25295 Location: The netherlands
|
Posted: Sat Dec 10, 2022 4:58 pm Post subject: |
|
|
for structure types you have to allocate memory inside CE and pass the address of that memory to the call
I prefer to use the MemoryStream object to allocate and fill it in, and then pass the .Memory property
Note 1: If something is optional, it can often get the value 0. Also for pointers to structures
Note 2: What specifically do you wish to do with UpdateLayeredWindow ? Perhaps form.setLayeredAttributes can already do what you wish ?
_________________
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 |
|
|
.lua Expert Cheater Reputation: 1
Joined: 13 Sep 2018 Posts: 189
|
Posted: Sat Dec 10, 2022 5:55 pm Post subject: |
|
|
Quote: | Note 2: What specifically do you wish to do with UpdateLayeredWindow ? Perhaps form.setLayeredAttributes can already do what you wish ? |
I want to implement an irregular form
For the function you encapsulate, it will cause aliasing around the form
Code: | form.setLayeredAttributes |
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25295 Location: The netherlands
|
Posted: Sat Dec 10, 2022 6:31 pm Post subject: |
|
|
I think the alliasing might be a result of the image editor you use
_________________
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 |
|
|
.lua Expert Cheater Reputation: 1
Joined: 13 Sep 2018 Posts: 189
|
Posted: Sun Dec 11, 2022 2:14 am Post subject: |
|
|
Dark Byte wrote: | I think the alliasing might be a result of the image editor you use |
I have also thought about using dwmapi, but it is not applicable to all Windows systems
Description: |
|
Filesize: |
397.44 KB |
Viewed: |
1765 Time(s) |
|
Description: |
|
Filesize: |
19.12 KB |
Viewed: |
1768 Time(s) |
|
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1257
|
Posted: Sun Dec 11, 2022 5:19 am Post subject: |
|
|
Here is an example. I guess this could be an idea too.
In the form close command, you can see the updated form attribute.
UDF1 may conflict with your original form. Open another CE and try the code on it. Otherwise it will kill your current form named UDF1.
Code: | ----------------------- Load Image Internet -----------------------
local ImgLink = [[https://i.hizliresim.com/i4aro3c.png]]
function loadImage(link)
int = getInternet()
local logostr=int.getURL(link)
int.destroy ()
local pict = createPicture()
local ss=createStringStream(logostr)
pict.loadFromStream(ss)
ss.destroy()
return pict
end
----------------------------- Form -------------------
if UDF1 then UDF1.Destroy() UDF1=nil end
UDF1=createForm()
UDF1.height=200 UDF1.width=200 UDF1.Position=poDesktopCenter
UDF1.PopupMode=0 UDF1.ShowInTaskBar="stAlways"
UDF1.BorderStyle=bsNone
UDF1.Color=0x000100 -- no black ..
-------------------------- Transparent ----------------------------
UDF1.setLayeredAttributes(0x000100, 255, LWA_COLORKEY | LWA_ALPHA )
-------------------------
local UDF_Tbl = {}
----------------------- UDF_Tbl.CEImage1 -----
UDF_Tbl.CEImage1=createImage(UDF1)
UDF_Tbl.CEImage1.height="200" UDF_Tbl.CEImage1.width="200" UDF_Tbl.CEImage1.left="0" UDF_Tbl.CEImage1.top="0"
UDF_Tbl.CEImage1.Stretch=true
UDF_Tbl.CEImage1.Picture = loadImage(ImgLink)
-----------------------
----------------------- UDF_Tbl.CELabel1 -----
UDF_Tbl.CELabel1=createLabel(UDF1)
UDF_Tbl.CELabel1.AutoSize=false
UDF_Tbl.CELabel1.height="35" UDF_Tbl.CELabel1.width="200" UDF_Tbl.CELabel1.left="0" UDF_Tbl.CELabel1.top="79"
UDF_Tbl.CELabel1.caption="Close"
UDF_Tbl.CELabel1.alignment="taCenter" UDF_Tbl.CELabel1.OptimalFill=true
UDF_Tbl.CELabel1.Enabled=true UDF_Tbl.CELabel1.FontStyle=fsBold UDF_Tbl.CELabel1.FontSize=20
-----------------------
------------------------- Load Table Images -----------------------
--UDF_Tbl.CEImage1.picture.loadFromStream(findTableFile("original200x200_119.png").stream) --.PNG .. .png ..?
-------------------------- drag form ------------------------------
UDF_Tbl.CEImage1.OnMouseDown=function() UDF1.DragNow() end
--------------- Close shadow Transparent Effect -------------------
if clsTim1 then clsTim1.Destroy() clsTim1=nil end
clsTim1=createTimer() clsTim1.Interval=30 clsTim1.Enabled=false
function clsTimTrn()
if clsTim1 then clsTim1.Destroy() clsTim1=nil end
UDF1.Destroy() -- form desing and no CE close..
-- closeCE()
--return cafree
end
local Attr = 255
clsTim1.OnTimer=function()
Attr = tonumber(Attr) - 5
UDF1.setLayeredAttributes(0x000100, Attr, LWA_COLORKEY | LWA_ALPHA )
if Attr==5 then
clsTimTrn()
end
end
UDF_Tbl.CELabel1.OnClick=function()
clsTim1.Enabled=true
end |
Description: |
|
Filesize: |
47.3 KB |
Viewed: |
1744 Time(s) |
|
_________________
|
|
Back to top |
|
|
.lua Expert Cheater Reputation: 1
Joined: 13 Sep 2018 Posts: 189
|
Posted: Sun Dec 11, 2022 7:15 am Post subject: |
|
|
AylinCE wrote: | Here is an example. I guess this could be an idea too.
In the form close command, you can see the updated form attribute.
UDF1 may conflict with your original form. Open another CE and try the code on it. Otherwise it will kill your current form named UDF1 |
Your code is very good, but the ultimate goal is to eliminate the surrounding aliasing, make it more smooth, and show shadows
So,it's not the best choice
Code: | UDF1.setLayeredAttributes()--imperfect |
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1257
|
Posted: Sun Dec 11, 2022 12:12 pm Post subject: |
|
|
Ha ha ha ..
Such questions have been asked before, the final result; "Windows Aero" features and PC settings.
https://tr.wikipedia.org/wiki/Windows_Aero
We're pushing too hard on this detail; The intended use of CE was only to provide a Form in which we could use and distribute our codes. A lot of customization (default or additional, fed with Lua codes) is the initiative of DB and enthusiast coders.
To say "This is flawed(!)" is to look too superficially.
What is it at fault? Even more so than what I said above.
According to Windows Aero, this is a "Defect" or problem that you will overcome!
I hope someone sees this and wants to help.
Maybe it will help us understand the difference between "This could happen too" and "Flawed".
I didn't give up, don't give up either.
_________________
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Mon Dec 12, 2022 8:18 pm Post subject: |
|
|
.lua wrote: |
I have also thought about using dwmapi, but it is not applicable to all Windows systems |
Refer to Microsoft, since Windows 7 / Vista, for higher version DWM composition always turn true / on, pfEnable no longer can set programmatically. But I don;t believe this. So, here is an example using DWN API DwmExtendFrameIntoClientArea function, work on Windows 8.1 using CE 7.4 (all 64 bits)
My questions, because I am noob in CE Lua regarding to create / populated a structure :
1. Example case :
Code: | Using : DWM API EnableBlurBehind function
The structure :
Constant DWM_BB_ENABLE; = 0x00000001
DWM_BLURBEHIND = {}
DWM_BLURBEHIND .dwFlags = DWM_BB_ENABLE;
DWM_BLURBEHIND .fEnable = true;
DWM_BLURBEHIND .hRgnBlur = nil
So, if use CreateMemoryStream() then
DWM_BLURBEHIND =createMemoryStream()
DWM_BLURBEHIND .writeDword(1) -- dwflags = DWM_BB_ENABLE, what is DWORD for 0x00000001, or using writeInteger or any else?
DWM_BLURBEHIND .writeDword(1) -- fEnable = true (boolean, 1 = true 0 = false)
DWM_BLURBEHIND . ???? -- .hRgnBlur = nil, how write this to memory stream ?
|
So if we understand about writing variables type to memory stream, then we can try to apply the method for some windows API functions.
2. How to write or read variables/structures with type pointer?
Meanwhile, here is example code using DWM API DwmExtendFrameIntoClientArea as mentioned above.
Code: | if f then f.destroy() end
f = createForm()
f.setSize(400,400)
f.BorderStyle = 'bsNone'
f.Color = 2392063
f.OnMouseDown = function() f.dragNow() end
p = createPanel(f)
p.setSize(250,250)
p.setPosition(75,75)
p.BorderStyle = 'bsNone'
p.Color = 0
img = createImage(p)
img.setSize(200,200)
img.setPosition(25,25)
img.stretch = true
img.Picture.loadFromStream(findTableFile('tiger.png').stream)
img.OnMouseDown = function() f.dragNow() end
lb = createLabel(f)
lb.setPosition(50,2)
lb.Font.Size = 36
lb.Font.Color = 0x0ff0ff
lb.Caption = 'Test dwmAPI'
function DwmExtendFrameIntoClientArea(hWnd, pMarInset)
-- pMarInset = margin top, left, right, bottom
return executeCodeLocalEx("dwmapi.DwmExtendFrameIntoClientArea", hWnd, pMarInset)
end
function DwmIsCompositionEnabled(en)
return executeCodeLocalEx("dwmapi.DwmIsCompositionEnabled",en)
end
function DwmEnableComposition(en)
return executeCodeLocalEx("dwmapi.DwmEnableComposition",en)
end
margins = createMemoryStream()
margins.writeDword(0) -- top
margins.writeDword(01) -- left
margins.writeDword(-10) -- right
margins.writeDword(-10) -- bottom
DwmEnableComposition(false)
DwmExtendFrameIntoClientArea(f.handle, margins.Memory)
f.show()
--- Check : https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmextendframeintoclientarea
--- Try change margins numbers
--- Tested on Windows 8.1 64 bit using CE 7.4 64 bit
|
Description: |
Test DWM API Extended Frame |
|
Filesize: |
93.64 KB |
Viewed: |
1643 Time(s) |
|
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
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
|
|