Mac文件处理软件Hammerspoon入门指南——与应用程序菜单交互
时间:2023-06-27 16:03:21
Hammerspoon mac这是一款macOS平台的自动化工具,可以帮助我们大大提高效率,适用于窗口管理、音乐播放、应用管理,甚至是网络请求……基本可以做到指哪打哪。应用场景:常用软件使用快捷键启动、高效快速的窗口管理、高效的音乐播放控制等。
Hammerspoon for Mac(自动化批处理软件)
立即下载
Hammerspoon mac这是一款macOS平台的自动化工具,可以帮助我们大大提高效率,适用于窗口管理、音乐播放、应用管理,甚至是网络请求……基本可以做到指哪打哪。应用场景:常用软件使用快捷键启动、高效快速的窗口管理、高效的音乐播放控制等。
2022-03-318.05 MB英文软件
与应用程序菜单交互
有时,自动化某事的唯一方法是与应用程序的GUI交互,这不是理想的,但通常需要完成某些事情。
为了说明这一点,我们将构建一个热键,在多个用户代理字符串之间循环Safari(即它如何向Web服务器标识自己)。要做到这一点,你需要有Safari浏览器Develop
启用菜单,您可以通过勾选做Show Develop menu in menu bar
在Safari→Preferences→Advanced
。
function cycle_safari_agents() hs.application.launchOrFocus("Safari") local safari = hs.appfinder.appFromName("Safari") local str_default = {"Develop", "User Agent", "Default (Automatically Chosen)"} local str_ie10 = {"Develop", "User Agent", "Internet Explorer 10.0"} local str_chrome = {"Develop", "User Agent", "Google Chrome — Windows"} local default = safari:findMenuItem(str_default) local ie10 = safari:findMenuItem(str_ie10) local chrome = safari:findMenuItem(str_chrome) if (default and default["ticked"]) then safari:selectMenuItem(str_ie10) hs.alert.show("IE10") end if (ie10 and ie10["ticked"]) then safari:selectMenuItem(str_chrome) hs.alert.show("Chrome") end if (chrome and chrome["ticked"]) then safari:selectMenuItem(str_default) hs.alert.show("Safari") endendhs.hotkey.bind({"cmd", "alt", "ctrl"}, '7', cycle_safari_agents)
我们在这里做的是首先启动Safari或将其带到前面(如果它已经运行)。这是任何菜单交互中的重要步骤 - 通常会禁用当前未关注的应用程序的菜单。
然后我们使用了对Safari本身的引用hs.appfinder.appFromName()
。使用此对象,我们可以搜索可用的菜单项并与它们进行交互。具体来说,我们正在寻找三个用户代理字符串的当前状态Develop→User Agent
。然后我们检查它们中的哪一个被勾选,然后选择下一个。
因此,反复按+++将在默认用户代理字符串,IE10用户代理和Chrome用户代理之间循环。每次,我们都会显示一个简单的屏幕警报,其中包含我们已循环访问的用户代理的名称。
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
dxgmms2.sys蓝屏怎么办?dxgmms2.sys蓝屏处理教程
![](https://img.aspxhome.com/file/2023/2/48062_0s.jpg)
怎么用钉钉新建番茄表单?钉钉新建番茄表单的方法
![](https://img.aspxhome.com/file/2023/7/a329785_0s.jpg)
安装驱动程序过程中如何禁用winxp驱动签名提示
![](https://img.aspxhome.com/file/2023/29/a254687_0s.jpg)
Office Word已停止工作的解决方案
![](https://img.aspxhome.com/file/2023/2/20352_0s.jpg)
例如在一个excel工作表中如果有很多单元格中的数据为0的数字单元格
WPS怎么设置成按笔画或拼音排序
易数一键还原怎么还原系统?易数一键还原还原系统的方法
![](https://img.aspxhome.com/file/2023/8/a335730_0s.jpg)
win7telnet开启出错怎么办_win7telnet无法开启解决方法
![](https://img.aspxhome.com/file/2023/3/a300002_0s.jpg)
MuMu模拟器怎么退出全屏?MuMu模拟器按什么退出全屏?
![](https://img.aspxhome.com/file/2023/7/a327615_0s.jpg)
Win10启动战争前线就停止工作怎么办
![](https://img.aspxhome.com/file/2023/26/a224668_0s.jpg)
word2016文档目录布局怎么更改?
![](https://img.aspxhome.com/file/2023/1/24291_0s.jpg)
如何增加Win10任务栏透明度的技巧
![](https://img.aspxhome.com/file/2023/30/a263403_0s.png)
Excel 2010在函数方面的改进
API文档和代码片段管理器:Dash
![](https://img.aspxhome.com/file/2023/1/a205651_0s.jpeg)
利用图片密码登录功能防止暴力破解Windows8系统密码
![](https://img.aspxhome.com/file/2023/29/a257686_0s.jpg)
微信中 文件传输助手 也可以置顶聊天
![](https://img.aspxhome.com/file/2023/9/a343378_0s.jpg)
word文档“保存”和“另存为”有什么区别?
![](https://img.aspxhome.com/file/2023/1/35111_0s.png)
Office 2019下载安装图解教程
![](https://img.aspxhome.com/file/2023/8/16258_0s.jpg)
万兴视频修复:如何修复损坏的MP4文件?
![](https://img.aspxhome.com/file/2023/0/a211130_0s.jpeg)
笔记本电脑漏电怎么解决?
![](https://img.aspxhome.com/file/2023/6/a322709_0s.png)