QuickQuotes - Add quotation marks around highlighted text (Get more accurate results from search engines)

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
Haris00911
Posts: 2
Joined: 18 Mar 2024, 23:22
Contact:

QuickQuotes - Add quotation marks around highlighted text (Get more accurate results from search engines)

10 Apr 2024, 08:03

QuickQuotes is an AHK script to quickly add quotation marks around the selected text. Created to easily narrow down Google search results to your exact search terms. (Fun fact, this is my first time publishing any type of code since I started learning a couple months ago)

Finding what you need on Google is getting harder and harder every year. Luckily, Google has inbuilt advanced search features that help bring back the reliability of search results from the past. One of these handy features is adding quotation marks around a specific word or phrase which tells Google to only display results that are an exact match (not including capitalization). So instead of finding web pages that happened to contain all your search keywords scattered unrelated throughout the page, you'll only see results with your exact phrase.

For example: If I google just the phrase: Denon X3700h recall. I get a mess of results from pages that happened to mention those three words on the page individually but it's obviously not what I'm looking for. The page could literally be a review of an entirely separate product but the poster's signature has Denon X3700H in it and the word recall is used in the article so Google thinks it's done a great job at finding a site to show me.

Instead, if I add quotation marks around the term "Denon x3700h recall", I'll find results that have those three terms in order which is more likely to give me results relevant to me. It's especially useful when searching error codes, adding quotation marks around the error will make sure you only see results for your exact error and not errors that are similar or a little off.

Instructions for use:
Install AutoHotKey 1.1
Download QuickQuotations.ahk from the latest release
Double click on the file
Highlight any text and use the hotkey Ctrl + Middle Mouse Click (Completely customizable to your liking)
Profit

Quality of Life Feature:
Double clicking on a search term in the Google search bar or address bar will usually highlight the world + the space following it. This script will detect if there's a trailing space and remove it before adding the quotation then add the space after the quotations. This feature was added when I was feeling especially lazy one day and wanted to exert the least possible effort at everything.

Hope someone else finds this extremely simple short script as useful as I do on a daily basis, let me know if you find any issues or outliers scenarios or any general improvements you'd like to see! This is my first time writing code and also publishing something on Github so shoutout to the AHK forums and ChatGPT to help me debug and learn from other scripts.

Code:

Code: Select all

;********************************************************
; QuickQuotes
; By: Haris00911 
; Website: HarisGuard.com
; GitHub: Github.com/Haris00911
; Version: 1.0
; Release Date: April 10, 202
;********************************************************
; Description: 
;  This script adds quotation marks around copied text and 
;  handles cases where there might be a trailing space.
;
; Usage:
;  1. Install AutoHotkey (https://autohotkey.com)
;  2. Save this code as a .ahk file
;  3. Run the script
;  4. Highlight text and press Ctrl + Middle Mouse Button
;********************************************************

#NoTrayIcon

^MButton:: ; Ctrl + Middle Mouse Button

  Clipboard := "" ; Clear clipboard to avoid pasting and mixing old content

  Send, ^c ; Copy highlighted text to clipboard

  ClipWait, 1 ; Wait up to 1 second for the clipboard to contain data

  if (ErrorLevel) { ; If ClipWait times out or the clipboard is empty
    return ; Exit the function without doing anything
  }

  if (SubStr(Clipboard, StrLen(Clipboard), 1) = " ") { ; Check if the last character is a space
    Clipboard := """" . SubStr(Clipboard, 1, StrLen(Clipboard) - 1) . """" " " ; Move the space after the ending quotation mark
  } else {
    Clipboard := """" . Clipboard . """" ; Enclose the clipboard content in quotes as usual
  }

  Sleep, 100 ; Wait a moment to ensure Clipboard operation completes

  Send, ^v ; Paste the modified clipboard content

return
Direct Download
QuickQuotes.ahk
QuickQuotes.ahk
(1.47 KiB) Downloaded 4 times
Github
https://github.com/Haris00911/QuickQuotes

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 87 guests