Add a Digi-Key Search Hotkey Everywhere (Slack, Excel, Outlook, KiCad and More)

Add Digi-Key Search Superpowers to Teams, Slack, Excel, Outlook, Eagle, KiCad and more by following the guide.
image

  1. Highlight any text/keyword in any application
  2. ctrl+shift+d
  3. Digi-Key search results will pop open in a fresh tab of your default browser.

Why?

Obligatory xkcd
Obligatory xkcd xkcd: Is It Worth the Time?

An engineer’s job is surrounded with part numbers and those numbers come from a variety of places including email, chats, spreadsheets, csv, PDFs, schematics, ERP tools and websites .

Repetitive processes are begging to be optimized and the constant loop of copying information to look up things on digikey.com or Google is something that occurs dozens of times a day.
Sometimes people optimize for real time savings, sometimes they do it because they’re engineers, I’m not quite sure which one this is.

This isn’t, a full tutorial, just a bit of code to get your life a little more automated and save you time.

What is AutoHotkey?

This automation uses the Windows application AutoHotkey

Expand to learn more about AutoHotkey

From their website:

AutoHotkey (AHK) is a free, open-source macro-creation and automation software for Windows that allows users to automate repetitive tasks. It is driven by a scripting language that was initially aimed at providing keyboard shortcuts, otherwise known as hotkeys, that over time evolved into a full-fledged scripting language.

Getting Started

  1. The first steps to getting up and running would be to download and install AutoHotkey.
  2. Then you’ll need to create a text file and end it with an .akh extension.
  3. Write or paste your code into the that file and save it.
  4. Double-click on it to run.
  5. You’re on your way to hotkey heaven.

:white_check_mark: Get It Quick - If you are just here for the superpower and don’t want to bother with the tutorial, right click on this link and select “save link as” to download the digikey.akh example and place the file in your startup folder.

Editing your Script

If AutoHotkey is running you should see anicon in your tray. To edit the file at some point in the future right click on theicon and select Edit this Script . After you make changes you’ll need to save the script in your text editor and then click Reload This Script to make the changes take effect.

Running at Startup

If you want to have it run when your PC starts, put a shortcut to the file in your Windows startup folder.

Example 1 - digikey.com search shortcut

A basic script which uses ctrl+shift+d to search Digikey.com for a bit of highlighted text might look something like this:

^+d::
{
    Send, ^c
    Sleep 150
    Run, http://www.digikey.com/en/products?keywords=%clipboard%
    Return
}

Syntax

The basic syntax is covered here. In the examples we’ll use these keys as reference:

shorthand keyboard mapping
^ Ctrl
+ Shift
d d
g g

The shortcut combination is expressed using a series of characters followed by a double colon ::

^+d - tells AutoHotkey to respond to the combination Ctrl+Shift+d and perform the commands after the double colon ::

Send, ^c- executes Ctrl+c (the copy to clipboard shortcut).

Sleep 150 - It seems to need this brief delay to run reliably.

Run, http://www.digikey.com/en/products?keywords=%clipboard%** - opens this webpage using the default browser on your system.

%clipboard% - inserts the contents of your clipboard.

Return - The end of a hokey command.

Example 2 - add google shortcut

If you wanted to add a similar ctrl+shift+g shortcut for a google search you could do something like this:

^+d::
{
    Send, ^c
    Sleep 150
    Run, http://www.digikey.com/en/products?keywords=%clipboard%
    Return
}
^+g::
{
    Send, ^c
    Sleep 150
    Run, https://www.google.com/search?q=%clipboard%
    Return       
}

Example 3 - limit which programs use the shortcut

If you are a regular user of applications with their own shortcut definitions, like text editors or IDEs, you can exclude AutoHotkey from running on those windows using the .exe name, window name, or other qualifiers (learn more).

Here’s an example that allows these hotkeys to run all the time except when vscode, SublimeText, or othere IDE/Editors are active windows:

GroupAdd Editors, ahk_exe sublime_text.exe
GroupAdd Editors, ahk_exe atom.exe
GroupAdd Editors, ahk_exe code.exe  

#If !WinActive("ahk_group Editors")  ; keeps autohotkey from taking over text editor's shortcuts
{
	^+d::
	{
		Send, ^c
		Sleep 50
		Run, http://www.digikey.com/en/products?keywords=%clipboard%
		Return
	}

	^+g::
	{
		Send, ^c
		Sleep 50
		Run, https://www.google.com/search?q=%clipboard%
		Return		
	}
}

Other Fun Uses for AutoHotkey

Plain text paste from clipboard.

No more opening notepad to copy and paste to remove formatting.

Fun fact: Many Windows programs natively paste text using this key combination, but Outlook maddeningly does not, hence why this is important.

Ctrl+Shift+v

^+v::                             ; Plain text paste from Clipboard
{
    Clip0 = %ClipBoardAll%
    ClipBoard = %ClipBoard%       ; Convert to text
    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
}

Insert quotes around highlighted word.


Ctrl+Shift+" results in

^+"::                                   ; puts quotes around a highlighted word
    {
        Send, ^c
        Send, "
        Sleep 50
        if (SubStr(Clipboard, 0) = " ") ; checks to see if trailing space has been copied (common in MS office)
        {
            ClipBoard = %ClipBoard%
            Send, ^v
            Sleep 50
            Send, "{Space}              ; restores the space after the quote
        }
        else                            ; just inserts quotes around word as is
        {
            Send, ^v
            Sleep 50
            Send, "
        }
        Return
    }

Summary

There’s a wide variety of really complex tasks which can be automated with AutoHotkey. One can do text processing, cross program data entry and automation, abbreviation expansion, and more with AutoHotkey. It’s just one more of those tools in the tool belt for programmers, engineers, and anyone else has an obsessive need to optimize their workflows.

Other Digi-Key Superpowers

If this was useful you may also enjoy learning more about advanced uses cases in Digi-Key with these

  • Add Parts to your Digi-Key Cart from Anywhere using a simple URL
  • Add Digi-Key Search to Chrome, Firefox, and Edge
  • Try out the Tampermonkey Userscript called KeyMaster. This is an offshoot of the old greasmonkey/tampermonkey userscript called advancedsearch for Digi-Key.com being rewritten to accomodate the new React based front end.
2 Likes