Quick Note Taker (like a Sticky Note)

In the recent update, Evernote has come up with a quite note-taking addon which sits in the system tray and pops up on clicking Ctrl+Alt+H. Would it be possible to have something similar for Obsidian enabling us to take quite notes and stays over other applications like a Sticky Note.

11 Likes

Yes this would be highly useful for me too. I have mainly been using OneNote before and it comes with a Quick Note keyboard shortcut (Win+N) which I use very often I would like to do something similar with Obsidian.

2 Likes

If that’s interesting for anyone, I can create a solution for that with AutoHotKey. I’d created a similar ultra-simple-quick-note-taking solution in the past, that basically displayed a window with three boxes: Title, main text, tags. When you clicked on a SAVE button, it was saved in a predefined, hard-coded path (but since AHK scripts are text-editable, it was changeable with any text editor). I can basically re-purpose it to remove any useless fluff I used, and upload it somewhere as “just that”. It wouldn’t open Obsidian’s editor, but at the same time, that’s not the point of any “quick note taking” solution.

3 Likes

would you mind sharing the ahk code? thanks

I can’t find the particular file right now, but this older version looks close enough. Save it in an AHK file and replace the “;” in front of the script-lines for it to work. If I remember correctly, this should save anything copied to the clipboard to a note when pressing Windows Key + C at the same time… but I could be mistaken, and I’m working in a restricted computer where I can’t actually check and run it now. Sorry about that.

;#c::
;vFileName=I:\00_Cloud_Storage\Dropbox\ody_notes.txt
;fileencoding, UTF-8
;Send, ^c
;ClipWait, 5
;MsgBox, 1, ClipNotes, ClipNotes Loop Mode On, 5
;Loop,
;{
;ClipWait, 600
;MsgBox, 4, Copied, %Clipboard%,`nWrite to file and Go on?
;IfMsgBox Yes
;{
;FileAppend, `n%Clipboard%, %vFileName%
;Clipboard =
;}
;else
;return
;}
;return

OK, the above sucked and was a sub-par version of what I was using. Since thousands of people (har-har) asked for this, and it would also be useful for me, I’ve sat down and re-implemented it from scratch. I couldn’t find the old file, so, I’ve written a new script that performs the same function, more or less.

HOWEVER…

Since this is also saving notes, it has to respect filesystem restrictions. So, I’ve tapped into a secondary script I’m using that cleans text from any “weird” characters. You should copy both, save the first, main script with whatever name you wish, and then save the second one as “clean_characters3.ahk”. The way I’m using it, this secondary script is in a “Tools” subdirectory. If you save both in the same directory, make sure to edit the main script to reflect that. The line with the path to the secondary “clean_characters3.ahk” script is:

RunWait %A_ScriptDir%\Tools\clean_characters3.ahk

Remove the “Tools” part if you won’t save the script in a Tools subdirectory, and change its name if you don’t go for “clean_characters3.ahk”.

You should also change the…:

NotesPath = I:\00_Cloud_Storage\Dropbox\Notes\Obsidian\Duckland\!Inbox

…line to reflect your own vault’s inbox folder. For example, it could be:

NotesPath = C:\notes\obsidian_vaults\DirtyNotes\IwasabadboySanta

Now, on with the show.

Script 1 - main one, for notes:

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

;_________________________________________________________________________( START! )____

;CTRL = ^, SHIFT = +, ALT = !, WINDOWS KEY = #

;________________________________________________________________( Variables Setup )____


