Calling any AppleScripting Wizards for scripting button click in UI

GabeShack
Valued Contributor III

Hey all, we have had an issue where about 653 of our laptops didnt renew their MDM profile when it was expiring.

I'm now in process of re-enrolling them with the profiles renew -type enrollment command, however it prompts the end user to go a click install on their computer to complete the process.  Since we had them approve the ability for applescript to do keystrokes and mouse clicks perviously, I am thinking I could script the click of the update button in notification center when it pops up.

 

I'm struggling to determine the UI element that is showing this button though.  Does anyone have any clues to processing the click of the update button seen here?  I always respect @mm2270 and their work, wondering if you have any idea if I can make it click this update button.

Screen Shot 2022-11-21 at 11.02.23 AM.png

Gabe Shackney
Princeton Public Schools
2 ACCEPTED SOLUTIONS

boberito
Valued Contributor

The Jamf seal heal thing works great when the Jamf binary is broke. This is for the MDM Profile.

I don't think there is a way to GUI script notification acknowledgement. There are ways to script mouse clicks at a specific location - https://apple.stackexchange.com/questions/266784/how-do-i-make-the-mouse-click-at-current-location-u... gives a small idea. 

View solution in original post

GabeShack
Valued Contributor III

@KrisMallory Yea, the self healing is just for the framework not for mdm.  If the mdm profile doesnt renew for some reason its a full re enrollment thats needed, but I think I found a way to automate this as much as possible.

@boberito Yea thanks, I was trying to tell it to use the UI info in the notifications box to click the update button, but if i keep it more generalized, it looks like I can make this work with just the coordinates.  

If anyone else is looking for this after pushing a sudo profiles renew -type enrollment command just run this for a 13" MacBook Air:

 

 

 

#!/bin/bash 
currentUser=$(/bin/ls -l /dev/console | /usr/bin/awk '{print $3}')
profiles renew -type enrollment
sudo -u $currentUser osascript <<EOF 
tell application "System Events"
		delay 2
		click at {1242, 96} -- {from left, from top}
        click at {1242, 96} -- {from left, from top}
        delay 2
        click at {772, 366} -- {from left, from top}
	end tell
EOF

 

 

 

 

Gabe Shackney
Princeton Public Schools

View solution in original post

4 REPLIES 4

KrisMallory
New Contributor III

Check this out instead. We were able to repair a number of devices with the API.

https://www.modtitan.com/2022/02/jamf-binary-self-heal-with-jamf-api.html

boberito
Valued Contributor

The Jamf seal heal thing works great when the Jamf binary is broke. This is for the MDM Profile.

I don't think there is a way to GUI script notification acknowledgement. There are ways to script mouse clicks at a specific location - https://apple.stackexchange.com/questions/266784/how-do-i-make-the-mouse-click-at-current-location-u... gives a small idea. 

GabeShack
Valued Contributor III

@KrisMallory Yea, the self healing is just for the framework not for mdm.  If the mdm profile doesnt renew for some reason its a full re enrollment thats needed, but I think I found a way to automate this as much as possible.

@boberito Yea thanks, I was trying to tell it to use the UI info in the notifications box to click the update button, but if i keep it more generalized, it looks like I can make this work with just the coordinates.  

If anyone else is looking for this after pushing a sudo profiles renew -type enrollment command just run this for a 13" MacBook Air:

 

 

 

#!/bin/bash 
currentUser=$(/bin/ls -l /dev/console | /usr/bin/awk '{print $3}')
profiles renew -type enrollment
sudo -u $currentUser osascript <<EOF 
tell application "System Events"
		delay 2
		click at {1242, 96} -- {from left, from top}
        click at {1242, 96} -- {from left, from top}
        delay 2
        click at {772, 366} -- {from left, from top}
	end tell
EOF

 

 

 

 

Gabe Shackney
Princeton Public Schools

PerryK
New Contributor III

I wonder if umad would detect this situation also and encourage the user towards clicking the option ?

https://github.com/macadmins/umad