如何使用Automator将窗口置于最前面? [英] How to use Automator to bring window to front?

查看:154
本文介绍了如何使用Automator将窗口置于最前面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Mac,OSX 10.6,并且在桌面应用程序中有一个要自动执行的功能.手动按Command + R等待应用程序从物理设备读取某些数据1分钟,然后再次按Command + R进行另一次读取(此时,它询问我是否要保存数据,因此按选项卡,选项卡,然后再按空格键选择要保存数据.我总共执行了3次,因此我想使这3次自动化,因此我可以离开计算机,它将自动读取3次.

自动器是执行此操作的最佳方法吗?

我已经尝试通过使用看我做"功能在自动化器中执行此操作.首先从无标题的窗口"开始,然后第二个命令是按Command + R.然后,我发现了一小段苹果脚本等待一分钟,然后将第一个动作插入了等待功能.

但是,当我单击运行或步进时,没有移动并打开正确的窗口(无标题"),而是将光标移到了automator中的媒体"按钮上,而是单击了它!但是该应用程序肯定被列为正确的应用程序.

任何帮助表示赞赏,但也许自动化是错误的方法?

解决方案

Apple Script是执行不需要任何特殊处理"的事情的最佳方法,这些处理不需要由一系列不同的应用程序来完成.

1)使用AppleScript实用程序 确保在"AppleScript实用程序"中启用了GUI脚本 2)使用脚本编辑器选择文件">打开库",然后查看您的应用程序是否具有任何可编写脚本的功能……这些可能是更好的方法.

3)创建一个新脚本并放入类似这样的内容...

tell application "Firefox"
    activate
    delay 1 -- give it time to react

    repeat 3 times
        -- this gives us the keyboard
        tell application "System Events" 
            keystroke "r" using {command down}
        end tell
        delay 6
    end repeat
end tell

我使用Firefox进行了测试....应该可以为您工作....

一旦有了脚本,就可以使用另存为将其保存到应用程序中,或者将其另存为脚本到〜/Library/Scripts文件夹中,或者将其粘贴到自动化工作流程中并通过iCal进行调度./p>

I'm using a Mac, OSX 10.6 and I have a function in a desktop application that I want to automate. Manually I press Command+R wait for the application to read some data form a physical device for 1 minute, then press command+R again to take another reading (at this point it asks me if I want to save the data, so I press tab, tab and then space bar to select to save the data. I do this 3 times in total, so I want to automate the 3 times, so I can walk away from the computer and it will read 3 times automatically.

Is automator the best way to do this?

I've tried to do this already in automator by using the 'watch me do' function. This starts with the 'bring window Untitled to the front', and then the second command is press command+R. I then found a little piece of apple script to wait 1 minute and I plug the first action into that for the wait function.

However, when I click run or step, instead of going and opening up the correct window ("Untitled"), the cursor moves to the Media button in automator, and clicks that instead! But the application is definitely listed as the correct one.

Any help appreciated, but maybe automator is the wrong way to go?

解决方案

Apple Script is the best way to go for things that don't require any "special processing" that would need to be done by a chain of different applications.

1) uging the AppleScript Utility make sure that you have GUI scripting enabled in the "AppleScript Utility" 2) using the Script Editor choose File>Open Library and see if your application has any scriptable functions ... these may be a better way to go.

3) Create a new script and put in something like this ...

tell application "Firefox"
    activate
    delay 1 -- give it time to react

    repeat 3 times
        -- this gives us the keyboard
        tell application "System Events" 
            keystroke "r" using {command down}
        end tell
        delay 6
    end repeat
end tell

I used Firefox to test it .... should work for you ....

Once you've got the script you can use the save as to make it into an app or save it as a script in your ~/Library/Scripts folder or paste it into an automator workflow and schedule it with iCal.

这篇关于如何使用Automator将窗口置于最前面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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