;___________________________________________________________________( GUI Creation )____
#`::
    Gui, 2:Add, Edit, x5 y5 w555 h50 vTitle, Title - Filename
    Gui, 2:Add, Edit, x5 y60 w555 h500 vNote, %Clipboard%
    Gui, 2:Add, Edit, x5 y565 w555 h100 vTags, Tags
    Gui, 2:Add, Button, x5 y670 w555 h60 Default, OK
    Gui, 2:Add, Button, x5 y735 w555 h30, Cancel

    Gui, 2:Show, w565 h770, QuickNotes
    Return

    2ButtonOK:
        NotesPath = I:\00_Cloud_Storage\Dropbox\Notes\Obsidian\Duckland\!Inbox
		FormatTime, TimeString, %DateTime%, hh:mm dddd, dd-MM-yy
        Gui, 2:Submit
        FileEncoding, UTF-8
        TempClipboard = %ClipBoard%
        sleep, 50
        ClipBoard = %Title%
        sleep, 50
        RunWait %A_ScriptDir%\Tools\clean_characters3.ahk
        sleep, 50
        FileName = %ClipBoard%
        sleep, 50
        ClipBoard = %TempClipboard%
        sleep, 50
        NoteFormat = `# %Title%`n- - -`n**Link: **`n**Tags:** `[%Tags%`]`n**Time:** %TimeString%`n`n**Notes: **`n- - -`n%Note%
        FinalFilename = %NotesPath%\%FileName%.md
        FileAppend, %NoteFormat%, %FinalFileName%
        sleep, 50
        Reload
        Sleep 1000 ; If successful, the reload will close this instance during the Sleep, so the line below will never be reached.
        MsgBox, 4,, The script could not be reloaded. Would you like to open it for editing?
        IfMsgBox, Yes, Edit
    return
    
    2ButtonCancel:
        Gui, 2:Submit
		FormatTime, TimeString, %DateTime%, hh:mm dddd, dd-MM-yy
        Clipboard = `# %Title%`n- - -`n**Link: **`n**Tags:** `[%Tags%`]`n**Time:** %TimeString%`n`n**Notes: **`n- - -`n%Note%
        sleep, 50
        Gui, 2:Destroy
        return

    2GuiEscape:
        Gui, 2:Submit		
		FormatTime, TimeString, %DateTime%, hh:mm dddd, dd-MM-yy
        Clipboard = `# %Title%`n- - -`n**Link: **`n**Tags:** `[%Tags%`]`n**Time:** %TimeString%`n`n**Notes: **`n- - -`n%Note%
        sleep, 50
        Gui, 2:Destroy
        return
    2GuiClose:
        Gui, 2:Submit
        Clipboard = `# %Title%`n- - -`n**Link: **`n**Tags:** `[%Tags%`]`n**Time:** %TimeString%`n`n**Notes: **`n- - -`n%Note%
        sleep, 50
        Gui, 2:Destroy
        return
return

Script 2 - secondary, called to remove weird characters from the filename.

#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.

CleanMePlease = %ClipBoard%
CleanMePlease := Regexreplace(CleanMePlease, "[^a-zA-Z0-9]", " ")
loop
   {
      StringReplace, CleanMePlease, CleanMePlease, %A_SPACE%%A_SPACE%, %A_SPACE%, all
      if ErrorLevel <> 0
                break
   }
ClipBoard = %CleanMePlease%

How it works

Press Windows Key + ` (that-button-left-of-one-over-Tab) at the same time and the QuickNotes window will pop-up. You can enter a title, main text - which will be pre-populated with anything that was already in the Clipboard, and tags.

When the note is saved, it’s styled according to a template I’m using. The note’s structure and contents are defined in:

NoteFormat = `# %Title%`n- - -`n**Link: **`n**Tags:** `[%Tags%`]`n**Time:** %TimeString%`n`n**Notes: **`n- - -`n%Note%

It’s easy to decipher what this does if you save a note with the script, then open it and check the line above. I’m just adding some titles and markdown in the content, saving the note with its cleaned-up version of its title as its filename, and then structure it as:

