I want a multiple search in Google Images. I know that there is something like
clipboard := StrReplace(clipboard, "+", "%2B")
but how is it possible? Below is a code relating to the one-time search.
url_encoding(str)
{
f = %A_FormatInteger%
SetFormat, Integer, Hex
if RegExMatch(str, "^\w+:/{0,2}", pr)
StringTrimLeft, str, str, StrLen(pr)
StringReplace, str, str, `%, `%25, All
Loop
if RegExMatch(str, "i)[^\w\.~%/:]", char)
StringReplace, str, str, %char%, % "%" . SubStr(Asc(char),3), All
else break
SetFormat, Integer, %f%
return, pr . str
}
F3::
image_search:
a = `%
old_clipboard := ClipboardAll
clipboard := url_encoding(clipboard)
Run, "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --profile-directory="Profile 2" --force-wave-audio --incognito --new-window https://www.google.com/search?tbm=isch&as_q=%clipboard%, , Max
clipboard := old_clipboard
return
The change from %clipboard% to %A_LoopField% caused that https://www.google.com/imghp?tbm=isch&as_q= was opened when searching for abc. So I added the parsing Loop:
F3::
image_search:
a = `%
old_clipboard := ClipboardAll
Loop, parse, clipboard, `n, `r
{
clipboard := url_encoding(clipboard)
Run, "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --profile-directory="Profile 2" --force-wave-audio --incognito --new-window https://www.google.com/search?tbm=isch&as_q=%A_LoopField%, , Max
}
clipboard := old_clipboard
return
When I then opened
abc
123
the search queries were each opened in a new window. But these should only be opened in one new window. The goal is to exclude empty lines (also with whitespace) as well as whitespace before and after the search queries. Once this is done, url_encoding can be used to perform a correct search. In all these cases, the code just mentioned did not work. For example, if
abc & def
123 % 456
is in the clipboard, a new incognito window should show
abc & def
in tab 1 and
123 % 456
in tab 2.
url_encoding() added line breaks as
%D%A
because they were not excluded.
url_encoding(str)
{
f = %A_FormatInteger%
SetFormat, Integer, Hex
if RegExMatch(str, "^\w+:/{0,2}", pr)
StringTrimLeft, str, str, StrLen(pr)
StringReplace, str, str, `%, `%25, All
Loop
if RegExMatch(str, "i)[^\w\.~%/:\r\n]", char)
StringReplace, str, str, %char%, % "%" . SubStr(Asc(char),3), All
else break
SetFormat, Integer, %f%
return, pr . str
}
F3::
image_search:
old_clipboard := ClipboardAll
clipboard := RegExReplace(clipboard, "`am)^\s+")
clipboard := RegExReplace(clipboard, "`am)\s+$")
clipboard := url_encoding(clipboard)
Run, "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --profile-directory="Profile 2" --force-wave-audio --incognito --new-window, , Max
Sleep, 1000
Loop, parse, clipboard, `n, `r
{
Run, "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --profile-directory="Profile 2" --force-wave-audio --incognito https://www.google.com/search?tbm=isch&as_q=%A_LoopField%, , Max
Sleep, 500
}
clipboard := old_clipboard
return
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.