Instantly share code, notes, and snippets.

What would you like to do?
Clicking "Allow" button in System Preferences via Screen Sharing
# This is clicking "Allow" in System Preferences "Security & Privacy" screen
# when you're on Screen Sharing. Otherwise it doesn't work.
# To fix:
# - Put "Security & Privacy" window in the top left screen
# - open a Terminal on a side
# - save click.oscript
# - Run: osascript click.oscript
# The mouse click you send should hit "Allow" button. You may need to move the window a little bit.
# Script originally from:
set x to 550
set y to 490
do shell script "
/usr/bin/python <<END
import sys
import time
from Quartz.CoreGraphics import *
def mouseEvent(type, posx, posy):
theEvent = CGEventCreateMouseEvent(None, type, (posx,posy), kCGMouseButtonLeft)
CGEventPost(kCGHIDEventTap, theEvent)
def mousemove(posx,posy):
mouseEvent(kCGEventMouseMoved, posx,posy);
def mouseclick(posx,posy):
mouseEvent(kCGEventLeftMouseDown, posx,posy);
mouseEvent(kCGEventLeftMouseUp, posx,posy);
ourEvent = CGEventCreate(None);
currentpos=CGEventGetLocation(ourEvent); # Save current mouse position
mouseclick(" & x & "," & y & ");

This comment has been minimized.

johnkeates commented Jan 30, 2018

For everyone who has trouble making this work, try duplicating the mouse click line in case you need two clicks.


This comment has been minimized.

deejaywoody commented Mar 30, 2018

Thanks for this! I was going crazy, then realized it was an Apple protective measure.


This comment has been minimized.

williamthrilliam commented May 1, 2018

I received this error: click.oscript: line 15: syntax error near unexpected token do' click.oscript: line 15: do shell script "'
ps. thanks for this


This comment has been minimized.

zirinisp commented Jun 26, 2018

I duplicated the click and I can see the pointer moving on top of allow, but nothing happens.

I am running everything on a screen share window.


This comment has been minimized.

vamossagar12 commented Oct 28, 2018


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment