Embed Video in AHK Gui?
- PuzzledGreatly
- Posts: 1303
- Joined: 29 Sep 2013, 22:18
Embed Video in AHK Gui?
Is it possible to play a video on the local PC inside a Gui, preferably mp4? I read the help information on SoundPlay. When I set up A Gui button to play an avi file I got distorted noise and nothing else. When I tried an mp4 I got nothing.
- PuzzledGreatly
- Posts: 1303
- Joined: 29 Sep 2013, 22:18
Re: Embed Video in AHK Gui?
Thanks for the link, I'll check it out.
Re: Embed Video in AHK Gui?
If you haveIE9+ installed, you can embed an IE control in your GUI and then use HTML5 video. Format is limited to mp4 and ogg. Also you would need to set FEATURE_BROWSER_EMULATION key for AutoHotkey.exe or CompiledScript.exe in the registry. Loading an HTML source from the local file system puts IE to compatibility mode, IE5 (for documents w/o <meta http-equiv="X-UA-Compatible" content="IE=edge" /> meta tag), otherwise, IE7. Hence you won't be able to use the new features in HTML5.
Disclaimer: Haven't tested this yet.
Disclaimer: Haven't tested this yet.
Re: Embed Video in AHK Gui?
Here's an example using an embedded IE, requires IE9+ installed:
Code: Select all
html =
(
<!doctype html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<script type="text/javascript">
</script>
<style type="text/css">
</style>
</head>
<body>
<div style="text-align:center">
<button onclick="playPause()">Play/Pause</button>
<button onclick="makeBig()">Big</button>
<button onclick="makeSmall()">Small</button>
<button onclick="makeNormal()">Normal</button>
<video id="video1" width="500">
<source src="" type="video/mp4">
Your browser does not support HTML5 video.
</video>
</div>
<script>
var myVideo = document.getElementById("video1");
function loadFile(filename) {
myVideo.src = filename;
}
function playPause() {
if (myVideo.paused)
myVideo.play();
else
myVideo.pause();
}
function makeBig() {
myVideo.width = 560;
}
function makeSmall() {
myVideo.width = 320;
}
function makeNormal() {
myVideo.width = 420;
}
</script>
</body>
</html>
)
fbe() ;// set FEATURE_BROWSER_EMULATION
Gui New, +LastFound +Resize
hGui := WinExist()
Gui Margin, 0, 0
Gui Add, ActiveX, w600 h400 vWB HwndhWB, Shell.Explorer
WB.Navigate("about:blank")
while (WB.ReadyState != 4)
Sleep 10
WB.Document.open(), WB.Document.write(html), WB.Document.close()
EnvGet user, USERPROFILE
FileSelectFile, file,, %user%\Videos, Select a video, Video (*.mp4;*.ogg)
if ErrorLevel {
MsgBox,,, No file chosen`, script will exit, 1
ExitApp
}
WB.Document.parentWindow.loadFile(file)
Gui Show
return
GuiClose:
ExitApp
GuiSize:
DllCall(
(Join C
"SetWindowPos",
"Ptr", hWB,
"Ptr", 0,
"Int", 0,
"Int", 0,
"Int", A_GuiWidth,
"Int", A_GuiHeight,
"UInt", 0x0004|0x0010|0x0002 ;// uFlags=SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE
))
return
/* FEATURE_BROWSER_EMULATION
*/
fbe() {
static dummy := 0
if dummy
return
dummy := new (base:={__Delete:"fbe_cleanup"})
RegRead FBE, HKCU,
(Join\ LTrim
Software\Microsoft\Internet Explorer\Main
FeatureControl\FEATURE_BROWSER_EMULATION
), AutoHotkey.exe
if (FBE == "")
RegWrite REG_DWORD, HKCU,
(Join\ LTrim C Q
Software\Microsoft\Internet Explorer\Main
FeatureControl\FEATURE_BROWSER_EMULATION
), AutoHotkey.exe, % ie_version()*1000 ; {7:0x1B58, 8:0x1F40, 9:0x2328, 10:0x02710, 11:0x2AF8}
}
;// called automatically when the script exits
fbe_cleanup(this:=true) {
RegRead FBE, HKCU,
(Join\ LTrim
Software\Microsoft\Internet Explorer\Main
FeatureControl\FEATURE_BROWSER_EMULATION
), AutoHotkey.exe
if (FBE != "")
RegDelete HKCU,
(Join\ LTrim
Software\Microsoft\Internet Explorer\Main
FeatureControl\FEATURE_BROWSER_EMULATION
), AutoHotkey.exe
}
ie_version() {
RegRead ver, HKLM, SOFTWARE\Microsoft\Internet Explorer, svcVersion
return SubStr(ver, 1, InStr(ver, ".")-1)
}
Last edited by Coco on 18 Jun 2014, 10:24, edited 1 time in total.
Re: Embed Video in AHK Gui?
Coco; this is really cool.
Is this using an actual "player" for the movie ?
If yes, then is it possible to expose a time elapsed bar ?
Either way, thank you for posting.
Is this using an actual "player" for the movie ?
If yes, then is it possible to expose a time elapsed bar ?
Either way, thank you for posting.
Re: Embed Video in AHK Gui?
@elmo:
The demo uses HTML5 Video
The demo uses HTML5 Video
The answer would be yes, would require some HTML+Javascript+CSS kungfu.elmo wrote:If yes, then is it possible to expose a time elapsed bar ?
Re: Embed Video in AHK Gui?
lol... Thanks for the reply. Still learning kung-fu
Who is online
Users browsing this forum: MSN [Bot], NinjoOnline and 212 guests