You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Triple-click mouse macro for selecting paragraphs of text

I have a Logitech mouse whose driver lets you create macros. I've created one for triple-clicking text so that I can highlight an entire paragraph of text with the push of one button (rather than three rapid ones). I've tested this macro with dozens of different delay values between events, in different applications, on different Macs, and on different versions of macOS. I've also tried every single value possible for the double-click speed in System Preferences, yet the macro simply won't select text. The same is true when trying to select individual words with a double-click macro. However, these Logitech macros *do* work correctly on Windows.


The folks at Logitech proved that the macro is doing its job by sending me to this JavaScript snippet. Therefore, the problem is within macOS, but when I contacted Apple Support, they told me they can't help me since the mouse wasn't made by Apple.


I've tried creating an executable Apple Script with the cliclick library. That also doesn't work.


Any ideas would be appreciated.

MacBook Pro with Touch Bar

Posted on Apr 29, 2022 3:01 PM

Reply

Similar questions

12 replies

May 8, 2022 3:50 AM in response to mph206

This really isn’t a macOS issue per se, it’s a mouse driver for macOS issue. Logitech does provide a perfectly functional option for assigning a triple-click to a mouse button depending on the software and model of mouse supported. For example, with Logitech Options and the M720 Triathlon, select Mouse, select a button, select Click, and then select Triple click:



Another example, with Logitech Options+ and the Signature M650 L, select the mouse, select Buttons, select a button, select Advanced click, and then select Triple click:



If you have a Logitech gaming mouse, such as the G703 and use Logitech G Hub software, your options are limited for triple-click implementation. By comparison, a double-click button assignment is trivial: select the mouse, select the Assignments icon (+), select System, and drag Double Click onto the button of your choice:



Logitech is capable of offering a simple option to add triple-click as they do with double-click. Why they don’t is inexplicable. That leaves one with the option of using a macro in G Hub in combination with other utilities to patch a workaround together. If you simply create a macro to record mouse clicks, and then run the macro by depressing the assigned mouse button, it will fail to select text. However, it will click on hyperlinks, buttons, and function for inserting a cursor.


I’ve tried the following two methods, both of which work. The AppleScript is somewhat faster than the cliclick script. Save the following AppleScript to your Scripts folder as a .scpt file. Assign a keyboard shortcut in FastScripts, or use another method of your choice. In G Hub, create a no repeat macro to record the keyboard shortcut. Delete all the delays. Then just assign the macro to a mouse button.


-- From Fredrik71 at https://macscripter.net/viewtopic.php?pid=207491#p207491 with modified delay.

use framework "Foundation"
use framework "Quartz"
use scripting additions

delay 0.5

clickAtPosition(3)

