键盘快捷键,用于搜索选定/突出显示的文本


17

在Chrome浏览器中,您可以突出显示网页上的某些文本,然后使用右键单击上下文菜单在新标签中打开google搜索所选文本。

如果我可以使用键盘快捷键而不是右键单击菜单来访问此功能,那将非常方便。我尝试搜索现有扩展名,并在以下位置搜索现有键盘快捷键的列表:https : //support.google.com/chrome/answer/157179?hl=zh_CN

有人知道实现此目标的方法吗?


有关Web浏览器功能的问题属于“ 超级用户”
ale

Answers:


9

在Chrome中可以使用:

  • 首先突出显示一些文本
  • 点击CTRL+ C-复制文本
  • 点击CTRL+ T-这将创建一个新标签并使其成为焦点
  • 点击CTRL+ V-将文本粘贴到多功能框中(Chrome默认将光标置于该框中)
  • 命中Enter-这将在多功能框中搜索文本

想要自动化吗?使用+ + 使用AutoHotKey将其设置为自动宏 使用以下脚本:CTRLAltS

^!s::
  Send ^c
  Send ^t
  Send ^v
  Send {Enter}
Return

仅供参考,我测试了此脚本,该脚本可在Chrome中运行。


6

我在AHK也有两个答案。

这是全球适用的任何地方(不仅适用于Chrome)。只需选择文本,然后按Windows+G

#g::  ;;Google selected text
   Send, ^c
   Run, http://www.google.com/search?q=%Clipboard%
Return

一个是我在这里的回答。选择文本,然后按Windows+ Shift+ G。区别在于它只是为您提供了剪贴板上的链接。

; Search google for the highlighted word
; then get the first link address and put it on the Clipboard

^!r:: Reload

#+g::
    bak = %clipboard%
    Send, ^c
    ;clipboard = %bak%`r`n%clipboard%
    Query = %clipboard%
    wb := ComObjCreate("InternetExplorer.Application")
    ;wb := IEGet()
    wb.Visible := false
    wb.Navigate("www.google.com/search?q=" Query)
    While wb.readyState != 4 || wb.document.readyState != "complete" || wb.busy ; wait for the page to load
      sleep 100
    ; loop % (Nodes := wb.document.getElementById("rso").childNodes).length
    ;     Links_urls .= (A_index = 1) ? Nodes[A_index-1].getElementsByTagName("a")[0].href : "`n" . Nodes[A_index-1].getElementsByTagName("a")[0].href
    ; Msgbox %Links_urls%

    Nodes := wb.document.getElementById("rso").childNodes
    First_link := Nodes[0].getElementsByTagName("a")[0].href
    Clipboard = %First_link%
    TrayTip, First Link on Google Search, %First_link% `r`n Ctrl+V to paste the link
return

第一个选项给了我最后一个Ctrl + C或Win +G。我不确定为什么吗?
josh

您必须先选择文本。那是我可以想到的获取最新剪辑的唯一原因,或者您正在使用剪贴板管理器?或尝试在Send, ^c命令后将其添加到脚本中以查看剪贴板上的内容TrayTip, Clipboard Contents, %clipboard% rn
Parivar Saraff

0


此扩展程序可以为您提供帮助:
https :
//chrome.google.com/webstore/detail/searchbar/fjefgkhmchopegjeicnblodnidbammed在安装后标记了这些选项:
*默认情况下,在新标签页中打开搜索结果(不影响热键;按Ctrl或中键-单击以切换新选项卡)
*默认情况下在前景中打开新选项卡(按Shift可在前景和背景之间切换)
现在您可以使用Ctrl + Shift + Alt + G快捷键运行搜索选定的文本


0

根据Parivar Saraff 这里提出的建议,这里有一个3合1 AutoHotKey脚本:

;Hotkey Modifier Symbols (for how to customize the hotkeys) https://www.autohotkey.com/docs/Hotkeys.htm#Symbols

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

;                               Google-search selected text
;  Usage:ctrl+shift+G
^+g::  
{
   Send, ^c
   Sleep 150
   Run, http://www.google.com/search?q=%Clipboard% ;(изм.себе на google.com.ua)
Return

}

;                               Google-dictionary selected text
;  Usage:ctrl+shift+D
^+d::
{
   Send, ^c
   Sleep 150
   Run, https://www.google.com/search?q=define:%Clipboard% ;(изм.себе на google.com.ua)
Return

}

;                           Wikipedia-search selected text by using google "site:" operator
;  Usage:ctrl+shift+W
^+w:: 
{
   Send, ^c
   Sleep 150
   Run, https://www.google.com/search?q=site:wikipedia.org %Clipboard% ;(изм.себе на google.com.ua)
Return

}

