请将一段简单的VB代码转换成VBS

请将一段简单的VB代码转换成VBS,第1张

call main

Sub Main()

Dim FileName, lujing

For Each FileName In wscript.arguments

lujing = GetTargetPath(FileName)

MsgBox lujing

Next

End Sub

Function GetTargetPath(LinkName)

On Error Resume Next

dim strPath,i

i = instrrev(linkname,chr(92))

strPath = left(linkname,i-1)

Dim Obj

Set Obj = CreateObject("WScript.Shell")

obj.Run strpath,1

GetTargetPath = strpath

set obj = nothing

End Function

把它保存为VBS文件,再随便拖个文件到这个脚本文件上测试下是不是这个效果

VB语言(包括VB、VBScript、VBS、VBA等所有VB家族的成员)的注释符号是单引号',不是//*

所以你把所有 //* 换成 ' 就行了,比如:

on error resume next//*容错语句,即使下面有错误也继续执行

改为

on error resume next'容错语句,即使下面有错误也继续执行

当然,你把注释语句删掉也可以

Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)

Private Sub Command1_Click()

Dim wsh

Set wsh = CreateObject("WScript.Shell")

Sleep 3000

wsh.SendKeys "{1}"

Sleep 50

wsh.SendKeys "{2}"

Sleep 50

wsh.SendKeys "{3}"

Sleep 50

wsh.SendKeys "{4}"

Sleep 50

wsh.SendKeys "{5}"

Sleep 50

wsh.SendKeys "{6}"

Sleep 50

wsh.SendKeys "{7}"

Sleep 50

wsh.SendKeys "{8}"

Sleep 50

wsh.SendKeys "{9}"

Sleep 50

wsh.SendKeys "{tab}"

Sleep 50

wsh.SendKeys "{9}"

Sleep 50

wsh.SendKeys "{8}"

Sleep 50

wsh.SendKeys "{7}"

Sleep 50

wsh.SendKeys "{6}"

Sleep 50

wsh.SendKeys "{5}"

Sleep 50

wsh.SendKeys "{4}"

Sleep 50

wsh.SendKeys "{3}"

Sleep 50

wsh.SendKeys "{2}"

Sleep 50

wsh.SendKeys "{1}"

Sleep 50

wsh.SendKeys "{0}"

Sleep 50

wsh.SendKeys "{Enter}"


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/tougao/12015279.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-20
下一篇2023-05-20

发表评论

登录后才能评论

评论列表(0条)

    保存