qNote2: take and save note in DT from anywhere, capture web URL, append selected text and fenced code block, capture screen, set reminder and calendar event

An update on the experimental qNote script

Basically, this script is a floating window version of Sorter that is only focused on notes taking for those who use large 4k display/s and don’t want to look up to the top right corner of the display/s when typing their notes (that user is me).

How to use the script:

  • Download “Dialog Toolkit Plus.scptd” and save it under “/Library/Script Libraries”
  • Save the script as “Application”. The best way to use the script is to attach a shortcut keys by using BTT or KM or the automator>sevices.
  • Saving the script as an application in MacOS script folder means that the script can be used anywhere in the system and save note into different DT groups even when the designated databases are not opened (DT or DT’s database will be opened automatically when the note is saved).
  • The Dialog Toolkit Plus can be downloaded from the Late Night Software website.


When the user selects a block of codes, they can use “Append Code” button to add fenced code.

  • Append selected text is also supported by using the “Append Text” button.
  • There is an internal preference to set the programming language and the header for formatting.
  • The user must define the UUIDs of their own groups in the script for saving the notes .

The user can also paste the website URL address into the note. Only Safari and Chrome are supported.

The programming for this feature is the most challenging area and is still somewhat experimental ( i.e. Can be unstable).

The user can append multiple blocks of text, fenced code, and website URL in the same note.

The user can also capture multiple screenshots in the same note.

  • The captured images won’t show in the note window (it’s plain text) but there is a count of Captured image in the upper right corner of the dialog box.
  • The mechanisms of the above features are working in the same manner for MD and RTF note.

The created note, saved under one of the designated note groups.

For the images in MD notes will be saved under a common image assets folder.

  • The image files use the naming format of DBname_Groupname_Notename_image#.
  • There can only be one group for saving the images and its uuid must be defined in the script.
  • For RTF notes, there is an internal preference to delete the image files after the note is created.

DEMO 2: Setting DT reminder and Apple Calendar event.

The user can set a few basic types of DT reminder and to add the event to a chosen Apple calendar with an event duration. If DT remainder and Apple calendar event are both used, the DT reminder time of alert is set at the last dropdown list.

There is a bug in Catalina and AppleScript can’t set the Apple Calendar alarm.
The user can add a reminder without adding a note. Just type in the reminder’s message field and leave the name and body fields empty.

A reminder is set, and an Apple Calendar event is set with a link to the DT note.

The Script

Note: The programming of appending text and code block, and getting the browser URL is not trivial. Some UI programming that involves keystrokes and time delay may make this script unusable on some computers. In addition, not all apps support select text method smoothly (I think).
I develop this for own use, and will unlikely to add any feature in the future, except for bug-fixes.


qNoteV4b5.scpt.zip (53.6 KB)

Updated 2020.05.28: v4b6 is identical to v1b5 but include error reporting message.
qNoteV4b6 (w error messge).scpt.zip (56.6 KB)

1 Like

That filename is getting a bit long and unwieldy :slight_smile:

Just the kind of nerd I am… :thinking: :thinking:


1 Like

This looks amazing…but I get an error when running it:

Not sure if I missed a step somewhere but this is way beyond my ability to debug without help! Thanks!

Sorry to hear that.

(1) Just to make sure that you have set up the uuid of the groups for saving notes and images within the script. The uuids in the script are mine, you’ll need to change those to your groups’ uuids - any number of groups for qNoteGpsUUID, and only one group for imageAssetUUID.

 -- groups for saving the note
property qNoteGpsUUID : {"C588333A-A275-4D66-9295-6B5D1048D710", "378BE728-BA45-42AC-A060-23A97578B7E4", "46B961B8-9EB0-49C4-860F-0766195DC024", "712259F8-EFC2-45BA-A492-BEB9C88A2F13"}
-- one centralised group for saving the images
property imageAssetUUID : "9A72DEC0-A97E-4531-A837-257E375483DC"

(2) Within the next two days, I’ll post another version with error checking blocks (to check where have the problem/s occurred) in case someone are seeing problems when using the script.

There are two scripting-related discussions I’d like to share.

(1) The option of taking MD and RTF notes is merely a trick by using the excellent DT’s internal conversion of MD to RTF. This script always create a note in MD format as the first step. But if the RTF option is checked, the script will tell DT to convert the MD into a new RTF formatted note, then delete the original MD formatted note (you will find the MD version in the trash). Since DT prepares the images into the RTF package contents, the images that are saved in the image assets group can be deleted, too. That’s why the MD and RTF versions of the same note will look almost identical.

(2) The second discussion is regrading the trick of grabbing and appending the text(or fenced code block) and the web URL into the note while the script is running as the frontmost app. I have modified what I found from other AppleScript user forums to the most effective way (IMHO) of accomplishing the job.

That’s why the script may not work for some computers, because the delay required for different computer could be different. I hope this trick can be useful for the others.

Note: If there are better/foolproof way to accomplish the same function, please share!

	tell application "System Events"
		tell (first application process whose frontmost is true)
			-- this "it" here is this script, and set itself to invisible, 
            -- so it's no longer the frontmost app
            -- that's why the dialog box of qNote will disappear for <1 sec 
            -- after the button is clicked
			set visible of it to false
			-- the delay is crucial, without it the coding won't work.
			-- the delay gives sometime for the system to register 
            -- the previous frontmost app to become the frontmost app again
			delay 0.2
			-- this "it" becomes the app the user is working on right 
            -- before the script is invoked.
			set theActiveApp to name of it
		end tell
	end tell