# Title
- - -
**Link: ** (you can enter links to other notes here)
**Tags: ** [List of tags you entered in the GUI part]
**Time: ** Auto-populated by the script. Check the TimeString line [and here](https://www.autohotkey.com/docs/commands/FormatTime.htm) for how to format the time.

**Notes:** I usually type some small notes here when I use the rest of the page for writing articles for clients. For personal use, where a note's a note - and not a project, this remains blank.
- - -
Here be content.

I hope someone finds this helpful :slight_smile:

EDIT/UPDATE:

Some more info on the script’s behavior. If you close the GUI or press Esc to cancel, hopefully your content should be styled precisely as if it would be saved in a new note, but copied to the clipboard instead. Thus, you can then paste it in another app, or Obsidian itself.

Also, to change the hotkey, change the:

#`::

…line to anything you wish. I’ve included a reminder of the shortcodes AHK uses for the Windows, CTRL, Alt, and Shift keys, so you can change it to any combo you wish. For example…:

#+^a::

…will call the GUI whenever you press Windows Key + Shift + CTRL + A at the same time.

EDIT 2: Updated the main script - it didn’t set the time properly. I hope it does now.

1 Like

Great idea and implementation! Thanks.

Quick issue I’m running into within Obsidian: The new files seem to start with a character that Obsidian cannot read.

Screenshot 2020-12-28 233359

I noticed the red dot and get this when I hover over it with my mouse:

Screenshot 2020-12-28 233430

Here is the formatting I’m applying

NoteFormat = Title: %Title%`nTags: %Tags%`nTime: %TimeString%`n`n---`n`n# Notes:`n%Note%

Any ideas?

1 Like

I don’t know, but remember seeing similar red dots and hover dialog codes when I imported notes I had created on my phone in ia writer.

The notes had links between them that followed the ia writer formatting. I simply deleted that stuff and forgot about it until I saw your post. I will be interested to hear what they are.

Thanks.

I-honestly-don’t-know! It bugs me as well, but have found no way around it. Initially I thought it was somehow borking because I’m adding a “#” character in front of the title, but while troubleshooting, it did the same thing both without the hash and when “escaping” it.

If anyone knows more about what this mysterious character is, I’d be interested as well. As it is, I, too, am manually deleting it from my notes, although it doesn’t seem to affect neither AHK nor Obsidian. It’s just… annoying :smiley:

1 Like

The character is the Byte Order Marker (aka BOM) and it looks like Obsidian doesn’t strip it automatically. Looking at the AHK docs, you should be able to fix it by using FileEncoding, UTF-8-RAW rather than just UTF-8 in your OK button handler.

3 Likes

Oh, I had this issue too in my implementation. With BOM. Even have an issue. Thanks for the solution mention.

I hope I’ll have enough time to do the MVP of the crossplatform quick extraction/capture tool I’m working on

1 Like

Yup, thanks! This worked!

Sorry for not returning for so long with a fix. Life happened.

I’m also deeply sorry @mrjackphil , I’m NOT trying to one-up you, and I pretty much love how your implementation works. However, in the meantime, I had also updated and expanded my solution. I’d love it if you took ideas (or even copy-pasted stuff as it is) to also expand your solution, if you find anything I’ve added useful. Except if, maybe, you’d like a collaboration? :smiley: I know how to use Github, but I’m not much into it, so, feel free to take anything you need from here and implement it in your solution.

That said…

Drummroll please…

Here’s the new version.

Things added:

  • It now uses an INI file, where it temporarily stores the last note ('s path) you’ve worked on.

  • This wouldn’t be useful without a new “Load Previous Note” button, at the very top, that allows you to keep adding stuff to the last note you’ve worked on.

  • Two new buttons - that use the same INI file - for independently saving and loading a set of tags. That’s useful if you want to take a stream of quick notes, but use the same tags on all of them to assist in organization in Obsidian.

  • A non-working Word Count feature. Hey, I tried, failed, and had no time to really look into it. If anyone can fix it, I’m game - and many kudos to you!

Anyways. Here it is, and I hope you find it useful:

#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.
;___________________________________________________________________________________________________



; QuickNotes
; ----------
; The quickest way to take plaintext (or Markdown) notes.



; Variables: User-editable
; ------------------------
NotesPath = C:\ENTER_FULL_PATH\TO_YOUR_OBSIDIAN\NOTES_INBOX_HERE
QuickNotesSettings = %A_ScriptDir%\QuickNotes_Settings.ini
; Feel free to set the above "QuickNotes_Settings.ini" to any name you wish.
; By the way, I don't include the file 'cause it's initially empty. It's only used as temp storage.



WordCount = 0

SetBatchLines -1




	;Pop-up window in 2nd monitor if available:
		SysGet, ScreenNumber, MonitorCount
		
		If (ScreenNumber > 1)
		{
			SysGet, Mon2, Monitor, 2
			SmartWindowPlacement := (Mon2Left +1)
		}
		
		If (ScreenNumber = 1)
		{
		SysGet, MonitorPrimary, MonitorPrimary
		SmartWindowPlacement := (MonitorPrimaryRight - 810)
		}

	;GUI code

	Gui, QuickNotes:Add, Button, x5 y2 w555 h22 gLoadNote, Load Previous Note
	Gui, QuickNotes:Add, Edit, x5 y25 w555 h50 vTitle, Title - Filename
	Gui, QuickNotes:Add, Edit, x5 y80 w555 h500 vNote, %Clipboard%
	;Gui, QuickNotes:Add, Edit, x5 y585 w555 h100 vTags, Tags
	Gui, QuickNotes:Add, Edit, x5 y585 w455 h100 vTags, Tags
	Gui, QuickNotes:Add, Button, x460 y585 w100 h50 gSaveTags, Save Tags
	Gui, QuickNotes:Add, Button, x460 y635 w100 h50 gLoadTags, Load Tags
	Gui, QuickNotes:Add, Button, x5 y690 w555 h60 Default, OK
	Gui, QuickNotes:Add, Button, x5 y755 w555 h30, Cancel
	Gui, QuickNotes:Add, Text, vWordCount x5 y790, Words`: %WordCount%

	Gui, QuickNotes:Show, x%SmartWindowPlacement% y0 w565 h830, QuickNotes

return

	;QuickNotes Functions
	
	LoadNote:
		IniRead, FinalFilename, %QuickNotesSettings%, Files, Working File
		IniRead, Tags, %QuickNotesSettings%, Organization, Tags
		IniRead, Title, %QuickNotesSettings%, Organization, Title
		FileRead, FileContent, %FinalFilename%
		Note = %FileContent%
		GuiControl, QuickNotes:, Note, %Note%
		GuiControl, QuickNotes:, Tags, %Tags%
		GuiControl, QuickNotes:, Title, %Title%
	return
	
	
	
	SaveTags:
		Gui, QuickNotes: Submit, NoHide
		GuiControlGet, Tags
		FileEncoding, UTF-8-RAW
		IniWrite, %Tags%, %QuickNotesSettings%, Organization, StandaloneTags
	return



	LoadTags:
		IniRead, Tags, %QuickNotesSettings%, Organization, StandaloneTags
		GuiControl, QuickNotes:, Tags, %Tags%
	return



	QuickNotesButtonOK:
		FormatTime, TimeString, %DateTime%, hh:mm dddd, dd-MM-yy
		Gui, QuickNotes:Submit
		FileEncoding, UTF-8-RAW
		TempClipboard = %ClipBoard%
		sleep, 50
		ClipBoard = %Title%
		sleep, 50
		RunWait %A_ScriptDir%\clean_characters3.ahk
		sleep, 50
		FileName = %ClipBoard%
		sleep, 50
		ClipBoard = %TempClipboard%
		sleep, 50
		NoteFormat = `# %Title%`n- - -`n**Link: **`n**Tags:** `[%Tags%`]`n**Time:** %TimeString%`n`n**Notes: **`n- - -`n`n%Note%
		FinalFilename = %NotesPath%\%FileName%.md
		FileAppend, %NoteFormat%, %FinalFileName%
		sleep, 50
		GuiControlGet, Tags
		GuiControlGet, Title
		IniWrite, %FinalFilename%, %QuickNotesSettings%, Files, Working File
		IniWrite, %Tags%, %QuickNotesSettings%, Organization, Tags
		IniWrite, %Title%, %QuickNotesSettings%, Organization, Title
		ExitApp
	return



	QuickNotesButtonCancel:
		Gui, QuickNotes:Submit
		FormatTime, TimeString, %DateTime%, hh:mm dddd, dd-MM-yy
		Clipboard = `# %Title%`n- - -`n**Link: **`n**Tags:** `[%Tags%`]`n**Time:** %TimeString%`n`n**Notes: **`n- - -`n`n%Note%
		sleep, 50
		ExitApp
	return
	
	

	QuickNotesGuiEscape:
		Gui, QuickNotes:Submit		
		FormatTime, TimeString, %DateTime%, hh:mm dddd, dd-MM-yy
		Clipboard = `# %Title%`n- - -`n**Link: **`n**Tags:** `[%Tags%`]`n**Time:** %TimeString%`n`n**Notes: **`n- - -`n`n%Note%
		sleep, 50
		ExitApp
		return
		
		
		
	QuickNotesGuiClose:
		Gui, QuickNotes:Submit
		Clipboard = `# %Title%`n- - -`n**Link: **`n**Tags:** `[%Tags%`]`n**Time:** %TimeString%`n`n**Notes: **`n- - -`n`n%Note%
		sleep, 50
		ExitApp
	return

