AppleScript的:隐藏/从应用程序获取进程名 [英] AppleScript: Hide/Get process name from app

查看:886
本文介绍了AppleScript的:隐藏/从应用程序获取进程名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想隐藏最前面的应用程序。
我知道你可以使用语法隐藏的过程:

 告诉应用程序系统事件
    设置过程中可见...为假
告诉结束

和我知道如何让最前面的应用程序:

 (路径最前面的应用程序的字符串)

但我怎么了两个命令弥合在一起吗?

这是行不通的:

 告诉应用程序系统事件
    设置过程中可见(路径最前面的应用程序作为字符串)为false
告诉结束


解决方案

试试这个。

 告诉应用程序系统事件
    设置frontProcess首先进程,其最前面的是真实的
    frontProcess的设置可见为false
告诉结束

您必须要小心,因为当你运行脚本某些方面来说,剧本是最前面的,所以你可能只是结束了隐藏脚本,而不是你的目标应用。我检查最前面的进程的名称,如果该脚本或AppleScript运行,那么你需要隐藏的名称相匹配,然后再次运行该命令,你实际上会得到你的目标应用。这是棘手。

I want to hide the frontmost app. I know you can hide a process using the syntax:

tell application "System Events"
    set visible of process "..." to false
end tell

and i know how to get the frontmost app:

(path to frontmost application as string)

But how do I bridge the two commands together?

This will not work:

tell application "System Events"
    set visible of process (path to frontmost application as string) to false
end tell

解决方案

Try this.

tell application "System Events"
    set frontProcess to first process whose frontmost is true
    set visible of frontProcess to false
end tell

You have to be careful because in some ways when you run the script, the script is frontmost so you may just end up hiding the script instead of the application you were targeting. I check the name of the frontmost process, and if that matches the name of the script or "applescript runner" then you need to hide that, then run the command again and you'll actually get the application you were targeting. It's tricky.

这篇关于AppleScript的:隐藏/从应用程序获取进程名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