on clickAtPosition(clickRepeatTimes)
	set {width, height} to item 2 of (current application's NSScreen's mainScreen())'s frame()
	tell current application's NSEvent to set thePosition to |mouseLocation|()
	repeat clickRepeatTimes times
		current application's CGPostMouseEvent({thePosition's x, height - (thePosition's y)}, true, 1, true)
		current application's CGPostMouseEvent({thePosition's x, height - (thePosition's y)}, true, 1, not true)
	end repeat
end clickAtPosition


The second method involves using cliclick as the click engine with a triple-click at current cursor position command (cliclick tc:.) saved in a shell script as a .sh file in your Scripts folder. You'll need to run chmod 755 on it in Terminal to make it executable.


#!/bin/zsh

/usr/local/bin/cliclick tc:.


If you prefer an AppleScript version:


do shell script "/usr/local/bin/cliclick tc:."


As with the AppleScript, assign a keyboard shortcut in FastScripts or by using another scripting utility. In G Hub, create a no repeat macro to record the keyboard shortcut. Delete all the delays. Then just assign the macro to a mouse button. 



This next part is important. In use, when selecting a block of text such as a paragraph, there are some apps that only require you to statically click the macro assigned button, but other apps require that the cursor be moved from its initial on-click position. The cursor needs to move, but not very far. Otherwise, the text selected may be wrong or incomplete. Moving the cursor in all apps is not a bad idea. One thing to keep in mind is that this workaround will be somewhat slower than if natively built into the mouse driver.


Mac mini (2018), macOS Monterey Version 12.3.1

May 13, 2022 5:55 AM in response to mph206

You’re welcome.


I also looked into setting up a triple-click in G Hub using scripting. The script editor is accessed from Profiles in the Games & Applications window. G Hub’s script editor allows you to write scripts in the Lua programming language with the Lua API to control mouse and keyboard functions. For instance, using this script you can simulate a triple-click of the left mouse button:


function OnEvent(event, arg)

    -- 4=Mouse Button 4
    if event == "MOUSE_BUTTON_PRESSED" and arg == 4 then
            -- for <variable_name> = <initial_value>, <final_value>, <step> do
            for i = 1, 3, 1 do
                --[[
                Simulate a left mouse button click (press and release)
                1=Left Mouse Button
                --]]
                PressAndReleaseMouseButton(1)
            end
    end
    
end


G Hub's Script editor with console:



Unfortunately, it suffers from the same deficiency as with creating a macro. This makes sense because it’s the same mouse driver. You can click on hyperlinks, buttons, and insert the cursor, but it won’t select text.


Another option that does work is to use third-party software such as BetterTouchTool or Keyboard Maestro to assign a triple-click to a mouse button. In testing, both these solutions were reliable and as fast as a native mouse driver.


Add a Triple-Click Mouse Function Using BetterTouchTool


In BetterTouchTool, select All Apps in the app sidebar. Select Normal Mouse at the top. Click [+] under Add first Normal Mouse Trigger for All Apps. Under Normal Mouse Configuration, click Please Select a Trigger with the unassigned mouse button you want to use. BTT may label the mouse buttons differently than G Hub. Click Save. Click [+] under Assign First Action to Selected Trigger. Under Action Configuration click No Action, click Mouse Click Actions, then select Custom Mouse Buttons & Modifiers(⌃⌥⇧⌘). Under Trigger Down & Up?, select Trigger Only Mouse Down. Under Click Type, select Left Triple Click.



You’ll need to add BTT to Accessibility under the Privacy tab of System Preferences’ Security & Privacy Pane.


You’ll also want to keep the BTT process running in the background. From the menubar, click BetterTouchTool, then  Preferences. Under Standard Settings in the sidebar, click Basic, then select Launch BetterTouchTool on startup. You may want to also under Advanced Settings, click General, then select Restart BTT after wake from sleep. Close both BTT windows, but don’t quit the app. Triple-click should now work everywhere whether the G703 is wired or wireless.


Add a Triple-Click Mouse Function Using Keyboard Maestro


In the Keyboard Maestro editor, select Global Macro Group under Groups. Click [+] under Macros. Give it a title. Click New Trigger. Select USB Device Key Trigger. Hover the cursor over None and physically click an unassigned Mouse button you want to use. Select 'ignoring modifiers'. Under 'Will execute the following actions,' click No Action. Under Actions scroll to or search and double-click Move or Click Mouse. Click Click and select 'Triple click'. Click to the right of 'relative to the' and select 'current mouse location'. You’ll need to create separate macros for both USB wired and USB receiver conditions. You can use the same mouse button assignment. Quit Keyboard Maestro. The Keyboard Maestro Engine.app process will keep running in the background.



You’ll need to add both Keyboard Maestro.app and Keyboard Maestro Engine.app to Accessibility under the Privacy tab of System Preferences’ Security & Privacy Pane. Also make sure Keyboard Maestro.app is added to Automation.


Also, from the menubar, navigate to Keyboard Maestro > Preferences > General and select Launch Engine at Login. You’ll need to do this if you want the triple-click macro available after restarting your Mac.

May 10, 2022 12:09 PM in response to Roote

Thanks for the detailed response! I do indeed have a G703 gaming mouse, even though I'm not a gamer. After complaining for 18 months, Logitech gave me a refund. I wish they'd just fix this bug instead, though.


The AppleScript approach does work, but it's *painfully* slow, even with a lower delay value. I would rather quickly click my mouse button three times. :)


I could try the MX series, but then I won't be able to use the Powerplay wirelessly charging mousepad of theirs, I'm assuming.

May 18, 2022 5:41 AM in response to mph206

I glad it worked out for you. Logitech's mouse driver for the G703 is an odd duck that doesn't play well with others. It's telling that it takes a third-party app to provide a basic function for Logitech's own product. BTW, there's no need to delete macros in Keyboard Maestro to disable them, you can disable macro groups and individual macros by unchecking them. For any questions you might have there's extensive help from the Help menu in the menubar.

May 18, 2022 8:10 AM in response to Roote

Yeah... I felt like it was hijacking my OS in a rather ugly way, so I fought back and scorched the earth. It has a ton of impressive features, though! I've set up my mouse wheel button to triple click text, copy to the clipboard, and trim the whitespace. The silly DPI button below the wheel now clicks & pastes. 😎

May 22, 2022 11:23 AM in response to mph206

It's not possible to disable Logitech's default Middle Click behavior, but I solved the problem by creating a weird keyboard macro in G HUB (Cmd-Shift-F9), assigning that to the middle mouse button, and taking over that new keyboard shortcut within Keyboard Maestro for my triple-click, copy, trim macro.

Triple-click mouse macro for selecting paragraphs of text

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.