display Image with no border before starting an app,exe file?

喜你入骨 提交于 2020-01-24 20:30:08

问题


ok so some tools , some converting tools, give the ability to display an image before starting the converted application, and after done ! that is something very interesting i definitely want to know about, so the question is this : how can you -using vbs,js,html,hta,css...- display an image (basically not in default windows image viewer you know what i'm talking about) ?

i first tough it's hta with that image as a background and no border but after trying it the image still have small borders.

any ideas, !? hope there is


回答1:


Try this example tested only on windows 7

NB: This example dosen't work on windows xp

[VBS/HTA] Popup an image with playing song in the background

Option Explicit
Dim URL,ws,fso,Srcimage,Temp,PathOutPutHTML,fhta,stRep,stFichier,oShell,oFolder,oFichier,Dimensions
Dim arrSize,intLength,intHorizontalSize,intVerticalSize,Tab
URL = "http://www.animatedimages.org/data/media/902/animated-tunisia-flag-image-0023.gif"
Set ws = CreateObject("wscript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Temp = WS.ExpandEnvironmentStrings("%Temp%")
PathOutPutHTML = Temp & "\image.hta"
Set fhta = fso.OpenTextFile(PathOutPutHTML,2,True)
stRep = Temp
Tab = split(url,"/")
stFichier = Tab(UBound(Tab))
Srcimage = stRep & "\" & stFichier
If Not fso.FileExists(Srcimage) Then
   Call DownloadingFile(URL,Srcimage)
Set oShell = CreateObject("Shell.Application")
Set oFolder = oShell.Namespace(stRep)
Set oFichier = oFolder.Items.Item(stFichier)
Dimensions = oFolder.GetDetailsOf(oFichier,31)
arrSize = Split(Dimensions,"x")
'***************************************Important à savoir **********************************************
'Instead, we ended up retrieving item 31, which gave us the total dimensions of the picture,
'using an output format similar to this: ?150 x 354?
'http://blogs.technet.com/b/heyscriptingguy/archive/2008/05/16/how-can-i-search-a-folder-for-all-the-image-files-that-are-not-a-specified-height-and-width.aspx
'Un grand merci à omen999 ==>
'http://www.developpez.net/forums/d1504644/autres-langages/general-visual-basic-6-vbscript/vbscript/passage-variables-procedure/#post8163406
intLength = Len(arrSize(0))
intHorizontalSize = Right(arrSize(0),intLength -1)
intLength = Len(arrSize(1))
intVerticalSize = Left(arrSize(1),intLength - 1)
'***************************************Important à savoir **********************************************
   Call LoadImage(Srcimage,intHorizontalSize,intVerticalSize,Timeout(51))
   ws.run "mshta.exe " & PathOutPutHTML
Else
Set oShell = CreateObject("Shell.Application")
Set oFolder = oShell.Namespace(stRep)
Set oFichier = oFolder.Items.Item(stFichier)
Dimensions = oFolder.GetDetailsOf(oFichier,31)
arrSize = Split(Dimensions,"x")
intLength = Len(arrSize(0))
intHorizontalSize = Right(arrSize(0),intLength -1)
intLength = Len(arrSize(1))
intVerticalSize = Left(arrSize(1),intLength - 1)
   Call LoadImage(Srcimage,intHorizontalSize,intVerticalSize,Timeout(51))
   ws.run "mshta.exe " & PathOutPutHTML
End If
'********************************************************************************************************
Function TimeOut(T)
   TimeOut = T * 1000
End Function
'********************************************************************************************************
Sub LoadImage(Srcimage,intHorizontalSize,intVerticalSize,TimeOut)
   fhta.WriteLine "<html>"
   fhta.WriteLine "   <hta:application id=""oHTA"" "
   fhta.WriteLine "     border=""none"" "
   fhta.WriteLine "     caption=""no"" "
   fhta.WriteLine "     contextmenu=""no"" "
   fhta.WriteLine "     innerborder=""no"" "
   fhta.WriteLine "     scroll=""no"" "
   fhta.WriteLine "     showintaskbar=""no"" "
   fhta.WriteLine "   />"
   fhta.WriteLine "<style>"
   fhta.WriteLine "{ margin: 0; padding: 0; }"
   fhta.WriteLine "body {background: url(" & DblQuote(Srcimage) & ") no-repeat center center fixed;}"
   fhta.WriteLine "</style>"
   fhta.WriteLine "   <script language=""VBScript"">"
   fhta.WriteLine "     Sub Window_OnLoad()"
   fhta.WriteLine "       width = " & intHorizontalSize
   fhta.WriteLine "       height = " & intVerticalSize
   fhta.WriteLine "       window.resizeTo width, height"
   fhta.WriteLine "       window.moveTo screen.availWidth\2 - width\2, screen.availHeight\2 - height\2"
   fhta.WriteLine "       idTimer = window.setTimeout(""vbscript:window.close"","& TimeOut &")"
   fhta.WriteLine "        window.setInterval ""setfocus()"",100"
   fhta.WriteLine "     End Sub"
   fhta.WriteLine "     Function setfocus"
   fhta.WriteLine "       Window.Focus()"
   fhta.WriteLine "     End Function"
   fhta.WriteLine "   </script>"
   fhta.WriteLine "<body>"
   fhta.WriteLine "<bgsound src=""http://upload.wikimedia.org/wikipedia/commons/2/23/Humat_al-Hima.ogg"">"
   fhta.WriteLine "</body>"
   fhta.WriteLine "</html>"
End Sub
'**********************************************************************************************
Function DblQuote(Str)
   DblQuote = Chr(34) & Str & Chr(34)
End Function
'**********************************************************************************************
Sub DownloadingFile(URL,strHDLocation)
Dim Titre,objFSO,Ws,objXMLHTTP,PathScript,Tab,objADOStream,Command,Start,File
Dim MsgTitre,MsgAttente,StartTime,DurationTime,ProtocoleHTTP
Set objFSO = Createobject("Scripting.FileSystemObject")
Set Ws = CreateObject("wscript.Shell")
ProtocoleHTTP = "http://"
If Left(URL,7) <> ProtocoleHTTP Then
URL = ProtocoleHTTP & URL
End if
Tab = split(url,"/")
File =  Tab(UBound(Tab))
File = Replace(File,"%20"," ")
File = Replace(File,"%28","(")
File = Replace(File,"%29",")")
   Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP.3.0")
   strHDLocation = PathScript & "\" & File
   On Error Resume Next
  objXMLHTTP.open "GET",URL,false
   objXMLHTTP.send()
If Err.number <> 0 Then
  MsgBox err.description,16,err.description
  Exit Sub
  Else
  If objXMLHTTP.Status = 200 Then
  strHDLocation = Temp & "\" & File
  Set objADOStream = CreateObject("ADODB.Stream")
  objADOStream.Open
  objADOStream.Type = 1 'adTypeBinary
  objADOStream.Write objXMLHTTP.ResponseBody
  objADOStream.Position = 0  'Set the stream position to the start
  objADOStream.SaveToFile strHDLocation,2 '2=adSaveCreateOverWrite
  objADOStream.Close
  Set objADOStream = Nothing
  End If
End if
Set objXMLHTTP = Nothing
End Sub



回答2:


@Hackoo you always have these WOW codes , i mean i never tough i can face something like that, and also thx for the quick reply and help, i may use that but basically i think i found something interesting and that works, and much easier than the code you posted , i'll let the code talk :
note this code need 3 file {"data/background.jpg" and "data/1.mp3"} and the hta file as "new2.hta"

<html>
<head>

<script Language="VBScript">


Sub window_onload
 window.setTimeout"Script", 3000, "VBScript"
End Sub


Sub Script
Set obj=CreateObject("Wscript.shell")
obj.run "new2.hta"
Self.close
End Sub

</script>
<HTA:APPLICATION
border="none"
InnerBorder="no">
<title>title is useless here :D</title>
<style type="text/css">
.bg {background-image:url(data/background.jpg)}
</style>
</head>
<body class="bg">
<embed src="data/1.mp3" hidden="true" loop="false" autostart="1">
</body>
</html>

actually i'm not sure if this is gonna work on other computers but it does work on windows XP , and yeah thanks for the help @Hackoo you're Awesome :D NOTE: for people copying this code make sure to change variable and resize the window to the proper size for the image ;)




回答3:


This another an old example that i made, hope that it will work for you on your windows xp.just give a try and tell me the result.

The effect is like in this video ==> https://www.youtube.com/watch?v=3OQdJT6xVqo

SplashScreen.vbs

The advantage of this code is that it can be used in any application written in Vbscript and is easily editable and customizable. So just call the procedure SplashScreen foremost Main program! and voila (-_°)

'The advantage of this code is that it can be used in any application written in Vbscript and is easily editable and customizable!
'So just call the procedure SplashScreen foremost Main program! and voila (-_°)
'Un Splash Screen ou bien un écran d'acceuil en Vbscript en utilisant la puissance du HTML Application [HTA] Réalisé par © Hackoo © le 02/01/2012
'L'avantage de ce code est qu'il est utilisable dans n'importe quelle Application écrite en Vbscript et il est facilement modifiable et personnalisable !
'Donc il suffit d'appeller la procédure SplashScreen avant tout programme Principal ! et le tour est joué (-_°)
'**************************************************************************************************
Call SplashScreen
Call MainProgram
'**************************************************************************************************
Sub SplashScreen()
Dim shell : Set shell = CreateObject("WScript.Shell")
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
Dim tempFolder : Set tempFolder = fso.GetSpecialFolder(2)
Dim SplashName : SplashName = "Splash.hta"
Dim tempFile : Set tempFile = tempFolder.CreateTextFile(SplashName)
tempFile.Writeline "<html>"
tempFile.Writeline "<head>"
tempFile.Writeline "<bgsound src=""http://hackoo.alwaysdata.net/Matrix.mp3"" loop=""infinite"">"
tempFile.Writeline "<title>Splash Screen</title>"
tempFile.Writeline "<HTA:APPLICATION ID=""Splash Screen"""
tempFile.Writeline "APPLICATIONNAME=""Splash Screen"""
tempFile.Writeline "BORDER=""none"""
tempFile.Writeline "CAPTION=""no"""
tempFile.Writeline "SHOWINTASKBAR=""no"""
tempFile.Writeline "SINGLEINSTANCE=""yes"""
tempFile.Writeline "SYSMENU=""no"""
tempFile.Writeline "SCROLL=""no"""
tempFile.Writeline "WINDOWSTATE=""normal"">"
tempFile.Writeline "<link rel=""stylesheet"" media=""screen"" type=""text/css"" title=""design_encoder"" href=""http://hackoo.alwaysdata.net/design_encoder.css""/>"
tempFile.Writeline "</head>"
tempFile.Writeline"<SCRIPT LANGUAGE=""VBScript"">"
tempFile.Writeline "Sub CenterWindow(x,y)"        
tempFile.Writeline     "window.resizeTo x, y"      
tempFile.Writeline     "iLeft = window.screen.availWidth/2 - x/2"      
tempFile.Writeline     "itop = window.screen.availHeight/2 - y/2"    
tempFile.Writeline       "window.moveTo ileft, itop"      
tempFile.Writeline "End Sub"    
tempFile.Writeline "Sub Window_OnLoad"
tempFile.Writeline      "CenterWindow 400,300"
tempFile.Writeline      "iTimerID = window.setInterval(""ShowSplash"", 120000)"
tempFile.Writeline "End Sub"
tempFile.Writeline "Sub ShowSplash"
tempFile.Writeline     "Splash.Style.Display = ""None"""
tempFile.Writeline     "Window.Close()"
tempFile.Writeline     "End Sub"
tempFile.Writeline "</SCRIPT>"
tempFile.Writeline "<body bgcolor=""black"">"
tempFile.Writeline "<DIV id=""Splash"">"
tempFile.Writeline "<CENTER>"
tempFile.Writeline "<p>"
tempFile.Writeline "<img src=""http://nsm05.casimages.com/img/2011/07/23//1107230741401311048506419.gif""/>"
tempFile.Writeline "<center onselectstart=""return false"" ondragstart=""return false"" oncontextmenu=""return false"">"
tempFile.Writeline  "<marquee DIRECTION=""UP"" HEIGHT=""200"" WIDTH=""350"" SCROLLAMOUNT=""3"" onselectstart=""return false"">"
tempFile.Writeline   "<center><font face=""Comic sans MS"" color=RED size=10><b><i> Splash Screen </i></b></font></center><br><br>"
tempFile.Writeline    "<center><font face=""Comic sans MS"" color=RED>This an example of Splash Screen</b></font></center>"
tempFile.Writeline "<br><center><font face=""Comic sans MS"" color=RED>By © Hackoo 2013<br><br></font></center><center><img src=""http://nsm05.casimages.com/img/2011/07/23//1107230741401311048506419.gif""></center></marquee>"
tempFile.Writeline "</center>"
tempFile.Writeline "</p>"
tempFile.Writeline "</CENTER>"
tempFile.Writeline "</DIV>"
tempFile.Writeline "</body>"
tempFile.Writeline "</html>"
tempFile.Writeline "tempFile.Close"
shell.Run tempFolder & "\" & SplashName,1,True
End Sub
'**************************************************************************************************
Sub MainProgram
MsgBox "Welcome! your in your main Program !"& VbCRLF & "Bienvenue ! dans votre Programme Principal !",64,"Programme Principal by © Hackoo 2013"
End Sub



回答4:


i'm an idiot !!!! after clicking post button by 2 seconds i remembered something about HTA:APPLICATION tag which is "InnerBorder" property !! sorry for wasting your time readers :D but it's pretty good to know about this, i guess !

EDIT : but this takes us to another problem which is "file opening Security check" , when i try to open the second file after displaying the first HTA/image file , it simply pops up a security window from IE, i did try to use

<a href="secondfile.hta">click here</a>

and that works perfectly with

<HTA:APPLICATION Navigable="yes"> option but the problem here again is that, i don't want to show the image with an annoying text link waiting to be clicked , to start the hta ! the question for this is :
How can i automate the click of < a> link< /a> ?
or if possible how can i get over this security popup ?



来源:https://stackoverflow.com/questions/29581832/display-image-with-no-border-before-starting-an-app-exe-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!