还突出显示了文本转换脚本(网络上此类脚本变体的组合):

;Hotkey Modifier Symbols (for how to customize the hotkeys) https://www.autohotkey.com/docs/Hotkeys.htm#Symbols


    ;Hotkey Modifier Symbols (for how to customize the hotkeys) https://www.autohotkey.com/docs/Hotkeys.htm#Symbols


#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.



cycleNumber := 1

#IfWinNotActive ahk_class XLMAIN

                                ;Highlighting any text, and then pressing that HotKey will cycle through the 4 most common text casings, converting the highlighted text right in-line.

                                    ;For example:

    ;If you highlight "This is a test sentence", and then hit that HotKey once, it'll make it all UPPERCASE ("THIS IS A TEST SENTENCE").
    ;Hit the HotKey again, it'll convert it to lowercase ("this is a test sentence").
    ;Hit it again and it'll convert it to Sentence case ("This is a test sentence"). (First letter is capitalized, rest is lower-case).
    ;Finally, hit it one more time and it'll convert it to Mixed case, or what I often call, "camel-case" ("This Is A Test Sentence"). (Each word is capitalized).

;  Usage:Ctrl+Shift+C
^+c:: 

If (cycleNumber==1)
{
ConvertUpper()
cycleNumber:= 2
}
Else If (cycleNumber==2)
{
ConvertLower()
cycleNumber:= 3
}
Else If (cycleNumber==3)
{
ConvertSentence()
cycleNumber:= 4
}
Else
{
ConvertMixed()
cycleNumber:= 1
}
Return

ConvertUpper()
{
    clipSave := Clipboard
    Clipboard = ; Empty the clipboard so that ClipWait has something to detect
    SendInput, ^c ; Copies selected text
    ClipWait
    StringReplace, Clipboard, Clipboard, `r`n, `n, All ; Fix for SendInput sending Windows linebreaks 
    StringUpper, Clipboard, Clipboard
    Len:= Strlen(Clipboard) ;Set number of characters ;Set number of characters
    SendInput, ^v ; Pastes new text
    Send +{left %Len%} ;Re-select text
    VarSetCapacity(clipSave, 0) ; Free memory
    Clipboard := clipSave ;Restore previous clipboard
}

ConvertLower()
{
    clipSave := Clipboard
    Clipboard = ; Empty the clipboard so that ClipWait has something to detect
    SendInput, ^c ; Copies selected text
    ClipWait
    StringReplace, Clipboard, Clipboard, `r`n, `n, All ; Fix for SendInput sending Windows linebreaks
    StringLower, Clipboard, Clipboard
    Len:= Strlen(Clipboard) ;Set number of characters
    SendInput, ^v ; Pastes new text
    Send +{left %Len%} ;Re-select text
    VarSetCapacity(clipSave, 0) ; Free memory
    Clipboard := clipSave ;Restore previous clipboard
}

ConvertSentence()
{
    clipSave := Clipboard
    Clipboard = ; Empty the clipboard so that ClipWait has something to detect
    SendInput, ^c ; Copies selected text
    ClipWait
    StringReplace, Clipboard, Clipboard, `r`n, `n, All ; Fix for SendInput sending Windows linebreaks
    StringLower, Clipboard, Clipboard
    Clipboard := RegExReplace(Clipboard, "(((^|([.!?]+\s+))[a-z])| i | i')", "$u1")
    Len:= Strlen(Clipboard) ;Set number of characters
    SendInput, ^v ; Pastes new text
    Send +{left %Len%} ;Re-select text
    VarSetCapacity(clipSave, 0) ; Free memory
    Clipboard := clipSave ;Restore previous clipboard
}

ConvertMixed()
{
    clipSave := Clipboard
    Clipboard = ; Empty the clipboard so that ClipWait has something to detect
    SendInput, ^c ; Copies selected text
    ClipWait
    StringReplace, Clipboard, Clipboard, `r`n, `n, All ; Fix for SendInput sending Windows linebreaks
    StringUpper Clipboard, Clipboard, T
    Len:= Strlen(Clipboard) ;Set number of characters
    SendInput, ^v ; Pastes new text
    Send +{left %Len%} ;Re-select text
    VarSetCapacity(clipSave, 0) ; Free memory
    Clipboard := clipSave ;Restore previous clipboard
}

#IfWinNotActive

                        ; Convert selected text to inverted case
                                    ;    Ex: THIS_is-a_tESt -> this_IS-A_TesT
; Usage:ctrl+Shift+I 
^+i::
    Convert_Inv()
