|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Fri Aug 19, 2022 8:08 pm Post subject: Create components using mix CE Lua script and win API. |
|
|
So, I try write script to make form (using CE Lua) and controls (Buttons using win API). But, I can't provide the correct way to make buttons click handler for the buttons created using 'createWindowEx'.
How to write CE Lua code to handle buttons click under function or procedure?.
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) |
Button click event (NOT FINISH)
Code: | --- THREAD
--- HOW TO HANDLE THIS PART FOR BUTTON CLICK
function WindProc(hwnd, wMsg, wParam, lParam)
if wMsg == WM_LBUTTONUP then
if lParam == hButton1 then
showMessage("Button was clicked!")
end
--WindProc = CallWindowProc(WndProcOld, hwnd, wMsg, wParam, lParam)
end
end
-- THIS PART DOESN'T WORK
function hButton1Click()
showMessage('You ate happy')
end
--hButton1.onClick = hButton1Click
-- |
I forgot this, same thread anyway:
https://www.cheatengine.org/forum/viewtopic.php?t=615443&sid=1b04415607e410b7d6e3b107629c20f9
Description: |
|
Filesize: |
18.22 KB |
Viewed: |
1290 Time(s) |
|
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25295 Location: The netherlands
|
Posted: Sat Aug 20, 2022 1:44 am Post subject: |
|
|
use a peekMessage loop
_________________
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 |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1257
|
Posted: Sat Aug 20, 2022 5:56 am Post subject: |
|
|
I will only give an idea that focuses on the result; I think of the effects function that customizes a "Panel". It will give the same result.
Because your project is a "Tutorial", I postpone my proposal.
Note: I can't be at my pc for 3 weeks and I can't test your code because I'm just following on the phone. I hope you get results.
_________________
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Sat Aug 20, 2022 10:23 pm Post subject: |
|
|
NVM, this is more easier using CE 7.4 Lua script
Code: | function createSpeedButton(Parent)
local b = createComponentClass('TSpeedButton', Parent)
b.Parent = Parent
return b
end
if f then f.destroy() end
f = createForm()
f.setSize(300,100)
f.Caption = 'Speed Button'
bmap = createImage(self)
bmap.Height = 24
bmap.Width = 24
bmap.Picture.loadFromStream(findTableFile('ok.png').Stream)
bmp = bmap.Picture.Bitmap
bBtn = createSpeedButton(f)
bBtn.Left = 40
bBtn.Top = 10
bBtn.Width = 100
bBtn.Height = 40
bBtn.Caption = 'Go'
bBtn.CanShowGlyph = true
bBtn.Glyph = bmp
function Button1Click(sender);
showMessage('Go...Clicked !!')
end;
f.show()
bBtn.onClick = Button1Click |
Description: |
|
Filesize: |
13.4 KB |
Viewed: |
1206 Time(s) |
|
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1257
|
Posted: Sun Aug 21, 2022 4:21 am Post subject: |
|
|
I think you can draw the control box @DB mentioned in the same way, give it a textOut (by putting a long and full box and a square empty box on top of it) and configure a table that creates its functions.
It could be something too complicated with the checkmark.
I still find "setWindowTheme" my favourite.
_________________
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1257
|
Posted: Sun Aug 21, 2022 10:50 am Post subject: |
|
|
Your ideas and solutions are always helpful.
Ok, hope you get a result.
_________________
|
|
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
|
|