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 


Images slide with motion/ease with timer

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

Joined: 10 Apr 2015
Posts: 1348

PostPosted: Fri Jul 31, 2020 9:31 am    Post subject: Images slide with motion/ease with timer Reply with quote

How to create images (from array table, e.q. 20 indexes) slide left right using on click event on timer?.
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Aylin
Grandmaster Cheater
Reputation: 9

Joined: 16 Feb 2017
Posts: 595

PostPosted: Fri Jul 31, 2020 6:36 pm    Post subject: Reply with quote

This is probably not what you want.
But as far as I understand, I am sharing an idea.

Code:
if f then f.destroy() f = nil end

f=createForm() f.Position=poDesktopCenter f.Width=160 f.Height=220
f.caption="Example Slayt" f.BorderIcons="biSystemMenu"

local p1=createPanel(f)
p1.Height=120 p1.Width=120 p1.Left=20 p1.Top=20
local p2=createPanel(f) p2.Font.Size=8
p2.Height=25 p2.Width=50 p2.Left=20 p2.Top=150 p2.caption="<< Play"
local p3=createPanel(f) p3.Font.Size=8
p3.Height=25 p3.Width=50 p3.Left=90 p3.Top=150 p3.caption="Play >>"
local p4=createPanel(f)
p4.Height=25 p4.Width=120 p4.Left=20 p4.Top=185 p4.caption="Stop Slayt"

--i1.picture.loadFromStream(findTableFile("download.png").stream)
------------------
int = getInternet()
local img1=int.getURL("https://i.hizliresim.com/eHvUpd.png")
local img2=int.getURL("https://i.hizliresim.com/GUwjei.png")
local img3=int.getURL("https://i.hizliresim.com/gRDtXn.png")
int.destroy()
local ss=createStringStream(img1)
local ss1=createStringStream(img2)
local ss2=createStringStream(img3)
--------------------------
local i1 = createImage(p1)
i1.Height=100 i1.Width=100 i1.Top=10 i1.Stretch=true i1.visible=true
local i2 = createImage(p1)
i2.Height=100 i2.Width=100 i2.Top=10 i2.Stretch=true i2.visible=true
local i3 = createImage(p1)
i3.Height=100 i3.Width=100 i3.Top=10 i3.Stretch=true i3.visible=true

i1.Picture.loadFromStream(ss)
i2.Picture.loadFromStream(ss1)
i3.Picture.loadFromStream(ss2)
ss.destroy() ss1.destroy() ss2.destroy()

function imageLeft()
i1.Left=10 i2.Left=0 - 100 i3.Left=0 - 210 end
imageLeft()

function imageLeft1()
i1.Left=10 i3.Left=120 i2.Left=130 + 100 end

-----------------------------------
local targets=2
if pTimer then pTimer.destroy() end
local pTimer=createTimer(f) pTimer.Interval=100 pTimer.Enabled=false

pTimer.OnTimer=function()
if target==1 then
i1.left=tonumber(i1.left) - 5 if i1.left==0 - 210 then i1.left=120 end
i2.left=tonumber(i2.left) - 5 if i2.left==0 - 210 then i2.left=120 end
i3.left=tonumber(i3.left) - 5 if i3.left==0 - 210 then i3.left=120 end
end
if target==2 then
i1.left=tonumber(i1.left) + 5 if i1.left==230 then i1.left=0 - 100 end
i2.left=tonumber(i2.left) + 5 if i2.left==230 then i2.left=0 - 100 end
i3.left=tonumber(i3.left) + 5 if i3.left==230 then i3.left=0 - 100 end
end
end

p2.OnClick=function()
if pTimer.Enabled==false then
imageLeft1() end
pTimer.Enabled=false
target=1
pTimer.Enabled=true
end

p3.OnClick=function()
if pTimer.Enabled==false then
imageLeft() end
pTimer.Enabled=false
target=2
pTimer.Enabled=true
end

p4.OnClick=function()
pTimer.Enabled=false
end

_________________
Hi Hitler Take control of your trainer
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 33

Joined: 10 Apr 2015
Posts: 1348

PostPosted: Sat Aug 01, 2020 12:13 am    Post subject: Reply with quote

Thanks, @Aylin for the example, that very smart and almost touch what I need (for my experiment). Just need to pause the timer for every displayed images, mean one image full show and the timer set to false and set to true when user click on previous or next buttons. More easy to do this in C# or HTML, CSS or JS script.

Here my progress:

Code:
if f then f.Destroy() end
if t1 then t1.Destroy() end
if t2 then t2.Destroy() end

f = createForm()
f.setSize(500,400)
f.Position = 'poScreenCenter'
f.BorderStyle = 'bsSingle'
f.Caption = 'Test Image Slider'

bLeft = createButton(f)
bLeft.setSize(100,30)
bLeft.setPosition(140,360)
bLeft.Caption = 'Prev'

