开发者

Applescript Tell Application launched by specific user

I am running two Skype on the same computer: one is launched normally and the other one is launched in Terminal under a different user acc开发者_如何学Goount B.

Then, I want to use Applescript to Tell application "Skype" (which is launched by account B) to do something. How should I specific the instance of Skype that is launched by account B in Applescript?

Many thanks!

miu


Apparently this can be done without duplicating/renaming the app if you enable remote apple events on your mac. (This is a system preference under sharing, and requires admin clearance, although you can restrict which users are allowed to send apple events, which I would recommend for security reasons).

Once that is done, you should be able to do something like:

tell application "Skype" of machine "eppc://userB@127.0.0.1"
 -- whatever
end tell

userB is of course the user name of user B, and 127.0.0.1 means 'this machine' or more correctly 'local host'.


I don't think you can. However I have thought of a work-around. Here's the idea. You can target an application several ways, one of them by its bundle identifier. For example to target TextEdit you could do this...

tell application id "com.apple.TextEdit" to activate

With that in mind, your 2 running versions of skype would need to have different bundle ids so you can target them separately. That's not the case right now but you can make that happen. Just duplicate the skype application (make a copy). Then open the package contents of the copy, open the "info.plist" file in there, find the bundle identifier key, and change it to something else. Now you have 2 versions of skype with different bundle ids which means you can target them separately.

I checked this using TextEdit. I made a duplicate copy and set its bundle id to "com.apple.myTextEdit". I opened both applications and could target them separately. So user B could use "com.apple.myTextEdit" and the normal user would use "com.apple.TextEdit"... or vice versa.

It's not an ideal solution but it would work.


I turned out to solve it by creating two copies of Skype.app and rename the new one "Skype2.app". Skpye.app is launched by user A and Skype2.app by user B (via Terminal). Then, in Applescript

tell application "Skype"
 -- do something for user A
end tell

tell application "Skype2"
 -- do something else for user B
end tell
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