Skip to content

Instantly share code, notes, and snippets.

@tmplinshi
Created November 8, 2014 05:03
Show Gist options
  • Save tmplinshi/9134fd1bd86def50e222 to your computer and use it in GitHub Desktop.
Save tmplinshi/9134fd1bd86def50e222 to your computer and use it in GitHub Desktop.
Img = http://www.animatedgif.net/cartoons/A_5odie_e0.gif
Img2 = http://www.animatedgif.net/cartoons/anime_hero2_e0.gif
Gui New, +HwndhGUI
gif1 := AnimatedGif( hGUI, Img, 50, 50, 200, 200, "", "MyGif", "myGif_" )
gif2 := AnimatedGif( hGUI, Img2, 300, 50, 292, 167, "White", "MyGif2", myGif2 )
Gui Show, center
return
GuiClose:
exitapp
AnimatedGif( guiHwnd, Image, X, Y, W, H, BackgroundColor="", Id="AnimatedGif", eventHandler="" ) {
DefaultGUIColor := DllCall( "User32.dll\GetSysColor", Int, 15, UInt )
R := DefaultGUIColor & 0xFF
G := ( DefaultGUIColor >> 8 ) & 0xFF
B := ( DefaultGUIColor >> 16 ) & 0xFF
DefaultGUIColor := "rgb(" R ", " G ", " B ")"
Gui %guiHwnd%:Add, ActiveX, x%X% y%Y% w%W% h%H% +HwndGifHwnd, HTMLFile
GuiControlGet HtmlObj, %guiHwnd%:, %GifHwnd%
HtmlObj.Body.style.BackgroundColor := BackgroundColor = "" ? DefaultGUIColor : BackgroundColor
HtmlObj.Body.style.margin := 0
HtmlObj.Body.style.padding := 0
HtmlObj.Body.style.overflow := "hidden"
out := HtmlObj.createElement( "img" )
out.id := Id
out.src := Image
out.style.position := "absolute"
out.style.left := 0
out.style.top := 0
out.style.width := "100%"
out.style.height := "100%"
out.style.minWidth := "100%"
out.style.minHeight := "100%"
out.style.visibility := "visible"
HtmlObj.Body.appendChild( out )
if eventHandler
ComObjConnect( out, eventHandler )
return out
}
myGif_OnClick( thisGif ) {
ToolTip % "you clicked " thisGif.Id
return
}
class myGif2
{
OnClick( thisGif ) {
ToolTip % "you clicked " thisGif.Id
return
}
OnMouseDown( thisGif ) {
if GetKeyState( "LButton", "P" )
ToolTip left mouse button down
if GetKeyState( "RButton", "P" )
ToolTip right mouse button down
return
}
OnMouseUp( thisGif ) {
ToolTip mouse button released
return
}
OnMouseOver( thisGif ) {
ToolTip you are hovering
return
}
OnMouseOut( thisGif ) {
ToolTip you are no longer hovering
return
}
OnDblClick( thisGif ) {
ToolTip % "you double clicked " thisGif.Id
return
}
}
@dd900
Copy link

dd900 commented Dec 14, 2020

Wow. I just found this... I never would have thought I wrote something worthy of long term storage. And this code still works with the latest ahk v1. This made my day thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment