Dragonglass: a fast way to add text to any note without opening its vault

Hello there. I present to you Dragonglass. It’s a simple AutoHotkey script to add stuff in any note with one keystroke. But if you know nothing about AHK, fear not! I made it noob friendly, everything is explained in the script.

What Dragonglass does when you press a key combination (default: alt+F3), is displaying a list of text files of your choosing and when you select one, an input window appears. You type in your idea/link/to do list, press tab, enter and the window closes, adding what you just typed to the file. All this in a few seconds and without opening the vault.

How to use:

  • Install AutoHotkey
  • Create a new text file called dragonglass.ahk (or any other name) and put it in your start menu folder (generally C:\Users\yourname\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\) so that it runs when starting Windows
  • Open it in an editor (I recommend notepad++) and paste the code below; every line starting with a semi colon is an explanation of what the code below it does and how to customize it
  • Simply paste your vault path and the name of each file in the right places
  • Save, relaunch the script by double clicking it and press alt+F3 to try it
  • Enjoy!

If you have any question and if the explanations in the script aren’t clear enough, I’d be happy to help. If there are AHK veterans reading this, feel free to improve on it and post suggestions!

;==========================================================
;==============dragonglass=================================
;==========================================================

;information about how to customize further can be found here: https://www.autohotkey.com/docs/v1/lib/Gui.htm
;notepad++ is recommended to edit this file more easily: https://notepad-plus-plus.org/downloads/
;if you use notepad++ you can install the syntax highlighter for AutoHotkey to make the code easier to read: https://www.autohotkey.com/boards/viewtopic.php?t=50

;==========================================================
;=============varibales====================================
;==========================================================
;each variable here can be renamed but then you'll have to rename every instance in which it is called (words between percent signs "%")
;every following number is in pixel
editheight=200			;height of the edit box
editwidth=500			;width of the edit box
editx=6					;horizontal position of the edit box
buttonheight=30			;button height
buttonwidth=100			;button width
buttonx=200				;horizontal position of the button 
buttony=212				;vertical position of the button
xpos=900				;horizontal position of the menu
ypos=500				;vertical position of the menu
baratheonfolder=%A_MyDocuments%\myvault\baratheon\	;folder where the files are stored(you can replace this with something like C:\Users\Yourname\Document)
starkfolder=%A_MyDocuments%\myvault\stark\
misc=%A_MyDocuments%\myvault\

;==========================================================
;=============menu=========================================
;==========================================================

;keyboard shortcut to display the menu (default is !F3 which is alt and F3)
;symbols: ^ is control, + is shift, ! is alt, # is windows key
;example: ^F3 is ctrl and F3, #+a is windows, shift and a
!F3::
CoordMode, Menu
Menu, dragonglass, Add
Menu, dragonglass, deleteAll

;when displaying the menu, each item can be selected by typing its first letter (the letter coming after "&" in the code below)
;you can rename each "commandX" but the name has to match its definition below (line starting with "commandX:")
;submenu 1 item 1
		Menu, Submenu_baratheon, Add, &Robert, command1
	;submenu 1 item 2
		Menu, Submenu_baratheon, Add, &Stannis, command2
	;submenu 1 item 2
		Menu, Submenu_baratheon, Add, &Renly, command3
	;submenu 1
	Menu, dragonglass, Add, &Baratheon, :Submenu_baratheon

;submenu 1 item 1
	Menu, Submenu_stark, Add, &Brandon, command4
;submenu 1 item 2
	Menu, Submenu_stark, Add, &Ned, command5
;submenu 1 item 3
	Menu, Submenu_stark, Add, &Lyanna, command6
;submenu 1 item 4
	Menu, Submenu_stark, Add, &Benjen, command7
;submenu 1
	Menu, dragonglass, Add, &Stark, :Submenu_stark

;separator
	Menu, dragonglass, Add

;menu item 3
	Menu, dragonglass, Add, &Children of the forest, command8

;%xpos%, %ypos% are the position in pixel of the menu, defined at the top of the script
Menu, dragonglass, Show, %xpos%, %ypos%
return

;==========================================================
;=============what each menu item does=====================
;==========================================================

command1:
;you can rename "vUltratext" to anything starting with "v" but it has to match the varibale name (%Ultratext%) in the corresponding button definition below (line starting with "FileAppend")
	Gui, Add, Edit, x%editx% w%editwidth% h%editheight% vUltratext
;you can rename "gsavebutton1" to anything starting with "g" but it has to match the definition below (line starting with "savebutton1:")
	Gui, Add, Button, x%buttonx% y%buttony% w%buttonwidth% h%buttonheight% gsavebutton1, &Save
;everything after "Show,," is the name of the window
	Gui, Show,,King Robert the legendary drinker
	return