v1b6 is updated in post#1. This version is identical to v1b5 but includes error reporting message.

Okay I got it running, and my activation method of choice is a KM macro that simply activates the qNote application. But there’s a CRAZY delay in doing so and the window popping up. Not sure what’s going on…


Perhaps it is best to test the performance of the script by running it directly from the Script Editor or Script Debugger. I don’t have KM so I have no idea on how KM launch script. If the performance is still slow, perhaps I’m too optimistic about the performance of the script! Please accept my apology :pray:

I saved it as an app as suggested and just use KM to launch it.

What I suggest is a troubleshooting process: if the performance of the script is reasonable when it is launched directly from Script Editor/Script Debugger, then perhaps the way KM launch the script has some unexpected consequence (by me), else the use of Dialog Toolkit Plus is more demanding on system resources (memory or CPU) than I have expected.


hi Ngan: whatever the date I set the DTP note alarm (not calendar) date sets to 5-5-2022?
any suggestions. thank you

I am assuming that you aren’t using the UK date format in your OS? I don’t have much experience in localisation but can you post a screenshot of the dialog showing what you have entered?

I think it’s the format of iniEventDateTime. E.g., if ur system is using US date format, try changing the iniEventDateTime to:

set iniEventDateTime to do shell script "date  '+%m.%d.%Y %H:%M'"

Or change the iniEventDateTime to an order/format that is consistent with your system.

thank you Ngan. yes that did the trick for the date. The time now is always 12:00AM now!

thanks again!

Can u show a screenshot? And what’s the date/time format of your system?
The setting of iniEventDateTime should be the same as your language and region setting except that no comma is needed between date and time, and the “/” can also use “.” (I think).

I have been using the script for a few days and have decided to add three features in this updated v1b7. The design will be frozen now.

qNoteV4b7.scpt.zip (57.6 KB)

  1. Add “Custom…” to the location list. The user can choose to save the note into other groups. The DT’s group selector will be shown after the “OK” button is clicked.
  2. Add an “Open Group” button that allows the user to jump to the selected group in the currently active DT’s viewer window - just make sure that nothing is entered in the body field or else the work will be lost!

  1. Add an internal preference to set up the shortcut key (cmd+letter) for the buttons.
  • The user can choose their letters by changing property buttonListShortcut .
  • Don’t use “c” or “v” or “x” - they will interfere with the normal copy-and-paste function in the body field.
  • If no shortcut key is needed, just change {"", "o", "u", "s", "f", "t", ""} to {"", "", "", "", "", "", ""}
property buttonList : {"Cancel", "Open Group", "+Web URL", "+Screenshot", "+Code", "+Text", "OK"}
property buttonListShortcut : {"", "o", "u", "s", "f", "t", ""} -- match the shortcuts with the buttons' position in buttonList

Final Note:
Grabbing the web URL is the trickiest part in this script and the feature may not work sometimes. The last resort is to increase the delay in this handler by increments of 0.1 until the feature works. I have no other solution as of now.


on getWebLink()
		tell application "System Events"
			tell (first application process whose frontmost is true)
				-- this "it" here is this script, and set itself to inviaible
				set visible of it to false
				-- this is crucial, without this delay, the coding won't work.
				-- it gives sometime for the system to register the previous frontmost app
				delay 0.4    -- <== this delay
				-- this "it" becomes the app the user is working on right before the script is invoked.
				set theActiveApp to name of it
			end tell
		end tell
		activate me
	on error
		display dialog "Err getWebLink 1"
	end try
		if theActiveApp is "Safari" then
			tell application "Safari"
				set theWebURL to URL of front document
				set theWebName to name of front document
				return "[Source: " & theWebName & "](" & theWebURL & ")"
			end tell
		else if theActiveApp is "Google Chrome" then
			tell application "Google Chrome"
				set theWebURL to URL of active tab of front window
				set theWebName to title of active tab of front window
				return "[Source: " & theWebName & "](" & theWebURL & ")"
			end tell
			return ""
		end if
	on error
		display dialog "Err getWebLink 2"
	end try
end getWebLink

Hi, when you ran the app for the first time, was DT opened? The reason is that the script will open DT and its relevant databases (of the groups for notes) before showing its dialog box for the first time (hence the possibility of delay). If such is the case, running the script should be much faster afterwards.

I am in USA, PST timezone.
here are the screenshots. thanks again for your kind help

I changed my system to US date-time format to test the script. It seems that for US time zone, the script needs to use 12 hr AM/PM format. I have changed this newer version of script to US date-time format e.g. 5/29/2020 08:30 AM. Remember to copy your uuids back to the script. Hope it’ll work this time.

qNoteV4b7.1 (US).scpt.zip (59.0 KB)

P.S. If you want to use the earlier version, the only changes are these two lines:

set iniEventDateTime to do shell script "date  '+%m/%d/%Y %I:%M %p'" -- US date-time format
set iniDateInTitle to do shell script "date  '+%A, %d %b %Y at %I:%M %p'" -- title being shown in the dialog