如何在 windows 中为 "use chrome to open a URL to search a word to learn English online conveniently" 创建新命令
how to create a new command to "use chrome to open a URL to search a word to learn English online conveniently" in windows
我的朋友们。这些是我的要求:
url有两部分:
- 第一部分已修复:
https://www.oxfordlearnersdictionaries.com/definition/english/hello_1?q=
- 另一部分是我要搜索的任何单词。例如"hello"
现在只能输入这个指令打开词典网页
chrome https://www.oxfordlearnersdictionaries.com/definition/english/hello_1?q=
但我需要输入完整的 URL 才能一步完成搜索。
chrome https://www.oxfordlearnersdictionaries.com/definition/english/hello_1?q=hello
但问题是:
- 命令太长了,要是能用个别名就好了。例如
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
如果您想自动执行此操作,您可以从中创建一个 Sub 并在遍历字典时调用它:
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
我的朋友们。这些是我的要求:
url有两部分:
- 第一部分已修复:
https://www.oxfordlearnersdictionaries.com/definition/english/hello_1?q=
- 另一部分是我要搜索的任何单词。例如"hello"
现在只能输入这个指令打开词典网页
chrome https://www.oxfordlearnersdictionaries.com/definition/english/hello_1?q=
但我需要输入完整的 URL 才能一步完成搜索。
chrome https://www.oxfordlearnersdictionaries.com/definition/english/hello_1?q=hello
但问题是:
- 命令太长了,要是能用个别名就好了。例如
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
如果您想自动执行此操作,您可以从中创建一个 Sub 并在遍历字典时调用它:
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