本文介绍了如何在OS X上将进程窗口置于前台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的shell/python脚本,可以打开其他窗口.我想在脚本执行完毕后将运行脚本的终端放到前台.

I have a simple shell/python script that opens up other windows. I'd like to bring the terminal where the script is running to the foreground when the script has finished.

我知道我的父窗口的进程ID. 如何将给定的窗口置于前台?我想我必须一路从PID中找出窗口名称.

I know the process ID of my parent window. How can I bring a given window to the foreground? I imagine I have to find out the window name from the PID along the way.

推荐答案

不确定是否有正确的方法,但这对我有用:

Not sure if there's a proper way, but this works for me:

osascript<<EOF
tell application "System Events"
    set processList to every process whose unix id is 350
    repeat with proc in processList
        set the frontmost of proc to true
    end repeat
end tell
EOF

您也可以使用osacript -e '...'来做到这一点.

You can do it with osacript -e '...' too.

显然将350更改为所需的pid.

Obviously change the 350 to the pid you want.

这篇关于如何在OS X上将进程窗口置于前台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 12:02