As I said, don’t bash me, I know it sucks - I’m no coder, and I’m only using AHK for my own automation needs (and making some mini-apps like this one).

Extra Note

I’m on an ancient PC with a Core i7 2600K, a GTX 970, and 8GBs of RAM. Those “sleep, NUMBER” lines add delays to the script, without which it sometimes borks on me. MAYBE, though, that’s because of my ancient and slow PC, and you can skip them to make this QuickNotes solution even… errr… quicker… yes. That. To test if it works for you, add a “;” character (without the quotes) at the beginning of every “sleep, NUMBER” line. Then save the script and run it. Did it blend? Er… Work? Keep it like that! Did it bork? Re-add the delays.

I’m up for other ideas and suggestions, but I’m NOT planning to expand this into a full-blown note-taking solution. Nor support MarkDown, or include a full text editor. There are alternatives for that. However, they’re also more complicated, “heavier”, and less easy to use. This is a straightforward TXT note-taking solution. Nothing more, nothing less.

Extra-Extra Note

Default hotkey for taking a new note is Windows Key + ` (“The Tilde Key” on the top left of the English default QWERTY keyboard setup).

Hidden Features

  • I work on two monitors, one 1920x1200 and one 1920x1080. If the script detects two monitors, it changes the window’s pop-up coordinates to “horizontal resolution of first monitor +1”. This makes it appear at the top left of the second screen, right next to the primary one. You can play with the “Pop-up window in 2nd monitor if available” section to tweak how this works. If, however, there’s only one monitor, the window is set to appear on Monitor’s-Right-Edge-Minus-810-pixels. In other words, on the right of the screen (I’m subtracting the window’s width from the monitor’s horizontal resolution).

  • I saved the best for last - although it was the simplest to implement, it makes a world of difference for my note-taking, and I guess it will help others, too: the note’s body is automatically populated with the Clipboard! This means that you can copy something from your browser to the clipboard, then “call” this QuickNotes thingy, and what you copied will appear in the main note section. Add a title, maybe some extra notes and tags, and your note’s ready :slight_smile:

That’s all for now, and sorry for the long post - and even longer absence. Blame life :expressionless:

IMPORTANT UPDATE!

Doh! I forgot! This also uses an extra script I wrote to clean the title - that’s also used as a filename - from “strange” characters. It’s the following one. Either save it in the same directory as the QuickNotes script with the name “clean_characters3.ahk”, or name it however you wish but then find any reference to “clean_characters3” in the QuickNotes script and change it to the name you used.

You could alternatively implement this as an extra function in the same script, but I keep it separate 'cause I’m also using it for other… er…eh… “solutions” of mine.

#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.

CleanMePlease = %ClipBoard%
;MsgBox, CleanMePlease set as %CleanMePlease%
CleanMePlease := Regexreplace(CleanMePlease, "[^a-zA-Z0-9]", " ")
loop
   {
      StringReplace, CleanMePlease, CleanMePlease, %A_SPACE%%A_SPACE%, %A_SPACE%, all
      if ErrorLevel <> 0
                break
   }
;MsgBox, CleanMePlease is now %CleanMePlease%
ClipBoard = %CleanMePlease%

Sorry for forgetting to post it before.

2 Likes

@ducklord We can discuss and collaborate on that. You can text me on Discord and we can figure out how to make it work together. I didn’t update it for a while.

Or I can help you to put your solution on Github. It would be easier for you to maintain (in a long term) and for others to get updated version of the script.

@mrjackphil Strangely, I’m not THAT familiar with Discord, either. I’ve used it in the past, but I feel as if I’m… missing something. And, generally, fumbling a bit with it.

If you tell me how and when I can find you using it, though, I will :slight_smile:

Do I just run it and search (somewhere) for your alias?

Hello guys,

Maybe I am too late here, but I want to say that this is a great idea.

I don’t know how to add that functionality to obsidian though.

Where should I add the scripts posted here? (I am a newbie regarding this type of scripting so the more detailed the explanation, the better😅)

Thanks.