command2:
	Gui, Add, Edit, x%editx% w%editwidth% h%editheight% vUltratext
	Gui, Add, Button, x%buttonx% y%buttony% w%buttonwidth% h%buttonheight% gsavebutton2, &Save
	Gui, Show,,Stannis the unfunny
	return

command3:
	Gui, Add, Edit, x%editx% w%editwidth% h%editheight% vUltratext
	Gui, Add, Button, x%buttonx% y%buttony% w%buttonwidth% h%buttonheight% gsavebutton3, &Save
	Gui, Show,,Renly the fabulous
	Return

command4:
	Gui, Add, Edit, x%editx% w%editwidth% h%editheight% vUltratext
	Gui, Add, Button, x%buttonx% y%buttony% w%buttonwidth% h%buttonheight% gsavebutton4, &Save
	Gui, Show,,Good old Ned
	Return

command5:
	Gui, Add, Edit, x%editx% w%editwidth% h%editheight% vUltratext
	Gui, Add, Button, x%buttonx% y%buttony% w%buttonwidth% h%buttonheight% gsavebutton5, &Save
	Gui, Show,,Brandon the big bro
	Return

command6:
	Gui, Add, Edit, x%editx% w%editwidth% h%editheight% vUltratext
	Gui, Add, Button, x%buttonx% y%buttony% w%buttonwidth% h%buttonheight% gsavebutton6, &Save
	Gui, Show,,Lyanna the maybe mother of Jon Snow
	Return
	
command7:
	Gui, Add, Edit, x%editx% w%editwidth% h%editheight% vUltratext
	Gui, Add, Button, x%buttonx% y%buttony% w%buttonwidth% h%buttonheight% gsavebutton7, &Save
	Gui, Show,,Benjen the swag uncle
	Return

command8:
	Gui, Add, Edit, x%editx% w%editwidth% h%editheight% vUltratext
	Gui, Add, Button, x%buttonx% y%buttony% w%buttonwidth% h%buttonheight% gsavebutton8, &Save
	Gui, Show,,Children of the forest are the coolest
	Return

;==========================================================
;=============what each button does========================
;==========================================================

savebutton1:
	Gui, Submit
;everything after "FileAppend," is what will be written in the text file and everything after the second comma is the path of the file
;%Ultratext% corresponds to the varibale of what you just typed and "`n" is used to create a new line
;so the following code will add the text you typed and then create a new line twice, add three dashes (---) and then add 2 other lines so you can easily see the different inputs when reading the file
	FileAppend, %Ultratext%`n`n---`n`n, %baratheonfolder%robert.md
	Gui, Destroy
	Return

savebutton2:
	Gui, Submit
;if you want to save some files in a different folder just create a new variable like "newfolder= C:\...\" at the beginning of this script and write the corresponding call this variable in the commands below (%newfolder%filename.md)
	FileAppend, %Ultratext%`n`n---`n`n, %baratheonfolder%stannis.md
	Gui, Destroy
	Return

savebutton3:
	Gui, Submit
	FileAppend, %Ultratext%`n`n---`n`n, %baratheonfolder%renly.md
	Gui, Destroy
	Return

savebutton4:
	Gui, Submit
	FileAppend, %Ultratext%`n`n---`n`n, %starkfolder%brandon.md
	Gui, Destroy
	Return

savebutton5:
	Gui, Submit
	FileAppend, %Ultratext%`n`n---`n`n, %starkfolder%ned.md
	Gui, Destroy
	Return

savebutton6:
	Gui, Submit
	FileAppend, %Ultratext%`n`n---`n`n, %starkfolder%lyanna.md
	Gui, Destroy
	Return

savebutton7:
	Gui, Submit
	FileAppend, %Ultratext%`n`n---`n`n, %starkfolder%benjen.md
	Gui, Destroy
	Return

savebutton8:
	Gui, Submit
	FileAppend, %Ultratext%`n`n---`n`n, %misc%children.md
	Gui, Destroy
	Return
4 Likes

Note capture is the holy grail for Obsidian. This looked promising. I use FastKeys, but will try this out.

In case you’re still interested, I made a simple software out of this on my github

No need to mess around with coding, I made a whole interface for easy use!

2 Likes

Amazing. Just to be clear for non-coders, do we just click “Dragonglass-QWERTY.exe”? When I do that i get “App can’t run on your PC”.

I’m sorry, I can’t find why it wouldn’t. Maybe Windows blocks it for security reasons. You can still try the .ahk version: you simply run “main.ahk” and you’re done. If you want it to launch on startup, create a copy of that file and put it there C:\Users[yourname]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\

I Hope this helps.

You have to install Autohotkey before being able launch .ahk files though.