I am trying to figure out how to make a macro that highlights paragraphs & then highlights & adds notes. I’ve been able to make a macro to change the highlight color & another one to add a note in the kindle app.
The macro below allowed me to drag a couple of letters, but each paragraph is different, so it’s hard to make one that consistently works with every paragraph.
Your current macro hardcodes the position of the mouse, telling the mouse where to click and drag. I would be surprised if that's what you want. I suspect what you want us for the macro to "select the next paragraph" from the current position of the flashing text cursor. Dragging the mouse works only if you already know the starting and ending position of the paragraph, which I suspect is something you do not know.
One of the key questions is whether the Kindle app supports AppleScript. I don't have the app so I can't test that. And if I had it, I'm not very good with AppleScript. Can you check if it supports AppleScript?
If the app does not support AppleScript, there may still be hope, because the app may have keyboard shortcuts for things like "Select next paragraph." And even if it doesn't have that, there might be a third option, but there's no point in talking about that yet.
In short, there is hope, but I don't think it's clear what you want to do. By any chance, can you work on creating a keyboard-only key sequence, rather than a mouse sequence, to achieve your goal? If so, this will likely be easy. But if you don't have a key sequence documented to solve your problem, there's still hope. I'm glad you brought your problem here, but there's still too many unknowns to know if we can set you up.
Kindle is the most bare-bones of Mac apps that you'll ever see. There are no menu commands for anything other than stock macOS features. There are no preferences. There's no contextual menu.
So in the end, I think Click at Found Image is the only thing that will work. I whipped up a quick macro that lets you pick a highlight color or a note, all from one keyboard shortcut. When you press Shift-Control-M after highlighting a section of text, you'll see this:
Type N for note, O for orange, etc. The macro then clicks at the right spot to apply your selection. And here's what each of those macros looks like; this happens to be the one for a note:
I left the comment in place with the values I found for each location, just in case.
INCREDIBLY IMPORTANT COMMENT: This macro will probably not work on your Mac, due to the way Found Image works. You need to capture the pop-up in Kindle and paste it into the image well in the Found Image action in my macro on your Mac. Capture it with Shift-Command-Control-4 (copy region to clipboard), and get just the buttons (none of the surrounding text), like this:
It doesn't have to include the line as mine does, but it must not include any text on the page, as that will change.
Once you do that, though, it should work for you. It does here in my admittedly limited testing. And you don't have to use this pop-up palette method either; you could make each macro standalone and run them on separate keys.
That’s exactly what I want. I don’t want the mouse position to be hardcoded like I did in the macro. I’d like it to be more variable, but I don’t know how to do that
I googled it & don’t know. No one discussed using an apple script with it & I don’t know how to use apple script
No. There’s no keyboard shortcuts available to do this. That’s what’s so annoying about this app.
Was I clearer above or are there more unknowns I can clarify? Basically, dragging my cursor from the beginning of a sentence to the end of one is difficult physically for me, so I’d like a way to do it through a keyboard shortcut. I have a macro that copies my mouse coordinates, so I was thinking of using that in some way, but the variable actions in KM confuse me.
Thank you for this comment. I figured out how to highlight text, but your macro is much better than me, so thanks for this, I’m also trying to figure out a marco to drag my cursor across varying paragraphs
Unfortunately, I think it will be impossible to really control the mouse the way you need to in order to accurately select text via a keyboard shortcut. Kindle must have the mouse down to start selecting, and it stops on mouse up. That wouldn't necessarily be a problem, except I don't see any way to reliably identify the end of a paragraph. There's just so much variability—some end near the right edge of the page, others near the left.
Some books might be formatted in such a way (i.e. blank lines between paragraphs) that you could use a found image action to get there, but it'd be a real pain: You'd have to capture the mouse's coordinates when you start your macro, then grab a selection of screen down and right from that point, then try to identify the blank line, etc.).
In short, the app is so feature-limited that I don't see any way you can select the text via the keyboard and Keyboard Maestro. Maybe someone will find a creative solution, but I sure don't see it.
Your best bet might be Mouse Keys (in System Settings), which lets you control the mouse via keyboard keys or the numeric keypad. But that's incredibly fiddly to use in practice; holding the mouse down and moving requires holding one key down while pressing others.
That was much, much clearer. @griffman's approach might be workable. But if it doesn't work, I think I have an idea using OCR that should work quite well too. The problem with OCR is that it doesn't tell you where the text was found, and it also requires a little repagination to reconstruct the paragraph, but I think with a little trickery, and a little compromise on your side, we could make it work.
For example, I think it would be possible for a macro to extract paragraphs simply by using OCR to extract the text from the window. For example, the number 1 could be a hotkey that would place the first full paragraph in the Kindle window into the clipboard. The number 2 could place the second full paragraph into the clipboard. That sort of thing. This may work well if the text you are reading is normal novel-like text, but wouldn't work well if your text contained a lot of images or formulas.
I haven't given any thought to the part of your problem where you want to "highlight and add notes" because I don't have the Kindle app.
I think this is the crux of the problem: Highlighting and notes are features of the Kindle app that require the reader to select text—using just the mouse, as there are no keyboard modes for text selection—then use that pop-up image shown above to either highlight or add notes. @Swin is trying to make the selection of the text keyboard based, not mouse based. I don't see any way at all to do that in Kindle itself.
Maybe if you OCRd the region around the mouse, you could find the paragraph break, but you'd then have to translate that back into mouse coordinates for the end-of-drag location. If anyone can do it, though, you can as you're the definitive OCR master around here!
I think it's entirely solvable, under certain conditions. I'm not sure if the user can meet these conditions because I have not seen a sample screenshot.
For example, I can convert OCR to screen location, but only if the number of lines per inch is consistent. If the Kindle App puts extra vertical space between paragraphs, it may complicate matters. I would need to see what I'm trying to solve. (The user is under no obligation to share the text he wants to process, but without seeing something formatted very similarly, I probably can't write any code.)
I had a bit of a thought last night about this...hopefully @Airy can come up with an OCR-based mechanism that works for you to select text via the keyboard. But in the interim, I came up with a method that lets you at least select text without having to drag-select the region.
I posted it in a new thread, as it doesn't directly address what you're trying to do, but others may find it useful:
By calling it "daunting," I'm tempted to write it, to get another one of your highly coveted compliments.
One of the samples you provided would be workable. But most of them would not be (easily) workable because they contain a mix of fonts, subtitles, inconsistent spacing and/or image placement. Since I don't know what the original poster's text looks like, I can't determine if I'm going to be able to solve the problem. But I will spend an hour pondering it with some "easy sample text."
FYI - Here is a list of Kindle for Mac commands. When I compare it to the MacOS Books app, it's surprisingly similar. In other words, both are poor.
Kindle for Mac functions...
Anywhere in the Application
Open Library - Command, ALT, L
Sync - Command R
Kindle for Mac: Preferences - Command ,
Kindle for Mac: Quit Kindle for Mac - Command Q
File: Close Book - Command W
Actions: Sync and Check for New Items - Command R
Go: Sync to Furthest Page Read - Command R
Move the focus of the book above the current selection - Up Arrow
Move the focus of the book to the right of the current selection - Right Arrow
Move the focus of the book to the left of the current selection - Left Arrow
Move the focus of the book below the current selection - Down Arrow
Scroll the list of books up one page - Page Up, Command, Up Arrow
Scroll the list of books down one page - Page Down, Command, Down Arrow
Open selected book (go to last page read)* - Return, Command, O
Next Page - Page Down, Command Down Arrow, Enter, Right Arrow, Space, or Down Arrow
Previous Page - Shift Enter, Shift Space, Page Up, Command Up Arrow, Left Arrow, or Up Arrow
Back - Delete, Backspace
Increase font size - Command +
Decrease font size - Command -
Bookmark - Command D
Open/Close Notes and Marks - Command B
Go to Location - Command G
Search - Command F
Open Flashcard side panel - Command, Shift, F
Open and close X-Ray for Textbooks - Command Y (only works on eligible Textbooks)
Export to Flashcards from Notebook - Command, Shift, N (when using the Notebook)
Export Notes from Notebook - Command, Alt, E (when using the Notebook)
Text-to-Speech is only supported with Mac OSX 10.10 or above.
To use these shortcuts, you must enable Text-to-Speech first. Press Command T or select the Tools menu and choose Start Text-to-Speech.
Toggle Text-to-Speech - Command T
Pause or resume reading - Space bar (while in a book)
Read the current sentence - Command S
Read the previous sentence - Command, Shift, Up arrow
Skip forward one sentence - Command, Shift, Down arrow
What's extra funny is that some of those don't even work: They're from the older version, which had at least a few actual Mac-like features. There aren't preferences any more, so Cmd-, does nothing. All those "move focus of the book" actions? Nothing. Flashcards? Nothing. etc...
Readers can also easily make changes to how things look in their books:
Yes, changing some of those settings would (unless the code was very complex) mess up any OCR-based actions, but the fact that these options exist may help make OCR-based actions work better. For example, a single column display would probably help me out. But we don't know if the user is going to say things like, "I need the smallest font possible with two column output." Such choices may make my solution harder to write. We still don't know whether the user's books have titles on every page or not.
I guess I could download the app myself (for now I'm just using Apple Books to prototype) but can you tell me what the "Low Vision" option does? Also, what does "Continuous Scrolling" do? If it does what I'm guessing, that could be helpful.
You recall I wrote a powerful macro to do binary searches on a window using OCR to locate the position of a word. I don't plan on using that here. I have a simpler idea.
Treats the entire book like it's one massively-long single-column page. One other issue I forgot to bring up is that the window is also resizable. Here's continuous-view in a few widths:
Thanks. Apple's OCR is so accurate I don't think it will need "Bigger and Bolder," but the "Draft" mode (as Word for Windows calls it) could be helpful.
I tried this and I think it actually works pretty well. If OCR doesn’t work, this solution is a better workaround than I could come up with on my own. Thank you so much @Airy@griffman for responding & helping me through this issue
so that I wouldn’t have to use the command palette, but would you mind explaining what is the usefulness of the command palette because maybe I made things worse by changing that aspect? Also, how do you get the mouse coordinates relative to the found image’s corner. I want to replicate what u did, so I can close the note window with a shortcut.
Using a conflict palette means the main macro can just call the conflict palette after you select some text. But as you've set it up, given Kindle doesn't let you type text (outside of a note), it's quicker to use—select the text, that macro ends, then just press one of the shortcut keys. So for Kindle, your way is probably a better solution.
Personally, I use a palette because I hate memorizing keystrokes, though these five would be pretty easy :).
I'm not sure I understand the question, as I don't do that anywhere that I can recall :). The main macro just saves the mouse's location at the start of the major and after you move it. Those values are just raw values on the screen from the top left.
The sub-macros that pick colors don't get the mouse coordinates at all, they just click at a location relative to the top left corner of the found image, which is the "relative to" pop-up in that action.
I meant this where did you get the numbers 200 & 15. When I use Click at Found Image, I usually use Found Image’s Center, but yours is relative to the Found Image’s corner & that seems to be better :