Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Cycle Through Images In A GUI


  • Please log in to reply
3 replies to this topic
obituary1992
  • Members
  • 2 posts
  • Last active: Nov 02 2015 07:39 AM
  • Joined: 30 Oct 2015

Hi all,

I am attempting to create a GUI that displays an image when it loads up, and allowing the user to cycle through the images in a directory by pressing the left and right arrow keys on the keyboard. Still very much a WIP, I've found myself getting hung up on this issue for hours now, and no amount of searching the Internet for answers is helping. 

Right now, I have 10 images that I would like to cycle through - 1,png (this is the default image), 2.png, 3.png, and so on - and when reaching the last image, pressing the right arrow will bring the user back to the first image (eventually the left arrow will bring the user back to the last image if pressed on the first image, but gotta walk before ya run).

Anyways, here's what I have so far: 

 

varnumadd = 0 + 1

Gui, Add, Picture, w400 h400 vBPicture, 1.png
Gui, Show, w450 h450
Return

Right::
GuiControlGet, BPicture
GuiControl, -Redraw, BPicture
GuiControl,, BPicture, %varnumadd%.png
GuiControl, +Redraw, BPicture
Gui, Submit, NoHide
Return

If anyone could point me in the right direction, I would greatly appreciate it. 



Jackie Sztuk _Blackholyman
  • Spam Officer
  • 3757 posts
  • Last active: Apr 03 2016 08:47 PM
  • Joined: 28 Feb 2012
you need to have the variable increment inside the hotkey routine for it to work something like this

Untested:
varnumadd = 1

Gui, Add, Picture, w400 h400 vBPicture, %varnumadd%.png
Gui, Show, w450 h450, Image Gui
Return

#ifwinactive Image Gui
Right::
Gui, Submit, NoHide
if (varnumadd <= 9)
	varnumadd += 1
else
	varnumadd := 1
GuiControl, -Redraw, BPicture
GuiControl,, BPicture, %varnumadd%.png
GuiControl, +Redraw, BPicture
Return

Left::
Gui, Submit, NoHide
if (varnumadd >= 2)
	varnumadd -= 1
else
	varnumadd := 10
GuiControl, -Redraw, BPicture
GuiControl,, BPicture, %varnumadd%.png
GuiControl, +Redraw, BPicture
Return
#ifwinactive

Helping%20you%20learn%20autohotkey.jpg?d

[AHK] Version. 1.1+ [CLOUD] DropBox ; Copy [WEBSITE] Blog ; About

obituary1992
  • Members
  • 2 posts
  • Last active: Nov 02 2015 07:39 AM
  • Joined: 30 Oct 2015

Thank you so much for the response, the code works beautifully!  :)



Jackie Sztuk _Blackholyman
  • Spam Officer
  • 3757 posts
  • Last active: Apr 03 2016 08:47 PM
  • Joined: 28 Feb 2012
Good! Nice to hear it is working :)
Helping%20you%20learn%20autohotkey.jpg?d

[AHK] Version. 1.1+ [CLOUD] DropBox ; Copy [WEBSITE] Blog ; About