带有URL引号的环绕剪贴板

时间:2019-02-12 13:17:08

标签: autohotkey

警告:我对此很陌生。

我想通过分配一个热键来搜索文本选择(在网络浏览器中)并用引号引起来(以获得完全匹配)来加快Google搜索的速度。

我尝试使用发现的一些代码,但到目前为止,我只能在Google上搜索所选文本,但不知道如何在搜索中用引号引起来。

^!d:: ;

prevClipboard := ClipboardAll
SendInput, ^c  
ClipWait, 1 
if !(ErrorLevel)  { 
    Clipboard := RegExReplace(RegExReplace(Clipboard, "\r?\n"," "), "(^\s+|\s+$)")
    If SubStr(ClipBoard,1,7)="http://"
Run, % Clipboard
else 
Run, % "https://www.google.com/search?q=" Clipboard
} 
Clipboard := prevClipboard
return

这只是打开带有剪贴板的Google搜索。 我不知道如何制作它,所以搜索“剪贴板”而不是剪贴板。

有什么建议吗?谢谢!

2 个答案:

答案 0 :(得分:1)

运行是命令,variables in commands必须用百分号括起来。

要包含引号,请两次指定两个连续的引号:

Run, http://www.google.com/search?q=""%Clipboard%""

答案 1 :(得分:0)

如果您想从任何选定的文本中进行“阶段google搜索” (并且从计算机系统的任何地方进行搜索)。

然后您可以尝试使用此AHK脚本。

您可以[选择任意文本],然后单击键盘设备上的[F1]键。

“计算机查找”会自动找出可在何处执行查询搜索(结果为100倍)以及必须使用的浏览器。

Example1.ahk

;#notrayicon
#SingleInstance force

GroupAdd, Browser, ahk_class Chrome_WidgetWin_1 ; Chrome or Iron
GroupAdd, Browser, ahk_class IEFrame            ; Internet Explorer
GroupAdd, Browser, ahk_class MozillaWindowClass ; FireFox
GroupAdd, Browser, ahk_class ApplicationFrameWindow ; Edge

; here you can change the variable into exact search [
quote1 = "
; here you can change the variable into exact search ]
quote2 = "

; here you can change the variables intitle: - inurl: - inanchor: - allinurl: - allinanchor:
insearch = allintitle:

; + = Shift
; ! = Alt
; ^ = Ctrl
; # = Win (Windows logo key)

esc::exitapp ;You can click the (esc) key to stop the script.

f1::
If WinActive("ahk_group Browser")
{
sendinput ^c ;copy the selected text to clipboard memory
sleep 150
sendinput ^t ;CTRL+t make a new tab + goto address bar - use CTRL+L for the active tab + goto address bar
sleep 150
texta = https://www.google.com/?gfe_rd=cr&gws_rd=cr#q=%insearch%%quote1%
textb = %clipboard%%quote2% ;selected text
textc = &lr=lang_us&hl=us&num=100 ; google parameters

clipboard=%texta%%textb%%textc%
sleep 150
sendinput ^v ; paste the selected text 
sleep 250
send {enter}
clipboard=%textb%
} else {
sendinput ^c ;copy the selected text to clipboard memory
sleep 150
texta = https://www.google.com/?gfe_rd=cr&gws_rd=cr#q=%insearch%%quote1%%quote1%
textb = %clipboard%%quote2%%quote2%%quote2% ;selected text
textc = &lr=lang_us&hl=us&num=100 ; google parameters

clipboard=%texta%%textb%%textc%
run %clipboard%
clipboard=%textb%
}

return