安卓编程 删除短信 批量删除短信应用程序
最编程
2024-05-07 15:34:33
...
涉及工具
1 mac自带app:“脚本编辑器” 2 原生应用「Accessibility Inspector(需安装 Xcode)」用以定位目标控件的类型,方便在打印的子控件中查找
开始:
模拟操作步骤:
打开message app
tell application "Messages" to activate
复制代码
操作需要在System Events下执行,所以需要tell一下
tell application "Messages" to activate
tell application "System Events"
end tell
复制代码
找到“信息”app
tell application "Messages" to activate
tell application "System Events"
tell process "Messages"
end tell
end tell
复制代码
查找选中要删除的短信
经验性规律:脚本运行结果中的所有 UI 元素是按软件界面中从上到下,从左到右的顺序排列的。
结合Accessibility Inspector ,查找要删除的短信的path
注意,大家的path可能不一样,比我有两个顶置消息所以位置path如下
tell application "Messages" to activate
tell application "System Events"
tell process "Messages"
click UI element 4 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 of window 1
end tell
end tell
复制代码
用“信息”app的顶部菜单栏实现,触发删除操作
查找顶部菜单栏中的删除按钮
delay 给出系统响应和UI事件的时间
tell application "Messages" to activate
tell application "System Events"
tell process "Messages"
click UI element 4 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 of window 1
delay 0.2
tell menu 1 of menu bar item "文件" of menu bar 1
entire contents
end tell
end tell
end tell
复制代码
打印
{menu item "新信息" of menu "文件" of menu bar item "文件" of menu bar 1 of application process "Messages" of application "System Events", menu item 2 of menu "文件" of menu bar item "文件" of menu bar 1 of application process "Messages" of application "System Events", menu item "快速查看" of menu "文件" of menu bar item "文件" of menu bar 1 of application process "Messages" of application "System Events", menu item 4 of menu "文件" of menu bar item "文件" of menu bar 1 of application process "Messages" of application "System Events", menu item "关闭窗口" of menu "文件" of menu bar item "文件" of menu bar 1 of application process "Messages" of application "System Events", menu item "全部关闭" of menu "文件" of menu bar item "文件" of menu bar 1 of application process "Messages" of application "System Events", menu item "删除对话…" of menu "文件" of menu bar item "文件" of menu bar 1 of application process "Messages" of application "System Events", menu item "在单独窗口中打开对话" of menu "文件" of menu bar item "文件" of menu bar 1 of application process "Messages" of application "System Events", menu item 9 of menu "文件" of menu bar item "文件" of menu bar 1 of application process "Messages" of application "System Events", menu item "从iPhone导入" of menu "文件" of menu bar item "文件" of menu bar 1 of application process "Messages" of application "System Events", menu "从iPhone导入" of menu item "从iPhone导入" of menu "文件" of menu bar item "文件" of menu bar 1 of application process "Messages" of application "System Events", menu item "iPhone 13" of menu "从iPhone导入" of menu item "从iPhone导入" of menu "文件" of menu bar item "文件" of menu bar 1 of application process "Messages" of application "System Events", menu item "拍照" of menu "从iPhone导入" of menu item "从iPhone导入" of menu "文件" of menu bar item "文件" of menu bar 1 of application process "Messages" of application "System Events", menu item "扫描文稿" of menu "从iPhone导入" of menu item "从iPhone导入" of menu "文件" of menu bar item "文件" of menu bar 1 of application process "Messages" of application "System Events", menu item "添加速绘" of menu "从iPhone导入" of menu item "从iPhone导入" of menu "文件" of menu bar item "文件" of menu bar 1 of application process "Messages" of application "System Events", menu item 5 of menu "从iPhone导入" of menu item "从iPhone导入" of menu "文件" of menu bar item "文件" of menu bar 1 of application process "Messages" of application "System Events", menu item 11 of menu "文件" of menu bar item "文件" of menu bar 1 of application process "Messages" of application "System Events", menu item "打印…" of menu "文件" of menu bar item "文件" of menu bar 1 of application process "Messages" of application "System Events"}
找到目标的path :menu item “删除对话…” of menu “文件” of menu bar item “文件” of menu bar 1
click 它,弹出删除确认框
弹出删除确认框
如果不熟悉Mac端的开发控件,可通过Accessibility Inspector,点击右上角聚焦,选中控件,查看控件信息
弹出框为sheet类型,在新window中
tell application "Messages" to activate
tell application "System Events"
tell process "Messages"
click UI element 4 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 of window 1
delay 0.2
click menu item "删除对话…" of menu 1 of menu bar item "文件" of menu bar 1
delay 0.2
tell sheet 1 of window 1
entire contents
end tell
end tell
end tell
复制代码
打印
{image 1 of sheet 1 of window "1068177100319040" of application process "Messages" of application "System Events", static text "您要删除此对话吗?" of sheet 1 of window "1068177100319040" of application process "Messages" of application "System Events", static text "此对话将从您的所有设备上删除。您不能撤销此操作。" of sheet 1 of window "1068177100319040" of application process "Messages" of application "System Events", button "删除" of sheet 1 of window "1068177100319040" of application process "Messages" of application "System Events", button "取消" of sheet 1 of window "1068177100319040" of application process "Messages" of application "System Events"}
找目标item的path :button "删除" of sheet 1
tell application "Messages" to activate
tell application "System Events"
tell process "Messages"
click UI element 4 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 of window 1
delay 0.2
click menu item "删除对话…" of menu 1 of menu bar item "文件" of menu bar 1
delay 0.2
click button "删除" of sheet 1 of window 1
end tell
end tell
复制代码
重复,删除全部
tell application "Messages" to activate
tell application "System Events"
tell process "Messages"
repeat 2 times
click UI element 4 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 of window 1
delay 0.2
click menu item "删除对话…" of menu 1 of menu bar item "文件" of menu bar 1
delay 0.2
click button "删除" of sheet 1 of window 1
delay 0.5
end repeat
end tell
end tell
最后
如果你觉得此文对你有一丁点帮助,点个赞。或者可以加入我的开发交流群:1025263163相互学习,我们会有专业的技术答疑解惑
推荐阅读
-
安卓编程 删除短信 批量删除短信应用程序
-
iCloud 切换区域,中国区保留 appStore(更新)--自 2018 年 2 月 28 日起,中国区 iCloud 由云上贵州管理 苹果公司发布的公告 https://support.apple.com/zh-cn/HT208352 关键词 关键部分 受影响的 iCloud 账户:国家或地区设置为 "中国 "的 Apple ID。 iCloud 包含的服务照片、邮件、通讯录、日历、提醒事项、备忘、书签、钱包、钥匙串、云备份、云驱动器、应用程序数据 新条款和条件: 同意仅出于本协议允许的目的并在中国法律允许的范围内使用服务。 云桂洲在提供服务时应使用合理的技能并尽职尽责,但在适用法律允许的最大范围内,我们不保证或担保您通过本服务存储或访问的任何内容不会意外损坏、崩溃、丢失或根据本协议的条款被删除,如果发生此类损坏、崩溃、丢失或删除,我们不承担任何责任。您应自行负责维护您的信息和数据的适当备份。 Apple 和云上贵州有权访问您存储在服务中的所有数据,包括有权根据适用法律相互之间共享、交换和披露所有用户数据(包括内容)。 本协议的解释、效力和履行应适用*法律。对于因本协议引起的或与本协议有关的任何争议,云桂洲和您同意提交中国国际经济贸易仲裁委员会(CIETAC)根据提交仲裁时有效的法律在北京进行具有约束力的仲裁。 由云桂洲管理,用户选择: 停用; ID 到地区; 受 iCloud(由云桂洲运营)条款和条件约束 首先,我想说说我对数据安全的看法。 当我在朋友圈发布通知时,有些朋友回复说国外的操作并没有多安全,或者国外的安全只是相对于国外而言的等等。首先,我非常感谢这些朋友,这让我反思什么是数据安全。以下观点均属个人观点: 国外的月亮一定比国内圆? 这是一个根深蒂固的问题,只要有人说国外的东西比国内好,就会有人嘲笑崇洋媚外。我觉得我们在某些方面应该向国外学习,比如搜索引擎和版权问题。打开百度搜索 "数据安全",第一行肯定是广告。打开谷歌搜索 "数据安全",第一条就是 "数据安全_百度百科" .....各种版权问题大家都明白,支持正版,但不仅客户一心想找免费破解,就连作者也往往没有保护自己劳动成果或产品的想法。但从另一个层面来说,国内的发展和安全,甩国外几条街。没有说哪里好,哪里不好,辩证地去学习更好。 国外也有别有用心的数据泄露,谈何安全? 从加密解密的角度看,自古以来就没有绝对安全的加密,只有相对安全的做法。苹果的棱镜门、微软的 cpu 漏洞,各种参差不齐的被破解案例 ....是的,这的确是一个很好的论据,但凡事都不能只看一面,当年苹果面对FBI破解手机的要求,几经论证,苹果还是拒绝破解。这点拿到国内,只要上面的文件传达下去,还有企业敢说不吗?还敢说不吗? 关于这次iCloud数据迁移个人看法? 把数据迁移到贵州的云端,相当于把手机的所有数据都存储在贵州的云端服务器上。也许访问数据的速度会快很多,但我会把我的iCloud区放到美国,因为我不想数据存在云上贵州后经常接到莫名其妙的电话或短信,更不想因为乱用国外服务器而被请去喝茶。iCloud一个ID,即从中国账号转到美国区,主要用于数据存在美国服务器上。appStore一个ID,除了注册一个中国ID外,专门用来下载应用用,因为国外ID不支持酷狗和网易云等应用。麻烦的是,用了新的 appStore ID 后,当前的应用还得重新下载安装,因为旧的应用 ID 与新的应用 ID 不兼容,安装不了。最后,iCloud迁移后,国内用户使用美国服务器,估计要 "扶墙 "了。 专业步骤: 首先,进行appleID设置,这是前提条件,否则无法选择转移区域! 取消 appleID 的双重认证 取消家庭共享选项 二、窗口下载并安装 icloud 3.0 版
-
windows下进程间通信的(13种方法)-摘 要 本文讨论了进程间通信与应用程序间通信的含义及相应的实现技术,并对这些技术的原理、特性等进行了深入的分析和比较。 ---- 关键词 信号 管道 消息队列 共享存储段 信号灯 远程过程调用 Socket套接字 MQSeries 1 引言 ---- 进程间通信的主要目的是实现同一计算机系统内部的相互协作的进程之间的数据共享与信息交换,由于这些进程处于同一软件和硬件环境下,利用操作系统提供的的编程接口,用户可以方便地在程序中实现这种通信;应用程序间通信的主要目的是实现不同计算机系统中的相互协作的应用程序之间的数据共享与信息交换,由于应用程序分别运行在不同计算机系统中,它们之间要通过网络之间的协议才能实现数据共享与信息交换。进程间通信和应用程序间通信及相应的实现技术有许多相同之处,也各有自己的特色。即使是同一类型的通信也有多种的实现方法,以适应不同情况的需要。 ---- 为了充分认识和掌握这两种通信及相应的实现技术,本文将就以下几个方面对这两种通信进行深入的讨论:问题的由来、解决问题的策略和方法、每种方法的工作原理和实现、每种实现方法的特点和适用的范围等。 2 进程间的通信及其实现技术 ---- 用户提交给计算机的任务最终都是通过一个个的进程来完成的。在一组并发进程中的任何两个进程之间,如果都不存在公共变量,则称该组进程为不相交的。在不相交的进程组中,每个进程都独立于其它进程,它的运行环境与顺序程序一样,而且它的运行环境也不为别的进程所改变。运行的结果是确定的,不会发生与时间相关的错误。 ---- 但是,在实际中,并发进程的各个进程之间并不是完全互相独立的,它们之间往往存在着相互制约的关系。进程之间的相互制约关系表现为两种方式: ---- (1) 间接相互制约:共享CPU ---- (2) 直接相互制约:竞争和协作 ---- 竞争——进程对共享资源的竞争。为保证进程互斥地访问共享资源,各进程必须互斥地进入各自的临界段。 ---- 协作——进程之间交换数据。为完成一个共同任务而同时运行的一组进程称为同组进程,它们之间必须交换数据,以达到协作完成任务的目的,交换数据可以通知对方可以做某事或者委托对方做某事。 ---- 共享CPU问题由操作系统的进程调度来实现,进程间的竞争和协作由进程间的通信来完成。进程间的通信一般由操作系统提供编程接口,由程序员在程序中实现。UNIX在这个方面可以说最具特色,它提供了一整套进程间的数据共享与信息交换的处理方法——进程通信机制(IPC)。因此,我们就以UNIX为例来分析进程间通信的各种实现技术。 ---- 在UNIX中,文件(File)、信号(Signal)、无名管道(Unnamed Pipes)、有名管道(FIFOs)是传统IPC功能;新的IPC功能包括消息队列(Message queues)、共享存储段(Shared memory segment)和信号灯(Semapores)。 ---- (1) 信号 ---- 信号机制是UNIX为进程中断处理而设置的。它只是一组预定义的值,因此不能用于信息交换,仅用于进程中断控制。例如在发生浮点错、非法内存访问、执行无效指令、某些按键(如ctrl-c、del等)等都会产生一个信号,操作系统就会调用有关的系统调用或用户定义的处理过程来处理。 ---- 信号处理的系统调用是signal,调用形式是: ---- signal(signalno,action) ---- 其中,signalno是规定信号编号的值,action指明当特定的信号发生时所执行的动作。 ---- (2) 无名管道和有名管道 ---- 无名管道实际上是内存中的一个临时存储区,它由系统安全控制,并且独立于创建它的进程的内存区。管道对数据采用先进先出方式管理,并严格按顺序操作,例如不能对管道进行搜索,管道中的信息只能读一次。 ---- 无名管道只能用于两个相互协作的进程之间的通信,并且访问无名管道的进程必须有共同的祖先。 ---- 系统提供了许多标准管道库函数,如: pipe——打开一个可以读写的管道; close——关闭相应的管道; read——从管道中读取字符; write——向管道中写入字符; ---- 有名管道的操作和无名管道类似,不同的地方在于使用有名管道的进程不需要具有共同的祖先,其它进程,只要知道该管道的名字,就可以访问它。管道非常适合进程之间快速交换信息。 ---- (3) 消息队列(MQ) ---- 消息队列是内存中独立于生成它的进程的一段存储区,一旦创建消息队列,任何进程,只要具有正确的的访问权限,都可以访问消息队列,消息队列非常适合于在进程间交换短信息。 ---- 消息队列的每条消息由类型编号来分类,这样接收进程可以选择读取特定的消息类型——这一点与管道不同。消息队列在创建后将一直存在,直到使用msgctl系统调用或iqcrm -q命令删除它为止。 ---- 系统提供了许多有关创建、使用和管理消息队列的系统调用,如: ---- int msgget(key,flag)——创建一个具有flag权限的MQ及其相应的结构,并返回一个唯一的正整数msqid(MQ的标识符); ---- int msgsnd(msqid,msgp,msgsz,msgtyp,flag)——向队列中发送信息; ---- int msgrcv(msqid,cmd,buf)——从队列中接收信息; ---- int msgctl(msqid,cmd,buf)——对MQ的控制操作; ---- (4) 共享存储段(SM) ---- 共享存储段是主存的一部分,它由一个或多个独立的进程共享。各进程的数据段与共享存储段相关联,对每个进程来说,共享存储段有不同的虚拟地址。系统提供的有关SM的系统调用有: ---- int shmget(key,size,flag)——创建大小为size的SM段,其相应的数据结构名为key,并返回共享内存区的标识符shmid; ---- char shmat(shmid,address,flag)——将当前进程数据段的地址赋给shmget所返回的名为shmid的SM段; ---- int shmdr(address)——从进程地址空间删除SM段; ---- int shmctl (shmid,cmd,buf)——对SM的控制操作; ---- SM的大小只受主存限制,SM段的访问及进程间的信息交换可以通过同步读写来完成。同步通常由信号灯来实现。SM非常适合进程之间大量数据的共享。 ---- (5) 信号灯 ---- 在UNIX中,信号灯是一组进程共享的数据结构,当几个进程竞争同一资源时(文件、共享内存或消息队列等),它们的操作便由信号灯来同步,以防止互相干扰。 ---- 信号灯保证了某一时刻只有一个进程访问某一临界资源,所有请求该资源的其它进程都将被挂起,一旦该资源得到释放,系统才允许其它进程访问该资源。信号灯通常配对使用,以便实现资源的加锁和解锁。 ---- 进程间通信的实现技术的特点是:操作系统提供实现机制和编程接口,由用户在程序中实现,保证进程间可以进行快速的信息交换和大量数据的共享。但是,上述方式主要适合在同一台计算机系统内部的进程之间的通信。 3 应用程序间的通信及其实现技术 ---- 同进程之间的相互制约一样,不同的应用程序之间也存在竞争和协作的关系。UNIX操作系统也提供一些可用于应用程序之间实现数据共享与信息交换的编程接口,程序员可以通过自己编程来实现。如远程过程调用和基于TCP/IP协议的套接字(Socket)编程。但是,相对普通程序员来说,它们涉及的技术比较深,编程也比较复杂,实现起来困难较大。 ---- 于是,一种新的技术应运而生——通过将有关通信的细节完全掩盖在某个独立软件内部,即底层的通讯工作和相应的维护管理工作由该软件内部来实现,用户只需要将通信任务提交给该软件去完成,而不必理会它的具体工作过程——这就是所谓的中间件技术。 ---- 我们在这里分别讨论这三种常用的应用程序间通信的实现技术——远程过程调用、会话编程技术和MQSeries消息队列技术。其中远程过程调用和会话编程属于比较低级的方式,程序员参与的程度较深,而MQSeries消息队列则属于比较高级的方式,即中间件方式,程序员参与的程度较浅。 ---- 4.1 远程过程调用(RPC)