RETURN
Convert_Inv()
{
    ; save original contents of clipboard
    Clip_Save:= ClipboardAll

    ; empty clipboard
    Clipboard:= ""

    ; copy highlighted text to clipboard
    Send ^c{delete}

    ; clear variable that will hold output string
    Inv_Char_Out:= ""

    ; loop for each character in the clipboard
    Loop % Strlen(Clipboard)
    {
        ; isolate the character
        Inv_Char:= Substr(Clipboard, A_Index, 1)

        ; if upper case
        if Inv_Char is upper
        {
            ; convert to lower case
           Inv_Char_Out:= Inv_Char_Out Chr(Asc(Inv_Char) + 32)
        }
        ; if lower case
        else if Inv_Char is lower
        {
            ; convert to upper case
           Inv_Char_Out:= Inv_Char_Out Chr(Asc(Inv_Char) - 32)
        }
        else
        {
            ; copy character to output var unchanged
           Inv_Char_Out:= Inv_Char_Out Inv_Char
        }
    }
    ; send desired text
    Send %Inv_Char_Out%
    Len:= Strlen(Inv_Char_Out)

    ; highlight desired text
    Send +{left %Len%}

    ; restore original clipboard
    Clipboard:= Clip_Save
}
                            ; Text–only paste from ClipBoard (while the clipboard formatted text itself is being untouched)
; Usage:ctrl+Shift+I 
^+v::                          
   Clip0 = %ClipBoardAll%
   Clipboard = %Clipboard%  ; Convert clipboard text to plain text.
   StringReplace, clipboard, clipboard,%A_SPACE%",", All ; Remove space introduced by WORD
   StringReplace, Clipboard, Clipboard, `r`n, `n, All ; Fix for Send sending Windows linebreaks
   Send ^v                       ; For best compatibility: SendPlay
   Sleep 50                      ; Don't change clipboard while it is pasted! (Sleep > 0)
   ClipBoard = %Clip0%           ; Restore original ClipBoard
   VarSetCapacity(Clip0, 0)      ; Free memory
Return

                                    ; Wrap selected text in double quotes->" "
; Usage:Ctrl+Shift+Q
^+q::
    clipSave := Clipboard
    Clipboard = ; Empty the clipboard so that ClipWait has something to detect
    SendInput, ^c ; Copies selected text
    ClipWait
    StringReplace, Clipboard, Clipboard, `r`n, `n, All ; Fix for SendInput sending Windows linebreaks
    Clipboard := Chr(34) . Clipboard . Chr(34)
    Len:= Strlen(Clipboard) ;Set number of characters
    SendInput, ^v ; Pastes new text
    Send +{left %Len%} ;Re-select text
    VarSetCapacity(clipSave, 0) ; Free memory
    Clipboard := clipSave ;Restore previous clipboard
Return

; RELOAD 
!+^x::
   SplashTextOn,,,Updated script,
   Sleep,200
   SplashTextOff
   Reload
   Send, ^s
Return

0

显然,S在高亮显示的文本上激活上下文菜单后按下即可完成操作(此处为Chrome 78)。可以使用Shift+F10关键字上的“上下文菜单”按钮或通过专用的“上下文菜单”按钮打开上下文菜单。

可以使用AutoHotKey将这两个快捷方式合并为一个:

^g::
  Send +{F10}
  Send s
Return

例如,这将Ctrl+G在新选项卡中搜索突出显示的文本。

与@Keltari答案相比,此方法的主要优点是它不使用剪贴板,因此不会覆盖那里的先前值。


-1

使用此扩展名

https://chrome.google.com/webstore/detail/hotkeys-for-search/gfmeadbjkfhkeklgaomifcaihbhpeido

如何使用它:

  1. 使用鼠标在网页上选择文本。
  2. 按键盘快捷键可在所需网站上搜索所选文本。

默认快捷方式:

Alt + Q = Google

Alt + W =维基百科

Alt + A = Google图片

Alt + S = YouTube

如果您想自动化许多任务,请使用我们针对chrome的自定义热键扩展

https://chrome.google.com/webstore/detail/keyboard-fu/cafiohcgicchdfciefpbjjgigbmajndb


1
仅仅推荐软件并不能解决问题。请添加必要的步骤来设置软件以回答问题。
music2myear

请阅读“我如何推荐软件”以获取有关如何推荐软件的一些提示。您应该至少提供一个链接,有关软件本身的一些其他信息,以及如何使用它来解决问题。
DavidPostill

OK我编辑的答案虽然这是很清楚的任何人都可以点击该链接将立即看到如何使用它的信息现在幸福
Kanyan - Rkv88
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.