[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
打开百度搜索k.txt的第一行的批处理:
  1. @set /p k=<k.txt
  2. @start iexplore "http://www.baidu.cn/s?wd=%k%"
复制代码

TOP

  1. Option Explicit
  2. OpenBaidu GetRandomLine("k.txt")
  3. Sub OpenBaidu(sKey)
  4.         Dim oShell
  5.         Set oShell = CreateObject("WScript.Shell")
  6.         oShell.Run "iexplore http://www.baidu.cn/s?wd=" + sKey
  7.         Set oShell = Nothing
  8. End Sub
  9. Function GetRandomLine(sFile)
  10.         Dim oFso, oFile, iLineNo
  11.         Set oFso = CreateObject("Scripting.FileSystemObject")
  12.         Set oFile = oFso.OpenTextFile(sFile)
  13.         iLineNo = GetRandom(GetFileLineCount(sFile))
  14.         Do Until oFile.AtEndOfLine
  15.                 If iLineNo = oFile.Line Then
  16.                         GetRandomLine = oFile.ReadLine
  17.                         Exit Do
  18.                 Else
  19.                         oFile.SkipLine
  20.                 End If        
  21.         Loop
  22.         oFile.Close
  23.         Set oFile = Nothing
  24.         Set oFso = Nothing        
  25. End Function
  26. Function GetFileLineCount(sFile)
  27.         Dim oFso, oFile
  28.         Set oFso = CreateObject("Scripting.FileSystemObject")
  29.         Set oFile = oFso.OpenTextFile(sFile)
  30.         While Not oFile.AtEndOfLine
  31.                 oFile.SkipLine        
  32.         Wend
  33.         GetFileLineCount = oFile.Line
  34.         oFile.Close
  35.         Set oFile = Nothing
  36.         Set oFso = Nothing
  37. End Function
  38. Function GetRandom(n)
  39.         Randomize
  40.         GetRandom = Int(Rnd * n + 1)
  41. End Function
复制代码

[ 本帖最后由 rat 于 2008-11-23 15:40 编辑 ]

TOP

我是想要个VBS 打开百度输入关键字 然后回车

关键字是从配置文件sf.ini中随机输入 一行为一个关键字 ,N行随机输入

原帖由 xtavvf 于 2008-11-23 22:59 发表
非常感谢 版主 虽然不是我想要的 但是还要 感谢你


……,写剪切板再Sendkeys?思路不好。我给出的代码是完全符合你的要求的。

TOP

返回列表