如何在vbscript中显示图像?

问题描述 投票:1回答:4

我想使用Vbscript编写每20分钟显示和成像的代码。是否可以使用VBscript加载图像?我发现LoadPicture()是一个选择。

图像应该每20分钟在我的桌面窗口中弹出一次。

如何使用?请帮我。预先感谢。

image vbscript
4个回答
3
投票

OK阿伦。这是我所做的

  1. 使用以下代码创建VBS文件

    Set objExplorer = CreateObject("InternetExplorer.Application")
    With objExplorer
        .Navigate "about:blank"
        .Visible = 1
        .Document.Title = "Show Image"
        .Toolbar=False
        .Statusbar=False
        .Top=400
        .Left=400
        .Height=200
        .Width=200
        .Document.Body.InnerHTML = "<img src='C:\Users\pankaj\Desktop\a.jpg'>"
    End With
    
  2. 转到Window的任务计划程序并创建任务

    • 创建触发器20分钟-每天重复一次
    • 将动作指定为启动程序->%systemroot%\ system32 \ cscript.exe->在参数给出VBS文件的位置

1
投票

您可以尝试使用此vbscript:

LoadImage.vbs

Option Explicit
If AppPrevInstance() Then 
    MsgBox "There is an existing proceeding !" & VbCrLF & CommandLineLike(WScript.ScriptName),VbExclamation,"There is an existing proceeding !"    
    WScript.Quit   
Else
    Dim ws,fso,Srcimage,Temp,PathOutPutHTML,fhta
    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)
    Srcimage = "http://img.xooimage.com/files86/6/3/b/encode-decode-37ceb55.jpg"
    Do
        Call LoadImage(Srcimage)
        ws.run "mshta.exe " & PathOutPutHTML
        Call Pause(20)
    Loop
End If
'********************************************************************************************************
Sub LoadImage(Srcimage)
    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 "    <script language=""VBScript"">"
    fhta.WriteLine "        Sub Window_OnLoad"
    fhta.WriteLine "            'Resize and position the window"
    fhta.WriteLine "            width = 760 : height = 580"
    fhta.WriteLine "            window.resizeTo width, height"
    fhta.WriteLine "            window.moveTo screen.availWidth\2 - width\2, screen.availHeight\2 - height\2"
    fhta.WriteLine "            'Automatically close the windows after 5 seconds"
    fhta.WriteLine "            idTimer = window.setTimeout(""vbscript:window.close"",10000)"
    fhta.WriteLine "        End Sub"
    fhta.WriteLine "    </script>"
    fhta.WriteLine "<body>"
    fhta.WriteLine "    <table border=0 width=""100%"" height=""100%"">"
    fhta.WriteLine "        <tr>"
    fhta.WriteLine "            <td align=""center"" valign=""middle"">"
    fhta.WriteLine "                <img src= "& Srcimage & ">"
    fhta.WriteLine "            </td>"
    fhta.WriteLine "        </tr>"
    fhta.WriteLine "    </table>"
    fhta.WriteLine "</body>"
    fhta.WriteLine "</html>"
End Sub
'**********************************************************************************************
Sub Pause(Min)
    Wscript.Sleep(Min*1000*60)
End Sub  
'**********************************************************************************************
Function AppPrevInstance()   
    With GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")   
        With .ExecQuery("SELECT * FROM Win32_Process WHERE CommandLine LIKE " & CommandLineLike(WScript.ScriptFullName) & _
            " AND CommandLine LIKE '%WScript%' OR CommandLine LIKE '%cscript%'")   
            AppPrevInstance = (.Count > 1)   
        End With   
    End With   
End Function   
'**************************************************************************
Function CommandLineLike(ProcessPath)   
    ProcessPath = Replace(ProcessPath, "\", "\\")   
    CommandLineLike = "'%" & ProcessPath & "%'"   
End Function
'**************************************************************************

0
投票
Set objExplorer = CreateObject ("InternetExplorer.Application")
Do
Wscript.sleep 1200000
with objExplorer
.Navigate "about:blank"
.Document.Title = "title goes here"
.ToolBar = 0
.StatusBar = 0
.Left = (intHorizontal - 200) / 2
.Top = (intVertical - 400) / 2
.Width = 200
.Height = 400
.Visible = 1             

.Document.Body.Style.Cursor = "default"

.Document.Body.InnerHTML = "<img src='C:\Users\Administrator\Desktop\Virus\Image.jpg'>"
End With
Loop

0
投票

我需要一些帮助,我知道这是一个老话题,所以如果有人可以帮助我,请先感谢!

我尝试了Hackoo的示例,但是效果很好,但是现在不会每20分钟显示一次图像!!

如何停止脚本运行?我只双击了test.vbs文件(带有Hackoo的代码)。

© www.soinside.com 2019 - 2024. All rights reserved.