Generating UUID's with a Stream Deck Button
I built uuid.rocks to learn how to build an API in TypeScript on Cloudflare Workers. However, I’ve found myself using it surprisingly often to grab a UUID. Whether it’s to give something a unique ID, or for an API key in another API, it’s come in handy many times.
However, going to a website (or even using curl) to get a UUID just isn’t fast enough. So with my recently acquired Stream Deck, I set off to build a button that would do it for me!
TL;DR - I made this:
A button that types a brand new UUID!
Building the Button
Instead of going through the trouble of building a Stream Deck plugin, I used a Multi Action button that utilizes multiple existing plugins/actions.
#1: Get a UUID
There is an amazing Stream Deck plugin made by BarRaider called API Ninja which lets you make web requests. In this case, we’ll have it request the uuid.rocks JSON API and write the UUID to a .txt file.
#2: Type the UUID stored in the file
Another handy plugin by BarRaider is Super Macro. It can read from a file and type the contents.
Vuala! It works!
But there’s a problem
For some reason, if you click the button too fast it may send the same UUID multiple times. Probably because the Super Macro plugin is meant to be able to spam macros without waiting on network calls.
To fix this, I switched things around so that it sends the content of the .txt file first, clears it, and then gets a new UUID.
Clearing the file between UUID’s
Another BarRaider plugin called Text File Tools has an action called Text File Updater which can set the contents of a file when run. In this case, it just needs to clear the file since the UUID has already been used.
New Multi Action
The new Multi Action will type the last generated UUID, clear the .txt file, and then get a new UUID and write it to the file for the next time the button is pushed.
Try it Yourself!
Download and import this profile to try it out:
Install the following plugins for it to work:
- Super Macro by BarRaider
- Text File Tools by BarRaider
- API Ninja by BarRaider