Jump to content

How to select all the contents of frontmost webpage and write it to a text file?


Recommended Posts

I was trying to use Key Combo `cmd a` and `cmd c` to copy the contents from the frontmost webpage. But, the command A, key does not work, I do not see the selected text (as we see when we actually press the cmd a on keyboard) and the workflow does not work.

 

How to use AppleScript for that instead of using `Key Combo`?

 

# Shared link

https://github.com/bhishanpdl/Shared/blob/master/Alfred_questions/z mycopy.alfredworkflow?raw=true

 

# My Workflow

keyword > delay > Keycombo cmdA > Keycombo cmdC > delay > write

2021-12-20-08-52-49.png

Link to comment
43 minutes ago, Bhishan said:

How to use AppleScript for that instead of using `Key Combo`?

 

That’s not going to fix your issue. You’d be faking the keypresses anyway, so it’s the same solution run a different way.

 

Are you sure your browser is the active application at the time you run your Workflow? Also, are you sure you don’t have a text input selected at the time you run it? If so, what page are you running your Workflow on? It works fine for me.

Link to comment

I just tried copying contents from right this webpage. It does not work.

macOS:  catalina MacBook Pro 2017

 

I got two problems:

1. This did not copy contents from frontmost webpage (I tried on right this page). Somehow the cmd A is not working ( I do not see any selected text, but I see them when I directly press them in my keyboard though)

 

2. the output file name is not `hello.txt` instead it wrote {var/fname}.txt   ( I gave that command in bash script at the end of workflow).

 

 

2021-12-20-10-04-39.png

Edited by Bhishan
Link to comment
22 minutes ago, Bhishan said:

Somehow the cmd A is not working ( I do not see any selected text, but I see them when I directly press them in my keyboard though)

 

Would you share a video? This is very likely a problem on your side; I can’t reproduce at all.

 

23 minutes ago, Bhishan said:

the output file name is not `hello.txt` instead it wrote {var/fname}.txt

 

You can’t use Alfred’s {var} inside scripts, you have to use what the language itself expects. In this case, you need to make it "${fname}.txt" (mind the quotes, or you’ll have issues with filenames with spaces).

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...