0

Title pretty much says it all. Also if anyone knows how to drag and drop something into a browser using any language or command(s), please share.

To be clear i'm talking about something like this:

  1. Press command+f
  2. Type in "the"
  3. (Insert magic hotkey, or bit of code, here, that does anything at with the word currently highlighted by command+f)

This could be used to click a link, for instance, or highlight the first word in a sentence (if you could use the command to do 2 clicks in quick succession) (at which point you could use shift+arrow keys to highlight the rest of the sentence, or the other commands to highlight by more than one character at a time, like shift+command+arrow keys)

As far as i know no such shortcut exists, but i don't see why, (so maybe one does exist and i'm just not aware of it).

  • 1
    You will need several shortcuts that are already implemented. For example copying you can do with CMD+C and clicking with your mouse or trackpad. – Jules Dec 10 '15 at 7:09
  • You cannot do command f then directly begin to highlight or click on a word (and thats what im asking about). I know about clicking with a physical mouse, i'm wondering if theres a shortcut to click the item current highlighted by command+f. Clearly theres none, or none that are widely known anyways. – pau Dec 10 '15 at 14:36
  • Ok, this explains your question more to me. Perhaps you could edit your question to avoid downvotes. – Jules Dec 10 '15 at 15:00
  • I said a shortcut or some code to click the item currently highlighted by command f. I also said i'm looking for a shortcut/piece of code, that would enable me to click (Which I'd think rules out the possibility of "click it" being a valid answer). How should i phrase the question? I don't know how to say it any better better. – pau Dec 10 '15 at 17:12
  • i think the problem is more with the question itself than its phrasing. Its hard to elegantly phrase that question without using like 3 sentences to prevent people from misinterpreting it. I probably shouldv'e left it as simply "Is there a shortcut or way to use code, to do anything with the item currently highlighted by Command+F?" – pau Dec 10 '15 at 17:22
1

If you select text in Safari (your example) Accessibility Inspector will list among Attributes:

  • "Passive" text . . AXRole: AXStaticText   /   AXValue: [text of a whole paragraph]
  • Link . . . . . . . . . . AXRole: AXStaticText   /   AXValue: [link name]

There's not very much functionality to detect there, is it?
Selected text in TextEdit on the other hand will display:

  • [Any text] . AXRole: AXTextArea   /   AXValue: [Whole text]   /   AXSelectedTextRange: [value]
  • [Link] . . . . AXRole: AXLink   /   AXRoleDescription: Hyperlink   /   AXURL: [its URL: http://...]

In Safari not too much can be done with highlighted text. Other programs -TextEdit!- that support accessibility more naturally, CAN be manipulated to a higher degree.

If you look at the hierarchy of a quite common button ("edited" on this page) it will reveal itself as:

AXStaticText ["edited"] / AXLink / AXGroup / AXWebArea / AXScrollArea / AXGroup / AXGroup / AXTabGroup / AXSplitGroup / AXWindow:AXStandardWindow / AXApplication

Doesn't sound very inviting to me, searching for a simple button ...
If I had to do a search I'd rather look into a Safari-document's source, text or URL, all of which are accessible, see: Safari's sdef file.

0

Quite some time since I last saw this question.
Just now came to my mind that I regularly use highlighted words (can be selected by Cmd-F, escape) via a bookmarklet to look them up in Wikipedia.

If this is what you meant, copy this code, save into a bookmark (replace "http://…") and assign a shortcut via System Preferences > Keyboard > Shortcuts > Application shortcuts > [+] icon blow right window > type bookmarklet's name, assign shortcut.

Here is what (little) JavaScript you need for Wikipedia:

javascript:doGetSel=window.getSelection();%20%20open(%22http://de.wikipedia.org/w/index.php?search=%22+doGetSel);

Adapting this code to any other site is simple. Search anything on that other page, copy its search string and replace "http://de.wikipedia.org/w/index.php?search= … with whatever you want.

I use similar code to get words/sentences translated by translate.google:

javascript:doGetSel=window.getSelection();%20%20open(%22https://translate.google.de/#en/de/%22+doGetSel);

  • My idea was just that i wanted to be able to not use the mouse ever. I wanted to be able to look for the thing i was looking for on a page, then maybe click on it, or selected the entire sentence. I know if you select a word, you can then select more text by holding shift and using the arrow keys. But, to be clear, my idea is simply that i was trying to imagine how one could completely stop using a mouse, but a more elegant way than some other solutions id found.I found something called shortcat but i forget why but it seemed sort of lacking. They had a way of moving the mouse using kb – pau Nov 29 '18 at 8:39
  • Well, that's not a PROBLEM but just a second STEP. Quite easy. Once you made this bookmarklet, just go to System-Preferences > Keyboard > Shortcuts > App-Shortcuts > [Add to Safari] and type the name of your bookmarklet (will also be found if in your favourites bar). I use Opt-w to open the article in wikipedia. – clemsam lang Nov 29 '18 at 9:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .