Community Built

Save to Hejour

Creates a new note in Hejour with the selected text.

By Michael Chrstopher Wiseman

Available in ActionClip 2.3.3. Update ActionClip before installing these actions. Download the action file, open it in ActionClip, then review it before choosing Add Action. Get ActionClip if you haven’t installed it yet.

What it does

Create a titled Hejour note by copying the selected text, opening Hejour, and using keyboard automation to enter the title and content. Keep the source app and Hejour ready; changes in focus may send keystrokes to the wrong window.

How to use it

  1. Available in ActionClip 2.3.3. Update ActionClip before installing these actions.
  2. Choose Download action and open the downloaded .actionclip file.
  3. Review the action and choose Add Action.
  4. Select the text you want to use and choose Save to Hejour.

Requirements

Hejour installed, plus Accessibility and Automation permissions for keyboard control.

Privacy

Temporarily uses the clipboard and sends the selected text to Hejour. Hejour controls any subsequent storage or sync. Clipboard restoration can fail on errors.

Example

Input

Remember to water the plants.

Output

A note containing the selected text is entered in Hejour.
View action source
property appName : "Hejour"

on isFrontApp(p)
	repeat 200 times
		try
			tell application "System Events" to if frontmost of process p then return true
		end try
		delay 0.05
	end repeat
	return false
end isFrontApp

on pasteIt(t)
	set the clipboard to t
	delay 0.1
	tell application "System Events" to keystroke "v" using command down
	delay 0.2
end pasteIt

set saved to missing value
try
	set saved to (the clipboard as record)
on error
	try
		set saved to (the clipboard as text)
	end try
end try
set mk to "ac" & (random number from 100000 to 999999)
set sel to ""
set msg to ""
try
	set the clipboard to mk
	delay 0.1
	tell application "System Events" to keystroke "c" using command down
	repeat 60 times
		delay 0.05
		try
			if (the clipboard as text) is not mk then
				set sel to the clipboard as text
				exit repeat
			end if
		end try
	end repeat
	try
		tell application appName to launch
	end try
	with timeout of 300 seconds
		tell current application to activate
		set r to display dialog "Enter title for the new note:" default answer "" buttons {"Cancel", "OK"} default button "OK" with title "Hejour Note Entry"
	end timeout
	tell application appName to activate
	if not my isFrontApp(appName) then error "Hejour did not come to the front."
	delay 0.2
	tell application "System Events" to keystroke "n" using command down
	delay 0.35
	my pasteIt(text returned of r)
	tell application "System Events" to key code 36
	delay 0.15
	if sel is not "" then my pasteIt(sel)
on error e number n
	if n is not -128 then set msg to e & " (" & n & "). If it mentions keystrokes, allow ActionClip in Privacy & Security > Accessibility."
end try
delay 0.1
try
	set the clipboard to saved
end try
if msg is not "" then display alert "Note entry failed" message msg

Back to Community Built actions