applescript

AppleScript -> Activate window of a non-scriptable application

不打扰是莪最后的温柔 提交于 2019-12-12 09:04:30
问题 I have opened 2 "Finder" window A & B, A is in the front while B underneath, the following snippet brings B to the front the topmost: tell application "Finder" activate activate window 2 end tell But for applications that do not support scripting, the code just mentioned won't help. Any ideas for activating a window of non-scripting application. 回答1: You can usually turn to system events in these cases. System events knows about the windows of running processes and you can usually manipulate

OSX assign left mouse click to a keyboard key

二次信任 提交于 2019-12-12 08:58:16
问题 I would like to be able to assign a key on my keyboard to be equivalent to a left mouse click. Ideally it needs to act such that holding the key down is also equivalent to holding the left mouse button down. I'd like this capability as a user, additionally a programmatic solution (cocoa/applescript etc) would be great too. 回答1: Not exactly what you want, but in the System preferences -> Universal access you can turn on mouse keys - and with them you can move (and click) mouse by keyboard.

How can I execute a simple Applescript from a C++ program?

↘锁芯ラ 提交于 2019-12-12 08:14:07
问题 I would like to execute the Applescript command tell application "Finder" to open POSIX file */path/to/somefilename* from a C++ program. It looks like I might want to use OSACompileExecute , but I haven't been able to find an example of how to use it. I keep finding examples of how to use the OSACompile Terminal command. Can someone provide an example or a link to an example? 回答1: Ok, the trick was to not bother trying to compile and execute the Applescript but to simply use the osascript

Set focus to specific window of an application using applescript

我是研究僧i 提交于 2019-12-12 08:02:59
问题 How can I set focus to a specific window of a given application using applescript? I have several iTerm2 windows running on different displays. I want to set focus to a specified window using applescript. I need two things, one script that collects the window ID's and prints them to stdout. I've got this: tell application "iTerm" set wins to id of every window end tell which prints 6 integers: 3034, 2528, -1, -1, -1, -1 Bonus Question: What are the four -1's ? Then I try: tell application

AppleScript for changing prefix and automatically upload to ftp when file is copied to folder

北战南征 提交于 2019-12-12 06:32:46
问题 I am programing an AppleScript that allows me to automatically put a prefix to a file and upload it to an ftp-server when it is copied to a specific folder (used as a folder action under OS X El Capitan). What I get to work is that the file is automatically uploaded, but when I try to implement that it should add a prefix (specifically a unix timestamp), it won't change either the filename nor uploading it to the ftp-directory. Here is my code as it is now: property uploadftp : "ftp://user

Remove cell borders

蓝咒 提交于 2019-12-12 05:58:15
问题 I'm having trouble using Applescript to remove cell borders in a table of data. I'm starting out with a spreadsheet that contains data in C15:K31. Each of these cells has a border around it. All I want to do is insert a column at index 4 (column D) and then set each of the cells in column D to not have any borders. I included a repeat to look at every cell in column D, but ideally I would simply remove the formatting all at once, without the repeat. Any thoughts? My code is below: tell

Why won't this Scripting Addition run from a Mail rule?

本秂侑毒 提交于 2019-12-12 05:42:20
问题 When I access the satimage.osax scripting addition (which I'm using for its regex capability) from a Mail rule on Snow Leopard, I get errors, but it runs fine in Script Editor. The code below illustrates the problem. The first line executes fine, but the line inside the tell block throws an error (below), from the mail rule version, which I had catching the error. set substr to find text "a" in "abcd" tell application "Mail" set substr to find text "a" in "abcd" end tell So I tried a

Blocking call while opening a file in python on osx

可紊 提交于 2019-12-12 05:39:39
问题 I am using python 2.7 on osx 10.9 I want to open a file in their default file opener like TextEdit for .txt file, pdf opener for .pdf file etc. As file is opened, it should block i.e. I want to open a file and wait the execution of next instruction till file is not closed. I read https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/open.1.html and How to open a file in subprocess on mac osx and used subprocess.call(["open","-W", FileName]) .But in this case,

how to repeat or loop an applescript

扶醉桌前 提交于 2019-12-12 04:48:57
问题 I was looking for an option to color all unread mails in apple mail and I found the following script tell application "Mail" set background color of (messages of inbox whose read status is false) to red --unread set background color of (messages of inbox whose read status is true) to none --default read end tell I added this script to a mail rule, which applies to every message, then it works almost perfect. The only problem is that it works only for one time. So if I get a new message, than

AppleScript to open URL in Safari crashes for Flash-based websites

跟風遠走 提交于 2019-12-12 04:26:05
问题 I'm trying to open a URL in Safari. It works fine for websites without Flash embedded, but crashes Safari for Flash sites. Example (this WORKS): tell application "Safari" to open location "http://google.com" This CRASHES when Safari is not already running: tell application "Safari" to open location "http://grooveshark.com" Two things I noticed: Safari only crashes for websites with embedded Flash The script above only crashes if a new instance of Safari is created (i.e. Safari was not running