show svg/wdp/jxr/animated gif image files in a GUI Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
User avatar
jeeswg
Posts: 6718
Joined: 19 Dec 2016, 01:58
Location: UK

show svg/wdp/jxr/animated gif image files in a GUI

28 Feb 2017, 15:21

I have found a way to show wdp/jxr/animated gif image files in a GUI.
But I have not yet found a way to show svg files.

Based on:
Animated Gif in GUI - Ask for Help - AutoHotkey Community
https://autohotkey.com/board/topic/8902 ... if-in-gui/

Code: Select all

vPath = C:\MyFile.gif
Gui, Add, ActiveX, x0 y0 w600 h600 voWB, shell explorer
oWB.Navigate("about:blank")
vHtml := "<html>`n<title>name</title>`n<body>`n<center>`n<img src=""" vPath """ >`n</center>`n</body>`n</html>"
oWB.document.write(vHtml)
Gui, Show, AutoSize Center
Return
==================================================

Note: jxr and wdp appear to be the same filetype:
JPEG XR - Wikipedia
https://en.wikipedia.org/wiki/JPEG_XR

- Btw to convert svg to other image formats, you can use ImageMagick's convert.exe.
- To convert wdp/jxr to other image formats use convert.exe and JXRDecApp.exe.
- I couldn't find JXRDecApp.exe to download anywhere, so I downloaded a source zip, extracted it, and opened a sln file with Visual Studio, and compiled it via 'Build, Build Solution'.
- I then put JXRDecApp.exe in one of the PATH environment variable folders.
- I had to rename wdp files to jxr in order to convert them.
- Multiple locations hosted JXRDecApp source files that had errors compiling, the version here worked for me:
https://github.com/glencoesoftware/jxrlib

==================================================

[EDIT:]
I'm trying to get multiple svg files to display on one page. But you can display a lone svg, as the whole page, by using:
oWB.Navigate(vPath)
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6718
Joined: 19 Dec 2016, 01:58
Location: UK

Re: show svg/wdp/jxr/animated gif image files in a GUI

14 Dec 2017, 05:23

- This works to show an svg in an 'Internet Explorer_Server' control.
- What I can't do currently, I would like to be able to show an svg and other things like txt etc in the same control.
- Also, I've been having problems trying to zoom/scroll the image cf. the IE control here:
control zoo (AHK v1.1) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=30652

Code: Select all

q:: ;gui - show svg file
vPath := "C:\MyFile.svg"
Gui, Add, ActiveX, x0 y0 w600 h600 voWB, shell explorer
oWB.Navigate(vPath)
Gui, Show, AutoSize Center
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
DanielToward13
Posts: 63
Joined: 18 May 2017, 10:56

Re: show svg/wdp/jxr/animated gif image files in a GUI

14 Dec 2017, 06:24

Thanks for sharing. Can't we use this explorer extension to display SVG vectors on Autohotkey GUI?
User avatar
jeeswg
Posts: 6718
Joined: 19 Dec 2016, 01:58
Location: UK

Re: show svg/wdp/jxr/animated gif image files in a GUI

14 Dec 2017, 06:40

- I don't know what exactly that code would do. Also, I don't like making changes to the registry. I would imagine that svg files could be incorporated within html, and loaded into an IE object, like in my first post.
- If you want to explore that idea further, re. the code in the link, I would suggest creating a new forum thread. Cheers.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
GeneBene

Re: show svg/wdp/jxr/animated gif image files in a GUI

14 Dec 2017, 06:42

jeeswg wrote:I have found a way to show wdp/jxr/animated gif image files in a GUI.
But I have not yet found a way to show svg files.

Based on:
Animated Gif in GUI - Ask for Help - AutoHotkey Community
https://autohotkey.com/board/topic/8902 ... if-in-gui/

Code: Select all

vPath = C:\MyFile.gif
Gui, Add, ActiveX, x0 y0 w600 h600 voWB, shell explorer
oWB.Navigate("about:blank")
vHtml := "<html>`n<title>name</title>`n<body>`n<center>`n<img src=""" vPath """ >`n</center>`n</body>`n</html>"
oWB.document.write(vHtml)
Gui, Show, AutoSize Center
Return
==================================================

Note: jxr and wdp appear to be the same filetype:
JPEG XR - Wikipedia
https://en.wikipedia.org/wiki/JPEG_XR

- Btw to convert svg to other image formats, you can use ImageMagick's convert.exe.
- To convert wdp/jxr to other image formats use convert.exe and JXRDecApp.exe.
- I couldn't find JXRDecApp.exe to download anywhere, so I downloaded a source zip, extracted it, and opened a sln file with Visual Studio, and compiled it via 'Build, Build Solution'.
- I then put JXRDecApp.exe in one of the PATH environment variable folders.
- I had to rename wdp files to jxr in order to convert them.
- Multiple locations hosted JXRDecApp source files that had errors compiling, the version here worked for me:
https://github.com/glencoesoftware/jxrlib

==================================================

[EDIT:]
I'm trying to get multiple svg files to display on one page. But you can display a lone svg, as the whole page, by using:
oWB.Navigate(vPath)
if only you had a way to get rid of the white background that is part of shell explorer, but its better than nothing
User avatar
Delta Pythagorean
Posts: 474
Joined: 13 Feb 2017, 13:44
GitHub: DelPyth
Location: Somewhere in the US

Re: show svg/wdp/jxr/animated gif image files in a GUI

14 Dec 2017, 09:50

I created this function a few months ago, and I think you might want to take a look.
Displaying an SVG file is the same as displaying any normal file.

Code: Select all

<img src="FileToUse.svg" alt="Some Message" />
This is the forum topic that I mentioned: https://autohotkey.com/boards/viewtopic.php?f=6&t=35199
User avatar
jeeswg
Posts: 6718
Joined: 19 Dec 2016, 01:58
Location: UK

Re: show svg/wdp/jxr/animated gif image files in a GUI

14 Dec 2017, 10:25

@Delta Pythagorean: Thanks for the suggestion, unfortunately, I tested your script and it didn't work with my svg file (although it did handle other filetypes), it just showed an image not loaded icon. When I used the code above in my script, again it worked with other filetypes, but showed the icon and 'Some Message'. The icon is a white X on a black PC screen, on a white PC. What OS do you use? (I use Windows 7.)
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
Delta Pythagorean
Posts: 474
Joined: 13 Feb 2017, 13:44
GitHub: DelPyth
Location: Somewhere in the US

Re: show svg/wdp/jxr/animated gif image files in a GUI

14 Dec 2017, 10:31

jeeswg wrote:What OS do you use? (I use Windows 7.)
I currently use Windows 10 for my work, and Windows 8.1 for general usage. I test my scripts in both before pushing to the public.
jeeswg wrote:... unfortunately, I tested your script and it didn't work with my svg file
Interesting... :eh:
jeeswg wrote:The icon is a white X on a black PC screen, on a white PC.
Then shouldn't it be a PNG instead of an SVG? I think you'd be better off with a Raster image vs. a Vector image. Unless Vector art is what you're aiming for :silent:
User avatar
jeeswg
Posts: 6718
Joined: 19 Dec 2016, 01:58
Location: UK

Re: show svg/wdp/jxr/animated gif image files in a GUI

14 Dec 2017, 10:43

- I want an improved version of SplashImage (that could handle more formats including animated gifs) / a custom image viewer. I mentioned one workaround above, which fills an IE control with an image, (if possible I would like to put multiple images/text in one IE control, plus its easier to set a specific position/size/zoom IIRC), another workaround is converting the svgs to another format.
- I tried putting either of these into the html, but they didn't work, they have been helpful for other problems.
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="X-UA-Compatible" content="IE=9">
- So you managed to get svg files to show, via your script, in Windows 8 and Windows 10?
- If you open up an svg file, it basically looks like html, so I thought that perhaps FileRead, and adding/removing some text from the top and bottom might make an svg work within html.
- Based on the fact that this script exists, I thought that perhaps someone would be able to help me achieve this, or at least shed light on what's possible/not possible.
SVGraph: Graphs in AHK GUIs - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=23892
- Potentially, IE controls could be used as a standard GUI control, for various multimedia things.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
Delta Pythagorean
Posts: 474
Joined: 13 Feb 2017, 13:44
GitHub: DelPyth
Location: Somewhere in the US

Re: show svg/wdp/jxr/animated gif image files in a GUI

14 Dec 2017, 15:46

- I guess I could improve on my WebPic function to allow multiple files/web images.
- I haven't tried an SVG, but I do know that the WebPic function works on most (Because of IE version) operating systems.
- Reading the SVG into memory and pushing it to be an image is a little tricky.
- Have you tried just loading the SVG into IE itself without using AHK's ActiveX?
User avatar
jeeswg
Posts: 6718
Joined: 19 Dec 2016, 01:58
Location: UK

Re: show svg/wdp/jxr/animated gif image files in a GUI

14 Dec 2017, 16:17

@Delta Pythagorean:
I guess I could improve on my WebPic function to allow multiple files/web images.
- Only if you want more features, I wasn't suggesting to change it in any way. The GUI looked quite nice in your script. What I had in my mind were things like name (path, and info e.g. date/dimensions) then image, or multiple images e.g. every icon on a webpage. I.e. an improved SplashImage, splash the image, with a bit of info.
Displaying an SVG file is the same as displaying any normal file.
...
I haven't tried an SVG, but I do know that the WebPic function works on most (Because of IE version) operating systems.
- Hmm. Perhaps 'is the same' should be replaced with 'is probably the same'. It's always a good idea to either use language that expresses a degree of doubt/uncertainty, or to run the code and double-check that it works, one and/or the other.
- [EDIT:] I often double-check things, or review things before posting, even that I know very well. The great thing about IT is that you can double-check things immediately. Everything can be confirmed.
- The sad part wasn't the effort involved in testing the script to confirm that it worked, only to see it didn't work. The sad part was having hopes raised temporarily only to be dashed. It seemed theoretically possible that newer versions of the IE control could handle it.
Reading the SVG into memory and pushing it to be an image is a little tricky.
- I'm not sure what you mean by 'pushing it to be an image', ImageMagick can do svg to png via the command line, although this means creating a file (and it's better if you can do it in memory). If we can do svg to png via Gdip that would be interesting, but then, is it easy to put an image into an IE control, based on data in memory?
- I had thought that perhaps IE controls could be used to create versatile GUIs, although I don't have much experience of this.
- [EDIT:] When you say that it's 'a little tricky', have you done this before?
Have you tried just loading the SVG into IE itself without using AHK's ActiveX?
- My example 'gui - show svg file', works to get the entire contents of the IE control to be the svg. And I'm looking to make the svg just one element alongside other elements.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6718
Joined: 19 Dec 2016, 01:58
Location: UK

Re: show svg/wdp/jxr/animated gif image files in a GUI  Topic is solved

12 Jun 2018, 19:59

- I have two working scripts (tested on Windows 7), one to display an existing file, one for inline svg.
- To get svg to work required two tricks:
<meta http-equiv="X-UA-Compatible" content="IE=9">
and
oWB.Refresh()
- Interestingly, on the inline svg example, if you miss out either of these 2 lines, you are shown the fallback text.

- Display an svg file:

Code: Select all

;display an svg file
vPath := "C:\MyFile.svg"
Gui, Add, ActiveX, x0 y0 w600 h600 voWB, shell explorer
oWB.Navigate("about:blank")
vHtml = <meta http-equiv="X-UA-Compatible" content="IE=9">
vHtml .= "<html>`n<title>name</title>`n<body>`n<center>`n<img src=""" vPath """ >`n</center>`n</body>`n</html>"
oWB.document.write(vHtml)
oWB.Refresh()
Gui, Show, AutoSize Center
return
- Display inline svg:

Code: Select all

;Tryit Editor v3.5
;https://www.w3schools.com/graphics/tryit.asp?filename=trysvg_circle

;display inline svg
Gui, Add, ActiveX, x0 y0 w600 h600 voWB, shell explorer
oWB.Navigate("about:blank")

vHtml = ;continuation section
(
<!DOCTYPE html>
<meta http-equiv="X-UA-Compatible" content="IE=9">
<html>
<body>

<svg height="100" width="100">
  <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
  Sorry, your browser does not support inline SVG.
</svg>

</body>
</html>
)

oWB.document.write(vHtml)
oWB.Refresh()
Gui, Show, AutoSize Center
return
- Links:
[mentions inline svg]
Using SVG | CSS-Tricks
https://css-tricks.com/using-svg/
[simple svg examples]
SVG Examples
https://www.w3schools.com/graphics/svg_examples.asp
Internet Explorer controls: scrollbars, borders, navigation sounds, image dimensions - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=50189
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask For Help”

Who is online

Users browsing this forum: flyingDman and 213 guests