bRight = createButton(f)
bRight.setSize(100,30)
bRight.setPosition(bLeft.Left + bLeft.Width + 10,360)
bRight.Caption = 'Next'

--- create pictures image
img = {'_1.jpg', '_2.jpg', '_3.jpg', '_4.jpg'}
local pics = {}
local scrollspeed = 5
local x = 0

for i = 1, 4 do
 table.insert(pics, createImage(f))
end

for i = 1, #pics do
 pics[i].setSize(500,350)
 pics[i].Stretch = true
 pics[i].Picture.loadFromStream(findTableFile(img[i]).Stream)
 pics[i].Left = x
 x = x - 500
end


--- slide to right
function moveright()
 t1.enabled = true
end

local function slideRight()  --- I want make this part using loop
  x1,y1 = pics[1].getPosition()
  x1 = x1 + scrollspeed
  if x1 == 500 then
     pics[1].setPosition(-1500, y1)
     t1.enabled = false
  else
     pics[1].setPosition(x1, y1)
  end

  x1,y1 = pics[2].getPosition()
  x1 = x1 + scrollspeed
  if x1 == 500 then
     pics[2].setPosition(-1500, y1)
     t1.enabled = false
  else
     pics[2].setPosition(x1, y1)
  end

  x1,y1 = pics[3].getPosition()
  x1 = x1 + scrollspeed
  if x1 == 500 then
     pics[3].setPosition(-1500, y1)
     t1.enabled = false
  else
     pics[3].setPosition(x1, y1)
  end

  x1,y1 = pics[4].getPosition()
  x1 = x1 + scrollspeed
  if x1 == 500 then
     pics[4].setPosition(-1500, y1)
     t1.enabled = false
  else
     pics[4].setPosition(x1, y1)
  end
end

t1 = createTimer()
t1.Interval = 5
t1.Enabled = false
t1.OnTimer = slideRight

--- slide to left
function moveleft()
 t2.enabled = true
end

local function slideLeft()
 -- too lazy to do this part
end

t2 = createTimer()
t2.Interval = 5
t2.Enabled = false
t2.OnTimer = slideLeft

bRight.OnClick = moveright
bLeft.OnClick = moveleft



another version using AnimatedWindow user32.dll

Code:
if fm then fm.Destroy() fm = nil end

fm = createForm()
fm.setSize(300,300)
fm.BorderStyle = 'bsNone'
fm.Position = 'poScreenCenter'
fm.Color = 7368816 --6052956
fm.Caption = 'VCL - Terms Glossary'
fm.OnMouseDown = function() fm.DragNow() end

p1 = createPanel(fm)
p1.setSize(200,200)
p1.setPosition(50,50)
p1.BorderStyle = 'bsNone'

img1 = createImage(p1)
img1.setSize(200,200)
img1.setPosition(0,0)
img1.Stretch = true
img1.Picture.loadFromStream(findTableFile('_3.jpg').stream)

p2 = createPanel(fm)
p2.setSize(200,200)
p2.setPosition(50,50)
p2.BorderStyle = 'bsNone'

img2 = createImage(p2)
img2.setSize(200,200)
img2.setPosition(0,0)
img2.Stretch = true
img2.Picture.loadFromStream(findTableFile('_4.jpg').stream)

AnimateWindowFlags =
{
    AW_HOR_POSITIVE = 0x00000001,
    AW_HOR_NEGATIVE = 0x00000002,
    AW_VER_POSITIVE = 0x00000004,
    AW_VER_NEGATIVE = 0x00000008,
    AW_CENTER = 0x00000010,
    AW_HIDE = 0x00010000,
    AW_ACTIVATE = 0x00020000,
    AW_SLIDE = 0x00040000,
    AW_BLEND =0x00080000
}

function animatedObject(hwnd, time, AnimateWindowFlags)
  return executeCodeLocalEx('user32.AnimateWindow', hwnd, time, AnimateWindowFlags)
end

img1.OnClick = function()
 animatedObject(p1.handle, 1000, AnimateWindowFlags.AW_SLIDE | AnimateWindowFlags.AW_HOR_POSITIVE | AnimateWindowFlags.AW_HIDE)
 animatedObject(p2.handle, 1000, AnimateWindowFlags.AW_CENTER)
end

img2.OnClick = function()
 animatedObject(p2.handle, 1000, AnimateWindowFlags.AW_SLIDE | AnimateWindowFlags.AW_HOR_POSITIVE | AnimateWindowFlags.AW_HIDE)
 animatedObject(p1.handle, 1000, AnimateWindowFlags.AW_CENTER)
end

fm.show()



If someone wants to try the scripts, please remember to set your own picture images.

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Aylin
Grandmaster Cheater
Reputation: 9

Joined: 16 Feb 2017
Posts: 595

PostPosted: Sat Aug 01, 2020 6:23 am    Post subject: Reply with quote

