Copy txt from web, append txt and URL into text editor running in background?

Hey dudes…

Not sure if this is possible…but it would change my life.

I would like to copy text from a webpage … maybe using the standard copy function or a Popclip extension.

Then have that text and the url from the browser append to a text document running in the background without having to switch apps.

Do we have the technology?

I have 2 ideas:

  1. If your application running the text document in the background supports AppleScript, look for a method to write/append text.
  2. Use KMs Clipboard Manager to append all your text and URLs to a named clipboard (i.e. using a trigger like ⌥⌘C) and use a custom hotkey (i.e. ⌥⌘V) to paste its contents into your application and empty the named clipboard afterwards.

How does this sound?

Yep.

Something like this can get you started. Let me know it you have problems.

This script

runs in an Execute Shell script action

osascript -l JavaScript path to script file

as long as the NSNotification option near the top of the script is set to false. (You can just add a KM notification after the execute script action).

[quote="Rothermel, post:1, topic:621"]
I would like to copy text from a webpage… Then have that text and the url from the browser append to a text document running in the background without having to switch apps.[/quote]

Hey Kevin,

Well that's simple enough if you can live with plain text.

Download and install TextWrangler (if you don't have BBEdit already).

Download the macro.
Double-click it to open in Keyboard Maestro.
Change the keyboard shortcut to suit yourself.

If I was doing this for myself I'd be a bit more fancy and regularize whitespace and maybe a few other things, but this should get you going.

NOTE: Saving the AppleScript as a script file using the Applescript Editor and running the file instead of the text will make it faster.

Best Regards,
Chris


Safari Page Text to TextWrangler.kmmacros (5.1 KB)


Tags: @Safari, @TextWrangler, @Extract, @Text

Oh, yeah.

The script uses this file:

~/Documents/Safari Text.txt

And creates it if it does not exist.

Do not monkey with the path unless you know what you’re doing - tell me what you need, and I’ll change it.

-ccs

Hi and good day,

The script I’m using (Send Notes Quickly) just copies a marked part of a webpage and appends it to the same TextWrangler doc, together with url, title, timestamp! Works with Safari and Chrome. (Got help with it from this community!)

Send Notes Quickly - GText_1
Triggered by any of the following:
The Hot Key ⌃⌥⌘L is pressed
Will execute the following actions:
–Copy to Named Clipboard ‘TempQuickN-a’
–If All Conditions Met
Condition iconApplication ‘Safari’ is at the front
Execute the Following Actions:
–Set Variable ‘url’ to Text
%SafariURL%
Otherwise, Execute the Following Actions:
–Set Variable ‘url’ to Text
%ChromeURL%
–Pause for 0.5 Seconds
–If All Conditions Met
Condition iconApplication ‘Safari’ is at the front
Execute the Following Actions:
–Append Text

capt. %NumberDate% %ShortTime% ===
URL: %url% ===
%SafariTitle%
%NamedClipboard%TempQuickN-a%
To file: /Users/okn/Documents/notes-a_2014.txt
With format Plain Text (UTF8).
–Pause for 0.5 Seconds
–Type the Return Keystroke
–Type the Return Keystroke
Otherwise, Execute the Following Actions:
–Append Text

capt. %NumberDate% %ShortTime% ===
URL: %url% ===
%ChromeTitle%
%NamedClipboard%TempQuickN-a%
To file: /Users/okn/Documents/notes-a_2014.txt
With format Plain Text (UTF8).
–Pause for 0.5 Seconds
–Type the Return Keystroke
–Type the Return Keystroke
–Speak Text With Voice ‘Veena’ at Default Rate
General text was appended at the end!
–Comment ‘If Then Macro to sort the 2 options’
This saves title, url & some marked text!

/
with best regards,
Omar KN
Stockholm, Sweden

Can you please export your macro and upload it here? Thanks.

Hi and good day Mirizzi,

Coming,… ASAP, also our friend from this list, C. S., has probably another (better) macro / AS going on…

Check this page: Updating a KM macro for less UI engagement
There is a download link.

/
with best regards,
Omar KN
Stockholm, Sweden

Thanks.

Upload of the script: Safari OR Google Chrome { Copy to Clipping File } { v1.03b }.kmmacros (28.2 KB)

Now this script was designed by Chris S., now as vs. 1.0.3 and I could not avoid from fiddling with the fonts, font size (22pt!), font color, and date (European, such as 2015-06-02), as vs. 1.0.3b.

Usage: On any website, (Safari or Chrome) just mark som text which you find most important, press the designated hotkey and that's it! A new file with all the necessary info is in your /Users/{YOURNAME}/Documents/_INPUT folder or whatever you want to call it! It is really beautiful piece of automation.

PS: If later in the text I realize I need to add more to the original clipping I bring up the last file with another macro (Open last file in INPUT) and add more to it.

/
with best regards,
Omar KN
Stockholm, Sweden