SlideShow

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
SimPlayer
Posts: 128
Joined: 01 Apr 2016, 05:57

SlideShow

Post by SimPlayer » 09 Apr 2022, 11:24

Hi guys.

Wonder if it´s possible to make a slideshow in AHK?
I use the SplashImage command, but it`s not so smooth, and it also shows the background between each picture show.

SimPlayer

User avatar
flyingDman
Posts: 2823
Joined: 29 Sep 2013, 19:01

Re: SlideShow

Post by flyingDman » 09 Apr 2022, 11:29

I forgot who the author is of this:

Code: Select all

#SingleInstance Force
Slideshow("C:\Users\xxx\Pictures\Wallpaper\*.jpg", 3)
return

esc::
GuiEscape:
ExitApp

SlideShow(fileList, duration)
	{
	global
	toplefty := 0, 	topleftx := 0, 	windh := A_ScreenHeight - 0, 
	objh := A_ScreenHeight - toplefty, 	objw := A_ScreenWidth - topleftx
	gui, Add, Picture, x%topleftx% y%toplefty% h%objh% w%objw% center vimg,
	Gui, Color, Black
	Gui -Caption
	Gui, Show,x0 y0 w%A_ScreenWidth% h%windh%, picwin
	Loop, %filelist%
		{
		;~ tooltip,%a_LoopFileLongPath%	
		guicontrol,hide,img
		guicontrol,, img, *h%objh% *w-1 %a_LoopFileLongPath%
		ControlGetPos,imgx,imgy,imgw,imgh,static1,picwin
		if imgw > %objw%
			{
			guicontrol,, img, *w%objw% *h-1 %a_loopfield%
			ControlGetPos,,,,imgh,static1,picwin
			imgy := (objh - imgh)//2 + toplefty
			guiControl,Move,img,x%topleftx%,y%imgy%
			}
		else
			{
			imgx := (objw - imgw)//2 + topleftx
			guiControl,Move,img,x%imgx%,y%toplefty%
			}
		guicontrol,show,img
		KeyWait,right,D T%duration%
		}
	}
14.3 & 1.3.7

SimPlayer
Posts: 128
Joined: 01 Apr 2016, 05:57

Re: SlideShow

Post by SimPlayer » 14 Apr 2022, 10:33

Hi,
and thanks for the code, works perfectly!
I do have one problem with it
It's first in the script, it should run through all the pics, then the script should continue.
As it is now, it waits for a keystroke to stop....

SimPlayer

User avatar
flyingDman
Posts: 2823
Joined: 29 Sep 2013, 19:01

Re: SlideShow

Post by flyingDman » 14 Apr 2022, 11:27

If you want it to exit after showing all images in the folder use:

Code: Select all

	Slideshow("C:\Users\xxxx\Pictures\Wallpaper\*.jpg", 3)
exitapp
if you want it to restart the show for an indefinite loop use:

Code: Select all

#SingleInstance Force
Loop
	Slideshow("C:\Users\xxxx\Pictures\Wallpaper\*.jpg", 3)
return

esc::
GuiEscape:
ExitApp

SlideShow(fileList, duration)
	{
	global
	toplefty := 0, 	topleftx := 0, 	windh := A_ScreenHeight - 0, 
	objh := A_ScreenHeight - toplefty, 	objw := A_ScreenWidth - topleftx
	gui, New														:<<<<<<<<<<< 
	gui, Add, Picture, x%topleftx% y%toplefty% h%objh% w%objw% center vimg,
	Gui, Color, Black
	Gui -Caption
	Gui, Show,x0 y0 w%A_ScreenWidth% h%windh%, picwin
	Loop, %filelist%
		{
		; tooltip,%a_LoopFileLongPath%	
		guicontrol,hide,img
		guicontrol,, img, *h%objh% *w-1 %a_LoopFileLongPath%
		ControlGetPos,imgx,imgy,imgw,imgh,static1,picwin
		if (imgw > objw)
			{
			guicontrol,, img, *w%objw% *h-1 %a_loopfield%
			ControlGetPos,,,,imgh,static1,picwin
			imgy := (objh - imgh)//2 + toplefty
			guiControl,Move,img,x%topleftx%,y%imgy%
			}
		else
			{
			imgx := (objw - imgw)//2 + topleftx
			guiControl,Move,img,x%imgx%,y%toplefty%
			}
		guicontrol,show,img
		KeyWait,right,D T%duration%
		}
	}
14.3 & 1.3.7

SimPlayer
Posts: 128
Joined: 01 Apr 2016, 05:57

Re: SlideShow

Post by SimPlayer » 14 Apr 2022, 12:40

Hi again.

As I told you the code should be first in the script, it should run through all the pics, then the script should continue, not exit at that point.

For some reason, the script doesn´t read the rest of the code in the script, and all goes wrong.

SimPlayer

User avatar
flyingDman
Posts: 2823
Joined: 29 Sep 2013, 19:01

Re: SlideShow

Post by flyingDman » 14 Apr 2022, 13:45

It's not that the code should be "first in the script" it is that you have other lines of code (which you did not tell about). What you need is probably just a gui, destroy at the end of the function, like so:

Code: Select all

Slideshow("C:\Users\xxxx\Pictures\Wallpaper\*.jpg", 1)
msgbox rest of script
return

esc::
GuiEscape:
ExitApp

SlideShow(fileList, duration)
	{
	global
	toplefty := 0, 	topleftx := 0, 	windh := A_ScreenHeight - 0, 
	objh := A_ScreenHeight - toplefty, 	objw := A_ScreenWidth - topleftx
	gui, New
	gui, Add, Picture, x%topleftx% y%toplefty% h%objh% w%objw% center vimg,
	Gui, Color, Black
	Gui -Caption
	Gui, Show,x0 y0 w%A_ScreenWidth% h%windh%, picwin
	Loop, %filelist%
		{
		;tooltip,%a_LoopFileLongPath%	
		guicontrol,hide,img
		guicontrol,, img, *h%objh% *w-1 %a_LoopFileLongPath%
		ControlGetPos,imgx,imgy,imgw,imgh,static1,picwin
		if (imgw > objw)
			{
			guicontrol,, img, *w%objw% *h-1 %a_loopfield%
			ControlGetPos,,,,imgh,static1,picwin
			imgy := (objh - imgh)//2 + toplefty
			guiControl,Move,img,x%topleftx%,y%imgy%
			}
		else
			{
			imgx := (objw - imgw)//2 + topleftx
			guiControl,Move,img,x%imgx%,y%toplefty%
			}
		guicontrol,show,img
		KeyWait,right,D T%duration%
		}
	Gui, Destroy	                                                  ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
	}
14.3 & 1.3.7

SimPlayer
Posts: 128
Joined: 01 Apr 2016, 05:57

Re: SlideShow

Post by SimPlayer » 15 Apr 2022, 03:58

Hi again.

Yess, now it works as it should, thanks man!

But, the indefinate loop I can´t get to work, I get an error, see the attached file.

This first thing that works ok,was an InfoSlideshow to be viewed automatically one time, but this second slideshow is more like a screensaver, it should run indefinately until it´s aborted by a keystroke.

SimPlayer
Attachments
Error.JPG
Error.JPG (17.33 KiB) Viewed 684 times

SimPlayer
Posts: 128
Joined: 01 Apr 2016, 05:57

Re: SlideShow

Post by SimPlayer » 15 Apr 2022, 09:48

Hi

With a little bit of trying, I got it!

SP

Code: Select all

#SingleInstance Force
Loop
Slideshow("C:\LFS\Info\*.jpg", 3)
return


esc::
GuiEscape:
ExitApp

SlideShow(fileList, duration)
	{
	global
	toplefty := 0, 	topleftx := 0, 	windh := A_ScreenHeight - 0, 
	objh := A_ScreenHeight - toplefty, 	objw := A_ScreenWidth - topleftx
	gui, New
	gui, Add, Picture, x%topleftx% y%toplefty% h%objh% w%objw% center vimg,
	Gui, Color, Black
	Gui -Caption
	Gui, Show,x0 y0 w%A_ScreenWidth% h%windh%, picwin
	Loop, %filelist%
		{
		;tooltip,%a_LoopFileLongPath%	
		guicontrol,hide,img
		guicontrol,, img, *h%objh% *w-1 %a_LoopFileLongPath%
		ControlGetPos,imgx,imgy,imgw,imgh,static1,picwin
		if (imgw > objw)
			{
			guicontrol,, img, *w%objw% *h-1 %a_loopfield%
			ControlGetPos,,,,imgh,static1,picwin
			imgy := (objh - imgh)//2 + toplefty
			guiControl,Move,img,x%topleftx%,y%imgy%
			}
		else
			{
			imgx := (objw - imgw)//2 + topleftx
			guiControl,Move,img,x%imgx%,y%toplefty%
			}
		guicontrol,show,img
		KeyWait,right,D T%duration%
		}
	
	}
[Mod edit: [code][/code] tags added.]
Last edited by gregster on 15 Apr 2022, 12:03, edited 1 time in total.
Reason: Please use code tags. Thank you!

albertcb98
Posts: 2
Joined: 12 Sep 2018, 19:19

Re: SlideShow

Post by albertcb98 » 08 Dec 2022, 21:17

Hi there, awesome Script!

How can you have resize image of slideshows to be A_screenwidth/2, and A_heigth/2, like --> https://drive.google.com/file/d/14B1tDJBJ32KJ_a9Qiq583lujz5k9dYja/view?usp=sharing (or see pic attachment)
(ignore the colors of the box its just for demonstration of where the images would be placed)

and if you could set images a bit transparent to be able to see the background would be awesome

Thanks a lot, best regards,
Attachments
chrome_eP5y1UZCUW.png
chrome_eP5y1UZCUW.png (262.63 KiB) Viewed 514 times

Post Reply

Return to “Ask for Help (v1)”