I added a code to pause.
But your coding looks better.
The purpose is only to develop ideas. Wink


Code:
local index1=0

pTimer.OnTimer=function()
index1=tonumber(index1) + 5
if index1==110 then index1=0 pTimer.Enabled=false end
--print(index1)
if target==1 then
i1.left=tonumber(i1.left) - 5 if i1.left==0 - 210 then i1.left=120 end
i2.left=tonumber(i2.left) - 5 if i2.left==0 - 210 then i2.left=120 end
i3.left=tonumber(i3.left) - 5 if i3.left==0 - 210 then i3.left=120 end
end
if target==2 then
i1.left=tonumber(i1.left) + 5 if i1.left==230 then i1.left=0 - 100 end
i2.left=tonumber(i2.left) + 5 if i2.left==230 then i2.left=0 - 100 end
i3.left=tonumber(i3.left) + 5 if i3.left==230 then i3.left=0 - 100 end
end
end


----------
Code:
if f then f.destroy() f = nil end

f=createForm() f.Position=poDesktopCenter f.Width=160 f.Height=220
f.caption="Example Slayt" f.BorderIcons="biSystemMenu"

local p1=createPanel(f)
p1.Height=120 p1.Width=120 p1.Left=20 p1.Top=20
local p2=createPanel(f) p2.Font.Size=8
p2.Height=25 p2.Width=50 p2.Left=20 p2.Top=150 p2.caption="<< Play"
local p3=createPanel(f) p3.Font.Size=8
p3.Height=25 p3.Width=50 p3.Left=90 p3.Top=150 p3.caption="Play >>"
local p4=createPanel(f)
p4.Height=25 p4.Width=120 p4.Left=20 p4.Top=185 p4.caption="Stop Slayt"

--i1.picture.loadFromStream(findTableFile("download.png").stream)
------------------
int = getInternet()
local img1=int.getURL("https://i.hizliresim.com/eHvUpd.png")
local img2=int.getURL("https://i.hizliresim.com/GUwjei.png")
local img3=int.getURL("https://i.hizliresim.com/gRDtXn.png")
int.destroy()
local ss=createStringStream(img1)
local ss1=createStringStream(img2)
local ss2=createStringStream(img3)
--------------------------
local i1 = createImage(p1)
i1.Height=100 i1.Width=100 i1.Top=10 i1.Stretch=true i1.visible=true
local i2 = createImage(p1)
i2.Height=100 i2.Width=100 i2.Top=10 i2.Stretch=true i2.visible=true
local i3 = createImage(p1)
i3.Height=100 i3.Width=100 i3.Top=10 i3.Stretch=true i3.visible=true

i1.Picture.loadFromStream(ss)
i2.Picture.loadFromStream(ss1)
i3.Picture.loadFromStream(ss2)
ss.destroy() ss1.destroy() ss2.destroy()

function imageLeft()
i1.Left=10 i2.Left=0 - 100 i3.Left=0 - 210 end
imageLeft()

function imageLeft1()
i1.Left=10 i3.Left=120 i2.Left=130 + 100 end

-----------------------------------
local target=0
local index1=0

if pTimer then pTimer.destroy() end
local pTimer=createTimer(f) pTimer.Interval=100 pTimer.Enabled=false

pTimer.OnTimer=function()
index1=tonumber(index1) + 5
if index1==110 then index1=0 pTimer.Enabled=false end
--print(index1)
if target==1 then
i1.left=tonumber(i1.left) - 5 if i1.left==0 - 210 then i1.left=120 end
i2.left=tonumber(i2.left) - 5 if i2.left==0 - 210 then i2.left=120 end
i3.left=tonumber(i3.left) - 5 if i3.left==0 - 210 then i3.left=120 end
end
if target==2 then
i1.left=tonumber(i1.left) + 5 if i1.left==230 then i1.left=0 - 100 end
i2.left=tonumber(i2.left) + 5 if i2.left==230 then i2.left=0 - 100 end
i3.left=tonumber(i3.left) + 5 if i3.left==230 then i3.left=0 - 100 end
end
end

p2.OnClick=function()
--if pTimer.Enabled==false then
if target==0 then
imageLeft1() end
pTimer.Enabled=false
target=1
pTimer.Enabled=true
end

p3.OnClick=function()
if target==0 then
imageLeft() end
pTimer.Enabled=false
target=2
pTimer.Enabled=true
end

p4.OnClick=function()
pTimer.Enabled=false
end


Your 2nd code is better. I hope you will complete your project.

_________________
Hi Hitler Take control of your trainer
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 33

Joined: 10 Apr 2015
Posts: 1348

PostPosted: Sat Aug 01, 2020 8:01 am    Post subject: Reply with quote

Aylin wrote:
I added a code to pause.
But your coding looks better.
The purpose is only to develop ideas. Wink


Great work, that is exactly I am looking for. Thanks for helps.

_________________
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 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