Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 如何为“创建新命令”;使用chrome打开URL搜索单词,方便在线学习英语;在窗户里_Windows_Batch File_Cmd_Vbscript - Fatal编程技术网

Windows 如何为“创建新命令”;使用chrome打开URL搜索单词,方便在线学习英语;在窗户里

Windows 如何为“创建新命令”;使用chrome打开URL搜索单词,方便在线学习英语;在窗户里,windows,batch-file,cmd,vbscript,Windows,Batch File,Cmd,Vbscript,我的朋友们。这些是我的要求: url由两部分组成: 第一部分是固定的: 另一部分是我想搜索的任何单词。例如“你好” 现在我只能通过输入这个命令打开字典网页 chrome https://www.oxfordlearnersdictionaries.com/definition/english/hello_1?q= 但我需要输入完整的URL,一步完成搜索 chrome https://www.oxfordlearnersdictionaries.com/definition/engli

我的朋友们。这些是我的要求:

url由两部分组成:

  • 第一部分是固定的:

  • 另一部分是我想搜索的任何单词。例如“你好”
现在我只能通过输入这个命令打开字典网页

chrome https://www.oxfordlearnersdictionaries.com/definition/english/hello_1?q=
但我需要输入完整的URL,一步完成搜索

chrome https://www.oxfordlearnersdictionaries.com/definition/english/hello_1?q=hello
但问题是:

  • comand太长了,如果我能用别名就好了。例如,
    dict hello
  • 每次我需要搜索的单词都不一样。 你能帮我实现这个命令行字典工具吗? 任何帮助都是非常有益的

尝试以下VBScript代码:

Dim sURL
Dim sSearch 
Dim objShell

sSearch = "hello"
sURL = "https://www.oxfordlearnersdictionaries.com/definition/english/" & sSearch & "_1?q=" & sSearch

set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "chrome.exe", sURL, "", "", 1
如果您想自动执行此操作,可以从中生成一个子集,并在迭代字典时调用它:

Dim iContinue
Dim sSearchString

sSearchString = "hello"
iContinue = vbYes

Do While iContinue = vbYes
    sSearchString = InputBox("Enter search string:", "Dictionary Lookup", sSearchString) 
    Search sSearchString
    iContinue = MsgBox("Would you like to make another search?", vbYesNo)
Loop

Sub Search(p_sSearchString)
    Dim sURL
    Dim objShell

    sURL = "https://www.oxfordlearnersdictionaries.com/definition/english/" & p_sSearchString & "_1?q=" & p_sSearchString

    Set objShell = CreateObject("Shell.Application")
    objShell.ShellExecute "chrome.exe", sURL, "", "", 1

End Sub

请尝试以下VBScript代码:

Dim sURL
Dim sSearch 
Dim objShell

sSearch = "hello"
sURL = "https://www.oxfordlearnersdictionaries.com/definition/english/" & sSearch & "_1?q=" & sSearch

set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "chrome.exe", sURL, "", "", 1
如果您想自动执行此操作,可以从中生成一个子集,并在迭代字典时调用它:

Dim iContinue
Dim sSearchString

sSearchString = "hello"
iContinue = vbYes

Do While iContinue = vbYes
    sSearchString = InputBox("Enter search string:", "Dictionary Lookup", sSearchString) 
    Search sSearchString
    iContinue = MsgBox("Would you like to make another search?", vbYesNo)
Loop

Sub Search(p_sSearchString)
    Dim sURL
    Dim objShell

    sURL = "https://www.oxfordlearnersdictionaries.com/definition/english/" & p_sSearchString & "_1?q=" & p_sSearchString

    Set objShell = CreateObject("Shell.Application")
    objShell.ShellExecute "chrome.exe", sURL, "", "", 1

End Sub

在批处理中,您可以执行以下操作:

@echo off
Mode 70,4 & color 0A
Title Open dictionary web page by input 
Set "URL=https://www.oxfordlearnersdictionaries.com/definition/english/"
:Main
cls
echo(
echo Type the word to search in dictionary
set /P "Dict="
Start "" Chrome "%URL%%Dict%"
TimeOut /T 1 /NoBreak>nul
Goto:Main

在批处理中,您可以执行以下操作:

@echo off
Mode 70,4 & color 0A
Title Open dictionary web page by input 
Set "URL=https://www.oxfordlearnersdictionaries.com/definition/english/"
:Main
cls
echo(
echo Type the word to search in dictionary
set /P "Dict="
Start "" Chrome "%URL%%Dict%"
TimeOut /T 1 /NoBreak>nul
Goto:Main

第一个没有弹出窗口的只能搜索固定的“hello”,因为我不知道如何输入新单词。除了第一次使用后关闭外,该弹出窗口是否还可能在下次搜索时保持活动状态?是的,您可以让它再次显示
输入框
,直到用户清除文本或再次搜索相同的文本。你可以用很多方法来解决这个问题。。。阅读VBScript中的
Do While
循环。如果你的循环需要帮助,你可以发布一个新问题。第一个没有弹出窗口的问题只能搜索固定的“你好”,因为我不知道如何输入新单词。顺便说一句。除了第一次使用后关闭外,该弹出窗口是否还可能在下次搜索时保持活动状态?是的,您可以让它再次显示
输入框
,直到用户清除文本或再次搜索相同的文本。你可以用很多方法来解决这个问题。。。阅读VBScript中的
Do While
循环。如果在循环方面需要帮助,您可以发布一个新问题。它在我的本地测试中有编译错误。D:\luxer\dict.vbs(1,1)Microsoft VBScript编译器错误:无效字符。请将其另存为dict.bat,因为它是批处理文件而不是VBScript文件!是的。另存为.bat文件对我来说也很酷。非常感谢您,我的本地测试中出现了编译错误。D:\luxer\dict.vbs(1,1)Microsoft VBScript编译器错误:无效字符。请将其另存为dict.bat,因为它是批处理文件而不是VBScript文件!是的。另存为.bat文件对我来说也很酷。非常感谢你