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 


Set Windows Wallpaper Via CE Game Trainer (Lua)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Extensions
View previous topic :: View next topic  
Author Message
Corroder
Grandmaster Cheater Supreme
Reputation: 31

Joined: 10 Apr 2015
Posts: 1146

PostPosted: Fri Mar 13, 2020 2:20 am    Post subject: Set Windows Wallpaper Via CE Game Trainer (Lua) Reply with quote

This just for have fun, how to set windows wallpaper the same as the CE Trainer background image using:

Code:
function setDeskWallpaper(filename)
  return executeCodeLocalEx('user32.SetDeskWallpaper',filename)
end


Complete example code:

Code:
--#Pictures table
img = {}
img[1] = 'https://wallpaperaccess.com/download/awesome-508415' -- Avengers
img[2] = 'https://wallpaperaccess.com/download/awesome-508255' -- Blue Robot
img[3] = 'https://wallpaperaccess.com/download/awesome-508374' -- City Mirror
img[4] = 'https://wallpaperaccess.com/download/pubg-4k-1133687' -- PUBG
img[5] = 'https://wallpaperaccess.com/download/rugby-1103840' -- Rugby
img[6] = 'https://c.wallhere.com/images/5d/9e/5b8d316d859a9050470899d03ee9-1738935.jpg!d' -- Sexy
img[7] = 'https://wallpaperaccess.com/download/awesome-232550' -- Tiger Face
img[8] = 'https://wallpaperaccess.com/download/bts-8329' -- BTS
pict = {'Avengers','Blue Robot','City Mirror','PUBG','Rugby','Sexy','Tiger Face', 'BTS'}

--#Game Trainer GUI
if form then form.destroy() end
form = createForm()
form.setSize(400,300)
form.borderStyle = 'bsSingle'
form.Position = 'poScreenCenter'
form.Color = 0
form.Caption = 'CRDR - Test Wallpaper'

panel1 = createPanel(form)
panel1.setPosition(0,0)
panel1.setSize(300,250)
panel1.BevelInner = 'bsNone'
panel1.BevelOuter = 'bsNone'
panel1.Color = 0

panel2 = createPanel(form)
panel2.setPosition(300,0)
panel2.setSize(100,250)
panel2.BevelInner = 'bsNone'
panel2.BevelOuter = 'bsNone'
panel2.Color = 0

button1 = createButton(form)
button1.setSize(100,30)
button1.setPosition(10,260)
button1.Caption = 'Set As Wallpaper'

image = createImage(panel1)
image.Align = 'alClient'
image.Stretch = true

combobox = createComboBox(panel2)
combobox.setPosition(10,10)
combobox.setSize(80,30)
combobox.Style = "csDropDownList"
combobox.ReadOnly = true
combobox.Items.Add('Pick image')
local items = combobox.Items
for i,v in ipairs(pict) do
  strings_add(items, v)
end

--#Events handler and functions
function setDeskWallpaper(filename)
  return executeCodeLocalEx('user32.SetDeskWallpaper',filename)
end

function createPictureFromURL(url)
 local http = getInternet()
 local file = http.getURL(url)
 http.destroy()
 local picture = createPicture()
 local stream = createStringStream(file)
 picture.loadFromStream(stream)
 return picture
end

function changeTrainerImage()
 local index = combobox.ItemIndex
-- index = img[index]
 if index == nil then
  index = 0
 else
  default_pic = createPictureFromURL(img[index])
  image.Picture = default_pic
 end
end

function cbboxOnChange()
  index = getProperty(cbbox, "ItemIndex")
  index = tbl_array[index]
  if index == nil then
    control_setCaption(edit1,"Pick an item")
  else
    control_setCaption(edit1, index.IdName)
  end
end

local path = TrainerOrigin or getMainForm()

function changeWallPaper()
 local wallpic = image.Picture
 wallpic.saveToFile(path..'//currentpict.jpg')
 setDeskWallpaper(path..'//currentpict.jpg')
end

function clearance()
 os.remove(path..'//currentpict.jpg')
 closeCE()
 return caFree
end

combobox.ItemIndex = 0
default_pic = createPictureFromURL(img[1])
image.Picture = default_pic

form.Show()
combobox.OnChange = changeTrainerImage
button1.OnClick = changeWallPaper
form.OnClose = clearance


In this sample, I use images that download from the internet. Of course you can change the scripts, so it use local images.

Demo video:
https://youtu.be/mSmgCXpGd74

Source CT file:
https://mega.nz/#!ml0DBbQY!5Y4b35KLvgPTTyHhL1W5NXXgxnTxShLBX1RgixJ5Jjo

Good luck



SetAsWallpaper.jpg
 Description:
 Filesize:  90.68 KB
 Viewed:  925 Time(s)

SetAsWallpaper.jpg



_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
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 Extensions 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