- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是我一直在编写的代码,但不起作用。我希望它执行搜索并查看同一目录中名为“info”的文件夹。
<html>
<head>
<title>Application Executer</title>
<HTA:APPLICATION ID="oMyApp"
APPLICATIONNAME="Application Executer"
WINDOWSTATE="normal">
<script type="text/javascript" language="javascript">
function RunFile() {
WshShell = new ActiveXObject("WScript.Shell");
WshShell.Run("explorer.exe search-ms://query=somethinginapdf", 1, false);
}
</script>
</head>
<body>
<input type="button" value="Windows Search" onclick="RunFile();"/>
</body>
</html>
最佳答案
用这个 vbscript 尝试一下:
'**********************************************************************************
'Description du script VBS : Rechercher dans le contenu des fichiers de type texte
'**********************************************************************************
'En balayant les fichiers de type "fichiers texte" (fichiers ".txt",".htm",".asp",".php",".rtf",".html",".htm",".hta",".xml",".csv",".vbs" etc...),
'de les ouvrir les uns après les autres pour en extraire la portion de texte contenant le mot recherché.
'Le petit moteur peut toutefois rendre service pour explorer (en local) de petits sites Intranet (sans indexation préalable des pages).
'Code Original ==> http://jacxl.free.fr/cours_xl/vbs/moteur_rech.vbs
'***************************************************************************************************************************************************************
'- Mise à jour par Hackoo en 19/12/2013
'- Ajout d'une fonction pour parcourir le dossier à traiter par la fonction BrowseForFolder afin de rendre le script plus convivial et facile à manipuler
'- le résultat de la recherche est dans un fichier de type HTA au lieu dans un fichier de type HTML crée dans le dossier temporaire
'- Ajout de la fonction Explore() intégré dans le HTA pour explorer chaque fichier à part dans l'explorateur Windows
'- Ajout de la fonction HtmlEscape()
'***************************************************************************************************************************************************************
'- Mise à jour par Hackoo en 07/03/2014
'- Ajout d'une barre d'attente en HTA lors de la recherche pour faire patienter l'utilisateur
'***************************************************************************************************************************************************************
On Error Resume Next
Dim ws,Titre,MsgTitre,MsgAttente,oExec,Temp,Copyright,Size
dim tabl()
dim tablold()
redim tabl(1)
tabl(0)="jetpack"
num=1
nbtot=0
nboct=0
nbssrep=0
Copyright = "(Version modifié © Hackoo)"
Titre = "Recherche dans le contenu des fichiers de type texte " & Copyright
Set fs = CreateObject("Scripting.FileSystemObject")
Set ws = CreateObject("wscript.Shell")
Temp = ws.ExpandEnvironmentStrings("%Temp%")
'choix du répertoire
nomrep = Parcourir_Dossier()
'choix du mot recherché
mot_cherch=inputbox("Taper le mot pour effectuer la recherche ?",Titre,"Wscript")
MsgTitre = "Recherche dans le contenu des fichiers de type texte " & Copyright
MsgAttente = "Veuillez patienter.la recherche du mot <FONT COLOR='yellow'><B>" & DblQuote(mot_cherch) & "</B></FONT> est en cours..."
If mot_cherch = "" Then WScript.Quit
'traiter le cas où nomrep est un disque ou un nom non valide
'if not fs.folderexists(nomrep) then 'or ucase(fs.getdrivename(nomrep))=ucase(replace(nomrep,"\","")) then
' MsgBox "nom de répertoire non valide"
' wscript.quit
'end if
tabl(1)=nomrep
'créer le fichier texte et l'ouvrir en appending
Dim tempFolder : Set tempFolder = fs.GetSpecialFolder(2)
Dim tempfile : tempFile = tempFolder & "\liste_fichiers.hta"
'msgbox tempFile
fichresult = tempFile
Set nouv_fich = fs.OpenTextFile(fichresult,2,true,-1)
nouv_fich.close
Set nouv_fich = fs.OpenTextFile(fichresult,8,false,-1)
Call CreateProgressBar(MsgTitre,MsgAttente)'Creation de barre de progression
Call LancerProgressBar()'Lancement de la barre de progression
StartTime = Timer 'Debut du Compteur Timer
nouv_fich.writeline("<html><title>"&Titre&"</title><HTA:APPLICATION SCROLL=""yes"" WINDOWSTATE=""Maximize""icon=""verifier.exe"">"&_
"<meta content=""text/html; charset=UTF-8"" http-equiv=""content-type"">"&_
"<body text=white bgcolor=#1234568><style type='text/css'>"&_
"a:link {color: #F19105;}"&_
"a:visited {color: #F19105;}"&_
"a:active {color: #F19105;}"&_
"a:hover {color: #FF9900;background-color: rgb(255, 255, 255);}"&_
"</style>")
nouv_fich.writeline "<SCRIPT LANGUAGE=""VBScript"">"
nouv_fich.writeline "Function Explore(filename)"
nouv_fich.writeline "Set ws=CreateObject(""wscript.Shell"")"
nouv_fich.writeline "ws.run ""Explorer /n,/select,""&filename&"""""
nouv_fich.writeline "End Function"
nouv_fich.writeline "</script>"
'boucler sur les niveaux jusqu'à ce qu'il n'y ait
'plus de sous répertoires dans le niveau
do while num>0 '------------------------------------
'recopie tabl
redim tablold(ubound(tabl))
for n=0 to ubound(tabl)
tablold(n)=tabl(n)
next
'réinitialiser tabl
redim tabl(0)
tabl(0)="zaza"
'explorer le ss répertoire
for n=1 to ubound(tablold)
expl(tablold(n)) 'ajoute ds le tableau tabl les ss rep de tablold(n)
next
loop '----------------------------------------------
nouv_fich.writeline("</BODY></HTML>")
nouv_fich.close
Call FermerProgressBar()'Fermeture de barre de progression
DurationTime = FormatNumber(Timer - StartTime, 0) & " seconds." 'La duree de l'execution du script
Set Dossier = fs.getfolder(nomrep)
SizeKo = Round(FormatNumber(Dossier.Size)/(1024),2) & " Ko" 'Taille en Ko avec 2 chiffres apres la Virgule
SizeMo = Round(FormatNumber(Dossier.Size)/(1048576),2) & " Mo" 'Taille en Mo avec 2 chiffres apres la Virgule
SizeGo = Round(FormatNumber(Dossier.Size)/(1073741824),2) & " Go" 'Taille en Go avec 2 chiffres apres la Virgule
If Dossier.size < 1024 Then
Size = Dossier.size & " Octets"
elseif Dossier.size < 1048576 Then
Size = SizeKo
elseif Dossier.size < 1073741824 Then
Size = SizeMo
else
Size = SizeGo
end If
set nouv_fich=nothing
If Err <> 0 Then
'MsgBox Err.Number & VbCrLF & Err.Description,16,MsgTitre
On Error GoTo 0
End if
'nboct2= int(fs.getfolder(nomrep).size/1024/1024)
set fs=nothing
'afficher le résultat dans un Popup
Ws.Popup "La recherche est terminée en "& DurationTime & " !"& vbCr &_
"Recherche effectuée dans " & vbCrLF & nbtot & " fichiers pour " & Size & " dans " & DblQuote(nomrep) &_
" et ses " & nbssrep & " sous-répertoires (total " & Size & ")","6",MsgTitre,64
Set sh = CreateObject("WScript.Shell")
sh.run "explorer " & fichresult
set sh=nothing
'*************************************************************************
Function Parcourir_Dossier()
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(0, "Veuillez choisir un dossier pour la recherche " & Copyright,1,"c:\Programs")
If objFolder Is Nothing Then
Wscript.Quit
End If
NomDossier = objFolder.title
Parcourir_Dossier = objFolder.self.path
end Function
'*************************************************************************
sub expl(nomfich)
'ajoute dans le tableau tabl() tous les sous répertoires de nomfich
'et ajoute dans le fichier nouv_fich les noms des fichiers et leurs caractéristiques
Set rep=fs.getFolder(nomfich)
num=ubound(tabl)
'parcourir les sous répertoires de nomfich
for each ssrep in rep.subfolders
num=num+1
redim preserve tabl(num)
tabl(num)= ssrep.path
nbssrep=nbssrep+1
next
'parcourir les fichiers de nomfich
for each fich in rep.files
nbtot=nbtot+1
nboct=nboct+fich.size
'**********************************************************************************************************************************************************************************************
'chercher dans le fichier (vous pouvez commenter cette ligne si vous voulez juste afficher les fichiers qui contient seulement le mot à rechercher)
'nouv_fich.writeline fich.path & "<br><FONT COLOR=""yellow""><B>(" & int(fich.size/1024) & " ko, créé " & fich.DateCreated & ", acc " & fich.DateLastAccessed & ")</B></FONT><br>"
'**********************************************************************************************************************************************************************************************
Dim Ext
'ici dans ce tableau vous pouvez ajouter d'autres extensions de type texte
Ext = Array(".txt",".asp",".php",".rtf",".html",".htm",".hta",".xml",".csv",".vbs",".js",".css",".ini",".inf")
For i=LBound(Ext) To UBound(Ext)
if instr(lcase(fich.name),Ext(i)) > 0 Then
Set fich_sce = fs.OpenTextFile(fich.path,1,false,-2)
txtlu=fich_sce.readall
txtlu = HtmlEscape(txtlu)
fich_sce.close
'txtlu=tt(txtlu)
pos=instr(lcase(txtlu),lcase(mot_cherch))
if pos>0 then
nouv_fich.writeline ("<HR><A href=""#"" OnClick='Explore("""& fich.Path & """)'>" & fich.Path & "</A>")
do while pos>0
nbav=50
if pos-1<nbav then nbav=pos-1
nbapr=50
if len(txtlu)-pos-len(mot_cherch)+1<nbapr then nbapr=len(txtlu)-pos-len(mot_cherch)+1
txx= tt(mid(txtlu,pos-nbav,nbav)) & "<FONT COLOR='Yellow'><B>" & tt(mid(txtlu,pos,len(mot_cherch))) & "</B></FONT>" & mid(txtlu,pos+len(mot_cherch),nbapr)
if nbav=50 then txx="..." & txx
if nbapr=50 then txx=txx & "..."
txx="<BR> " & txx
nouv_fich.writeline txx
txtlu=right(txtlu,len(txtlu)-pos+1-len(mot_cherch))
pos=instr(lcase(txtlu),lcase(mot_cherch))
loop
end if
end if
next
next
set rep=nothing
end sub
'*************************************************************************
function tt(txte)
tt=txte
tt=replace(tt,"<","<")
tt=replace(tt,">",">")
end function
'*************************************************************************
Function HtmlEscape(strRawData)
'http://alexandre.alapetite.fr/doc-alex/alx_special.html
Dim strHtmlEscape
strHtmlEscape = strRawData
strHtmlEscape = Replace(strHtmlEscape, "&", "&")
strHtmlEscape = Replace(strHtmlEscape, "<", "<")
strHtmlEscape = Replace(strHtmlEscape, ">", ">")
strHtmlEscape = Replace(strHtmlEscape, """", """)
strHtmlEscape = Replace(strHtmlEscape, "à", "à")
strHtmlEscape = Replace(strHtmlEscape, "è", "è")
strHtmlEscape = Replace(strHtmlEscape, "é", "é")
strHtmlEscape = Replace(strHtmlEscape, "©", "©")
strHtmlEscape = Replace(strHtmlEscape, "ê", "ê")
'strHtmlEscape = Replace(strHtmlEscape, vbCrLf, "<br>")
'strHtmlEscape = Replace(strHtmlEscape, vbCr, "<br>")
'strHtmlEscape = Replace(strHtmlEscape, vbLf, "<br>")
'strHtmlEscape = Replace(strHtmlEscape, vbTab, " ")
'strHtmlEscape = Replace(strHtmlEscape, " ", " ")
HtmlEscape = strHtmlEscape
End Function
'****************************************************************************************************
Sub CreateProgressBar(Titre,MsgAttente)
Dim ws,fso,f,f2,ts,ts2,Ligne,i,fread,LireTout,NbLigneTotal,Temp,PathOutPutHTML,fhta,oExec
Set ws = CreateObject("wscript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Temp = WS.ExpandEnvironmentStrings("%Temp%")
PathOutPutHTML = Temp & "\Barre.hta"
Set fhta = fso.OpenTextFile(PathOutPutHTML,2,True)
fhta.WriteLine "<HTML>"
fhta.WriteLine "<HEAD>"
fhta.WriteLine "<Title> " & Titre & "</Title>"
fhta.WriteLine "<HTA:APPLICATION"
fhta.WriteLine "ICON = ""magnify.exe"" "
fhta.WriteLine "BORDER=""THIN"" "
fhta.WriteLine "INNERBORDER=""NO"" "
fhta.WriteLine "MAXIMIZEBUTTON=""NO"" "
fhta.WriteLine "MINIMIZEBUTTON=""NO"" "
fhta.WriteLine "SCROLL=""NO"" "
fhta.WriteLine "SYSMENU=""NO"" "
fhta.WriteLine "SELECTION=""NO"" "
fhta.WriteLine "SINGLEINSTANCE=""YES"">"
fhta.WriteLine "</HEAD>"
fhta.WriteLine "<BODY text=""white""><CENTER><DIV><SPAN ID=""ProgressBar""></SPAN>"
fhta.WriteLine "<span><marquee DIRECTION=""LEFT"" SCROLLAMOUNT=""3"" BEHAVIOR=ALTERNATE><font face=""Comic sans MS"">" & MsgAttente &"</font></marquee></span></DIV></CENTER></BODY></HTML>"
fhta.WriteLine "<SCRIPT LANGUAGE=""VBScript""> "
fhta.WriteLine "Set ws = CreateObject(""wscript.Shell"")"
fhta.WriteLine "Temp = WS.ExpandEnvironmentStrings(""%Temp%"")"
fhta.WriteLine "Sub window_onload()"
fhta.WriteLine " CenterWindow 480,90"
fhta.WriteLine " Self.document.bgColor = ""1234568"" "
fhta.WriteLine " End Sub"
fhta.WriteLine " Sub CenterWindow(x,y)"
fhta.WriteLine " Dim iLeft,itop"
fhta.WriteLine " window.resizeTo x,y"
fhta.WriteLine " iLeft = window.screen.availWidth/2 - x/2"
fhta.WriteLine " itop = window.screen.availHeight/2 - y/2"
fhta.WriteLine " window.moveTo ileft,itop"
fhta.WriteLine "End Sub"
fhta.WriteLine "</script>"
fhta.close
End Sub
'**********************************************************************************************
Sub LancerProgressBar()
Set oExec = Ws.Exec("mshta.exe " & Temp & "\Barre.hta")
End Sub
'**********************************************************************************************
Sub FermerProgressBar()
oExec.Terminate
End Sub
'**********************************************************************************************
Function DblQuote(Str)
DblQuote = Chr(34) & Str & Chr(34)
End Function
'**********************************************************************************************
关于javascript - 是否可以使用 JavaScript 对 HTA 执行 Windows 资源管理器搜索?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22854627/
我有一个 html 格式的表单: 我需要得到 JavaScript在value input 字段执行,但只能通过表单的 submit .原因是页面是一个模板所以我不控制它(不能有
我管理的论坛是托管软件,因此我无法访问源代码,我只能向页面添加 JavaScript 来实现我需要完成的任务。 我正在尝试用超链接替换所有页面上某些文本关键字的第一个实例。我还根据国家/地区代码对这些
我正在使用 JS 打开新页面并将 HTML 代码写入其中,但是当我尝试使用 document.write() 在新页面中编写 JS 时功能不起作用。显然,一旦看到 ,主 JS 就会关闭。用于即将打开的
提问不是为了解决问题,提问是为了更好地理解系统 专家!我知道每当你将 javascript 代码输入 javascript 引擎时,它会立即由 javascript 引擎执行。由于没有看过Engi
我在一个文件夹中有两个 javascript 文件。我想将一个变量的 javascript 文件传递到另一个。我应该使用什么程序? 最佳答案 window.postMessage用于跨文档消息。使
我有一个练习,我需要输入两个输入并检查它们是否都等于一个。 如果是 console.log 正则 console.log false 我试过这样的事情: function isPositive(fir
我正在做一个Web应用程序,计划允许其他网站(客户端)在其页面上嵌入以下javascript: 我的网络应用程序位于 http://example.org 。 我不能假设客户端网站的页面有 JQue
目前我正在使用三个外部 JS 文件。 我喜欢将所有三个 JS 文件合而为一。 尽一切可能。我创建 aio.js 并在 aio.js 中 src="https://code.jquery.com/
我有例如像这样的数组: var myArray = []; var item1 = { start: '08:00', end: '09:30' } var item2 = {
所以我正在制作一个 Chrome 扩展,它使用我制作的一些 TamperMonkey 脚本。我想要一个“主”javascript 文件,您可以在其中包含并执行其他脚本。我很擅长使用以下行将其他 jav
我有 A、B html 和 A、B javascript 文件。 并且,如何将 A JavaScript 中使用的全局变量直接移动到 B JavaScript 中? 示例 JavaScript) va
我需要将以下整个代码放入名为 activate.js 的 JavaScript 中。你能告诉我怎么做吗? var int = new int({ seconds: 30, mark
我已经为我的 .net Web 应用程序创建了母版页 EXAMPLE1.Master。他们的 I 将值存储在 JavaScript 变量中。我想在另一个 JS 文件中检索该变量。 示例1.大师:-
是否有任何库可以用来转换这样的代码: function () { var a = 1; } 像这样的代码: function () { var a = 1; } 在我的浏览器中。因为我在 Gi
我收到语法缺失 ) 错误 $(document).ready(function changeText() { var p = document.getElementById('bidp
我正在制作进度条。它有一个标签。我想调整某个脚本完成的标签。在找到可能的解决方案的一些答案后,我想出了以下脚本。第一个启动并按预期工作。然而,第二个却没有。它出什么问题了?代码如下: HTML:
这里有一个很简单的问题,我简单的头脑无法回答:为什么我在外部库中加载时,下面的匿名和onload函数没有运行?我错过了一些非常非常基本的东西。 Library.js 只有一行:console.log(
我知道 javascript 是一种客户端语言,但如果实际代码中嵌入的 javascript 代码以某种方式与在控制台上运行的代码不同,我会尝试找到答案。让我用一个例子来解释它: 我想创建一个像 Mi
我如何将这个内联 javascript 更改为 Unobtrusive JavaScript? 谢谢! 感谢您的回答,但它不起作用。我的代码是: PHP js文件 document.getElem
我正在寻找将简单的 JavaScript 对象“转储”到动态生成的 JavaScript 源代码中的最优雅的方法。 目的:假设我们有 node.js 服务器生成 HTML。我们在服务器端有一个对象x。
我是一名优秀的程序员,十分优秀!