【代码】MacOS批量删除短信

前言

MacOS批量删除短信

源代码

  • 此代码在使用前应先打开信息.app,并将焦点放在第一条短信上

MacOS 13 Ventura 以前

100:设置脚本执行次数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
tell application "Messages" to activate
tell application "System Events"
tell process "Messages"
tell window 1
repeat 100 times --这里输入需要删除的数量
delay 0.5 -- 延时0.5秒
click UI element 1 of group 1 of group 1 of group 1 of group 2 of group 1 of group 1 of group 1 of group 2 of group 1 of group 1 of group 1 of group 1 of group 1 of group 1 of group 1 --选中第一个会话
delay 0.5 -- 延时0.5秒
click menu item "删除对话…" of menu "文件" of menu bar item "文件" of menu bar 1 of application process "Messages" of application "System Events" --激活右键菜单中的删除对话
click button "删除" of sheet 1 of window 1 of application process "Messages" of application "System Events" --在确认删除弹窗中点击删除
end repeat
end tell
end tell
end tell

MacOS 13 Ventura 及以后

100:设置脚本执行次数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
tell application "Messages" to activate
tell application "System Events"
tell process "Messages"
tell window 1
repeat 100 times --这里输入需要删除的数量
delay 0.5 -- 延时0.5秒
click UI element 1 of group 1 of group 1 of group 1 of group 2 of group 1 of group 1 of group 1 of group 2 of group 1 of group 1 of group 1 of group 1 of group 1 of group 1 of group 1 --选中第一个会话
delay 0.5 -- 延时0.5秒
click menu item "删除对话…" of menu "对话" of menu bar item "对话" of menu bar 1 of application process "Messages" of application "System Events" --激活右键菜单中的删除对话
click button "删除" of sheet 1 of window 1 of application process "Messages" of application "System Events" --在确认删除弹窗中点击删除
end repeat
end tell
end tell
end tell

完成

参考文献

CSDN——renyajun1990