Jump to content
unfunfionn

Toggle trackpad pinch & zoom

Recommended Posts

There's a years-old bug in macOS that causes pinch to zoom to stop working under heavy usage. For designers and video editors, this is an absolute productivity killer. It never gets fixed and the only workaround is disabling and enabling it again in System Preferences. Many of us need to do this 10+ times a day.

 

I would like to create an Alfred workflow that toggles this setting with the 'pinch' keyword, but I'm having trouble figuring out A. Whether this is possible and B. How to access that option.

 

Does anybody have some pointers? Thanks!

Share this post


Link to post

It should be possible, yes, with AppleScript. For example, if you use Script Editor to run:

tell application "System Preferences"
    reveal anchor "trackpadTab" of pane id "com.apple.preference.trackpad"
    activate
end tell


You’ll see you’re halfway there. We still need the code to select the specific tab and checkbox, but I’m too tired to think beyond that at this hour. You may also try Ask Different if you’re in a hurry. If you get the correct AppleScript code, it will be easy for us to help you construct the Workflow.

Share this post


Link to post

This is how I do it:

 

1. Open Automator app and create a new "Workflow"

2. Search for action "Run AppleScript" and drag it to the main pane on the right

3. Paste the following script into it:

tell application "System Preferences"
	reveal anchor "trackpadTab" of pane id "com.apple.preference.trackpad"
	activate
end tell
tell application "System Events"
	tell process "System Preferences"
		click radio button "Scroll & Zoom" of tab group 1 of window "Trackpad"
		click checkbox 2 of tab group 1 of window "Trackpad"
	end tell
end tell
tell application "System Events"
	tell process "System Preferences"
		click radio button "Scroll & Zoom" of tab group 1 of window "Trackpad"
		click checkbox 2 of tab group 1 of window "Trackpad"
	end tell
end tell
tell application "System Preferences"
	quit
end tell

4. Save as Workflow and place the file somewhere it won't move.

5. Still in Automator, create new "Application"

6. Search for action "Run Workflow" and drag it to the right

7. On the first line "Workflow:", click on the dropdown menu and select "Other..."

8. Browse for the workflow file you created earlier

9. Save as Application and place anywhere you want.

 

10. Open System Preferences > Security & Privacy > Accessibility, unlock the padlock (bottom left), click on the + button and browse to the application file you created (not the workflow file). At this point you want to make sure the checkbox for the application is also ticked.

 

From now on, anytime the Pinch & Zoom disables itself, just run the app and it will do the job seamlessly.

 

You can keep the app in your dock, or assign it a keyboard shortcut. I use BetterTouchTool for that.

 

What the script does:

Open System Preferences > Open Trackpad pane > Open Scroll & Zoom tab > Click on "Zoom in or out" twice > Quit System Preferences

Share this post


Link to post

And to run Jebediah's script in Alfred.

 

1. Create a new blank workflow.

2. Add a keyword trigger with pinch as triggerword

3. Connect above trigger to a "Run NSAppleScript" Action which you paste in the AppleScript code.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...