Open image in a window using VBS
Solved
PetitMinou12
Posted messages
86
Status
Member
-
PetitMinou12 Posted messages 86 Status Member -
PetitMinou12 Posted messages 86 Status Member -
Bonjour, je souhaiterais ouvrir une image dans une fenêtre, j'ai donc cherché sur des forums et j'ai trouvé ça :
Je souhaite supprimer le chemin d'accès pour ouvrir l'image dans le dossier actuel pour que je puisse par la suite envoyer mon projet compilé.
Set objExplorer = CreateObject("InternetExplorer.Application")
With objExplorer
.Navigate "about:blank"
.ToolBar = 0
.StatusBar = 0
.Left = 500
.Top = 50
.Width = 1000
.Height = 1000
.Visible = 1
.Document.Title = "Test"
.Document.Body.InnerHTML = _
"<img src='1.jpg' height=1000 width=1000>"
End With Je souhaite supprimer le chemin d'accès pour ouvrir l'image dans le dossier actuel pour que je puisse par la suite envoyer mon projet compilé.
4 answers
dim fso dim scriptdir dim src_path dim src set fso = CreateObject("Scripting.FileSystemObject") ' répertoire dans lequel ce script est en cours d'exécution scriptdir = fso.GetAbsolutePathName(".") src_path = scriptdir & "\1.jpeg" With objImg .Navigate "about:blank" .ToolBar = 0 .StatusBar = 0 .Left = 500 .Top = 50 .Width = 1000 .Height = 1000 .Visible = 1 .Document.Title = "Test" .Document.Body.InnerHTML = _ "<img src='" & src_path & "' height=1000 width=1000>" End With --
Best regards,
Jordane
PetitMinou12
Posted messages
86
Status
Member
5
I adapted the program and it works, thanks ^^
Hello,
to retrieve the script path
All you need to do is concatenate it in your src tag
--
Best regards,
Jordane
to retrieve the script path
scriptdir = WScript.ScriptFullName.substring(0,WScript.ScriptFullName.lastIndexOf(WScript.ScriptName)-1)
All you need to do is concatenate it in your src tag
--
Best regards,
Jordane
```html
I tried
And also
and even a messed up thing created by myself:
And none of them work :/
Edit: added the language in the code tags ```
"<img src='scriptdir = WScript.ScriptFullName.substring(0,WScript.ScriptFullName.lastIndexOf(WScript.ScriptName)-1) & \1.jpg' height=1000 width=1000>" "<img src='scriptdir = WScript.ScriptFullName.substring(0,WScript.ScriptFullName.lastIndexOf(WScript.ScriptName)-1) & 1.jpg' height=1000 width=1000>" "<img src= scriptdir = WScript.ScriptFullName.substring(0,WScript.ScriptFullName.lastIndexOf(WScript.ScriptName)-1) & \1.jpg height=1000 width=1000>" "<img src= scriptdir = WScript.ScriptFullName.substring(0,WScript.ScriptFullName.lastIndexOf(WScript.ScriptName)-1) & 1.jpg height=1000 width=1000>" "<img src=scriptdir = WScript.ScriptFullName.substring(0,WScript.ScriptFullName.lastIndexOf(WScript.ScriptName)-1) & \1.jpg height=1000 width=1000>" "<img src=scriptdir = WScript.ScriptFullName.substring(0,WScript.ScriptFullName.lastIndexOf(WScript.ScriptName)-1) & 1.jpg height=1000 width=1000>"
And also
Set objExplorer = CreateObject("InternetExplorer.Application") scriptdir = WScript.ScriptFullName.substring(0,WScript.ScriptFullName.lastIndexOf(WScript.ScriptName)-1) With objExplorer .Navigate "about:blank" .ToolBar = 0 .StatusBar = 0 .Left = 500 .Top = 50 .Width = 1000 .Height = 1000 .Visible = 1 .Document.Title = "Test" .Document.Body.InnerHTML = _ "<img src=''' & scriptdir & '\1.jpg'' height=1000 width=1000>" End With and even a messed up thing created by myself:
Set objImg = CreateObject("InternetExplorer.Application") Set objCurrent = CreateObject("WScript.Shell") actualdir = objCurrent.CurrentDirectory With objImg .Navigate "about:blank" .ToolBar = 0 .StatusBar = 0 .Left = 500 .Top = 50 .Width = 1000 .Height = 1000 .Visible = 1 .Document.Title = "Test" .Document.Body.InnerHTML = _ "<img src=''' & actualdir & '1.jpg'' height=1000 width=1000>" End With And none of them work :/
Edit: added the language in the code tags ```