|
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: 1668
|
Posted: Fri Oct 02, 2020 5:38 am Post subject: Copy To And Paste From Clipboard (Bitmap / Picture) |
|
|
For text is easy, but as the subject. How to do it in CE Lua?.
Of course there are several tricks.
1. Save the bitmap / picture as a temporary file and the load it, then destroy the temporary file, but that means not using clipboard at all.
2. Using winapi
3. Convert the image to base64, writeToClipboard and load and corvert back from bas64 to image.
4. Other ways
But, how do this in possible simple way by using the clipboard like copy paste text to clipboard?
example (for text)
Code: | -- on CE Instance 1
x = 'hello word'
writeToClipboard(x)
-- on CE Instance 2
UDF1.CELabel1.Caption = readFromClipboard()
|
So, how with the bitmap/image?
And also how to check the clipboard data format?.
i.e :
winapi: IsClipboardFormatAvailable(2)<>0 -- 2 = bmp, 14 = jpeg, etc
or
lazarus / delphi:
Clipboard.HasFormat(PredefinedClipboardFormat(pcfDelphiBitmap))
or
Clipboard.HasFormat(PredefinedClipboardFormat(pcfBitmap))
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 34
Joined: 16 Feb 2017 Posts: 1432
|
Posted: Fri Oct 02, 2020 10:23 am Post subject: |
|
|
If you can't find the solution for Copy - Paste,
You can edit an alternative old code.
Code: |
--Set the save folder path.
local sf = TrainerOrigin or getMainForm()
path = (sf.."\\Save Picture\\")
--You can create a folder for recording.
function FolderPath()
path= os.execute([[mkdir "]]..TrainerOrigin..[[\Save Picture"]])
end
btn3.onClick = function()
picture1 = Image2.Picture
if path then
FolderPath()
picture1.saveToFile(path.."Pic1.jpeg")
sleep(200)
local answer = messageDialog("Open folder after recording?", mtWarning, mbYes, mbNo)
if answer == mrYes then
shellExecute(path)
end
end
end |
_________________
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Sat Oct 03, 2020 1:01 am Post subject: |
|
|
Thanks for suggestion. I already have to save, open and assign the image to another image function. What I need is something like, you select image bitmap from canvas and 'Copy' to clipboard, next go to another image processing (i.e msPaint) and there you just need press ctrl+V or click the 'paste' button, vise versa.
I try to create a basic paint app, using CE Lua Script, event I already have more complex paint app created using other programming language.
I want this CE basic app, have abilities to copy current project to Window clipboard and also get a bitmap from the window clipboard to current project.
I'm doing this 'thing', just for fun and learning purposes to prove that CE able to do this 'thing'.
So, for copy paste the image/bitmap, I try use winapi lib, but still I am not find yet how to handle "SetClipboardData(uformat, handleMemory)". Here the script I tried:
Code: | function OpenClipboard(hwnd)
return executeCodeLocalEx("user32.OpenClipboard", hwnd)
end
function CloseClipboard()
return executeCodeLocalEx("user32.CloseClipboard")
end
function EmptyClipboard()
return executeCodeLocalEx("user32.EmptyClipboard")
end
function SetClipboardData(uFormat, hMem)
return executeCodeLocalEx("user32.SetClipboardData", uFormat, hMem)
end
function GetClipboardData(uFormat)
return executeCodeLocalEx("user32.GetClipboardData", uFormat)
end
function GlobalAlloc(flags, size)
return executeCodeLocalEx("kernel32.GlobalAlloc", flags, size)
end
function GlobalLock(handle)
return executeCodeLocalEx("kernel32.GlobalLock", handle)
end
function GlobalUnlock(hMem)
return executeCodeLocalEx("kernel32.GlobalUnlock", hMem)
end
function copyBitmapToClipboard(frm, src)
local CF_BITMAP = 2
local hReturn, hMem, pMem
OpenClipboard(frm.Handle)
EmptyClipboard()
--------------- NEED TO HANDLE -------------------
-- define struct handle for src (bitmap info) here
-- alloc mem here
-- lock mem here
--------------------------------------------------
hReturn = SetClipboardData(CF_BITMAP, src)
CloseClipboard()
if hReturn ~= 0 then
src.Destroy()
end
end
------------------------------------------------------------------------------
GMEM_SHARE = 0x2000
GMEM_MOVEABLE = 0x2
GMEM_ZEROINIT = 0x40
FOR_CLIPBOARD = GMEM_MOVEABLE or GMEM_SHARE or GMEM_ZEROINIT
if f then f.Destroy() end
f = createForm()
f.Height = 150
f.Width = 350
f.Position = 'poScreenCenter'
MyCanvas = createPaintBox(f)
MyCanvas.Left = 0
MyCanvas.Top = 0
MyCanvas.Height = 150
MyCanvas.Width = 150
MyCanvas.ParentColor = false
if paintbmp ~= nil then paintbmp.Destroy() end
paintbmp = createBitmap(self)
paintbmp.PixelFormat = pf32bit
paintbmp.Width = getScreenWidth()
paintbmp.Height = getScreenHeight()
paintbmp.Canvas.FillRect(0,0, paintbmp.Width, paintbmp.Height)
paintbmp.Canvas.Brush.Style = 0
MyCanvas.Canvas.Brush.Style = 0
MyCanvas.Width = paintbmp.Width
MyCanvas.Height = paintbmp.Height
paintbmp.LoadFromFile('D:\\test.bmp')
MyCanvas.OnPaint = function()
MyCanvas.Canvas.Clear()
MyCanvas.Canvas.draw(0, 0, paintbmp)
end
f.show()
--- On other CE Instance, Window Paint, Photoshop, just need press paste or ctrl V
p=createImage(f2)
p.left = 200
p.setSize(140,140)
p.Picture = GetClipboardData(2) |
Maybe there are others simple way to do this. And also I am weak on AA script.
Any solutions?.
Description: |
|
Filesize: |
74.63 KB |
Viewed: |
2316 Time(s) |
|
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 34
Joined: 16 Feb 2017 Posts: 1432
|
Posted: Sat Oct 03, 2020 1:53 am Post subject: |
|
|
I guess I can't understand "executeCodeLocalEx ()".
But I see this;
Now "Cheat Engine" is used outside of its purpose and makes new coding.
And this; It softens the accusations against CE a little more.
It adds the ability to "blend different codes" to the user.
Maybe it triggers "coding desire and learning".
This fires CE on both the "Game Hack" and the "Global (Lua) coding" path.
DB realizes this and helps as much as possible.
As long as DB is alive, he wants to train more coders.
The future consists of codes and "1,0,1,0,1".
@Corroder makes a good archive of fun and coding examples you brought to CE.
I hope these contributions will help improve novices.
The fun must continue. The contribution of this to the future is obvious.
_________________
|
|
Back to top |
|
|
LeFiXER Grandmaster Cheater Supreme Reputation: 20
Joined: 02 Sep 2011 Posts: 1065 Location: 0x90
|
Posted: Fri Nov 29, 2024 1:13 pm Post subject: |
|
|
Did you ever find out anything more about copying the clipboard data to an image/picture component?
|
|
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
|
|