Skip to content

Instantly share code, notes, and snippets.

@tmplinshi
Last active January 2, 2016 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmplinshi/8293675 to your computer and use it in GitHub Desktop.
Save tmplinshi/8293675 to your computer and use it in GitHub Desktop.
; Scrollable image list ( supports .gifs)
: Author: Sjc1000
; Link: http://ahkscript.org/boards/viewtopic.php?f=6&t=1277
FileSelectFolder, myFolder,
imageExt := "jpg,bmp,gif,png"
main := new imageDisplay(1, A_ScreenWidth / 1.2 - 20, A_ScreenWidth / 3, ( A_ScreenWidth / 1.2 ) / 4.6 )
imageList := Object()
Gui, Color, 0x333333
Gui, Show
MsgBox, % myFolder
Loop, %myFolder%\*.*,, 1
{ If A_LoopFileExt not in %imageExt%
continue
main.newImage( A_LoopFileFullPath, A_Index, "Name" )
imageList[ A_Index ] := A_LoopFileFullPath
}
Return
Class imageDisplay
{
__New( guiNumber, width, height, imageWidth=200, imageHeight="auto", eventName="evnt_" )
{ static imgList
this.width := width
this.height := height
this.imageWidth := imageWidth
this.imageHeight := imageHeight
Gui, %guiNumber%: Add, ActiveX, w%width% h%height% vimgList, MSHTML:
html =
(
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
img:hover { background-color: #444444; }
</style>
</head>
<body>
<div id="imgCont">
</div>
</body>
</html>
)
imglist.write( html )
ComObjConnect(imgList, eventName )
imglist.getElementsByTagName("body")[0].style.backgroundColor := "333333"
imglist.getElementsByTagName("div")[0].style.overflow := "auto"
imgList.getElementsByTagName("div")[0].style.height := height - 20
imgList.getElementsByTagName("div")[0].style.width := width - 20
imgList.close()
this.var := imgList
return this
}
newImage( imageDir, imageID, imageText )
{ element := this.var.createElement( "img" )
element.src := imageDir
element.Id := imageID
element.style.width := this.imageWidth
element.style.height := this.imageHeight
element.style.padding := this.imageSpace ? this.imageSpace : "10px"
this.var.getElementById( "imgCont" ).appendChild( element )
}
}
evnt_OndblClick( p* )
{ global activeImage
elm := p[1].parentWindow.event.srcElement.Id
activeImage := p[1].getElementById(elm).Id
SetTimer, OnClick, -1
}
evnt_OnClick( p* )
{ global prevImage, backgroundColor
prevImage.style.backgroundColor := backgroundColor
elm := p[1].parentWindow.event.srcElement.Id
If elm is not digit
Return
image := p[1].getElementById(elm)
image.style.backgroundColor := "FFFFFF"
prevImage := image
}
OnClick:
imageDir := imageList[ activeImage ]
MsgBox, % imageDir
Return
GuiClose:
ExitApp
Return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment