applescript

'Click at' returns “System events got an error…” -Applescript

不羁的心 提交于 2019-12-10 22:41:02
问题 Newbie to applescript, sorry if its dumb. I have been trying to write a script to check if the network is healthy, if not go to a url and click Login button on the webpage (actually the page has 'username' and 'password' which my browser autofills). i used the following code; try set thePing to do shell script "/sbin/ping -o -c 1 www.google.com" on error tell application "Google Chrome" to open location "https://mwcp-ekm-04.adlkerala.com:8001" delay 5 tell application "System Events" tell

How to create and manage macOS Safari bookmarks programmatically?

最后都变了- 提交于 2019-12-10 21:43:45
问题 I'm making a script, which updates bookmarks on my macOS Safari to always have all of my subscribed subreddits as individual bookmarks in a specific folder. I've gotten to a point where I have all the subreddits as a sorted list of tuples in Python, with the wanted bookmark name as the first element and the bookmark url as the second element: bookmarks = [ ('r/Android', 'https://www.reddit.com/r/Android/'), ('r/Apple', 'https://www.reddit.com/r/Apple/'), ('r/Mac', 'https://www.reddit.com/r

Cocoa/Objective-C get a HFS path (path:to:desktop) from a posix path (path/to/desktop)

本秂侑毒 提交于 2019-12-10 21:14:02
问题 I am on OSX, Objective-C. I have a path/NSURL like /Users/xxx/Desktop/image2.png But i pass it to a third party application that excpects finder pathes like Harddisk:Users:Desktop:image2.png Is there any method (i can't find) to convert pathes like that or get them out of an NSURL (if possible without string modifying)? In AppleScript it is return POSIX file "/Users/xxx/Desktop/image2.png" --> Harddisk:Users:xxx:Desktop:image2.png EDIT : This is pretty much the same: Cocoa path string

Programmatically select text range in TextEdit

最后都变了- 提交于 2019-12-10 19:56:00
问题 Is it possible to select (Highlight) a range of text in TextEdit (by AppleScript,Cocoa or Carbon)? I tryed this code but not work: set value of attribute "AXSelectedTextRange" to {selStart, selLen} It seems this attribute is readonly. Thanks. 回答1: Not sure how to do it with AppleScript (should be possible though), with the accessibility APIs, you could do something like this: AXUIElementRef systemWideElement = AXUIElementCreateSystemWide(); AXUIElementRef focussedElement = NULL; AXError error

Launch multiple process of an app on mac osx

六月ゝ 毕业季﹏ 提交于 2019-12-10 19:47:44
问题 I am using python 2.7 on mac osx 10.9 for creating an app. This app takes file name as argument, and then opens the file, and keep monitoring the file for changes till file is closed. It is working fine for a single file. I used, py2app and platypus for converting python code .py file to an app. Limitation of it is, once an instance(process) of an app is started(by clicking on any file to open), file opens. But, simultaneously, I am not able to open two files at a time i.e. to launch to

Applescript, POSIX filenames and Mountain Lion

こ雲淡風輕ζ 提交于 2019-12-10 18:40:00
问题 While I was using Snow Leopard, I've used many times the following pattern when creating my Applescripts: on run args set filePath to POSIX file (item 1 of args) as alias ... end run After upgrading to Mountain Lion, the above script seems to produce a warning, though: 2012-08-10 15:12:12.305 osascript[54131:303] CFURLGetFSRef was passed this URL which has no scheme (the URL may not work with other CFURL routines): path/to/input/file.ext Could anyone enlighten on the meaning of the error? 回答1

Applescript folder actions support for changed / altered / updated files?

為{幸葍}努か 提交于 2019-12-10 17:48:32
问题 Does the folder action for when a folder item is changed not exist? I want my script to run when and if I update a file. I don't see any reference to it in the documentation. Is there some sort of alternative I am missing because this seams pretty crazy to not have. on adding folder items to this_folder after receiving added_files do shell script "anything" end adding folder items to on removing folder items from this_folder after losing removed_files do shell script "anything" end removing

Add file breakpoint in Xcode 4 via Applescript

ぃ、小莉子 提交于 2019-12-10 17:18:16
问题 I'm trying to add a breakpoint to the selected .m file in my current XCode project using AppleScript. Right now I'm stuck since AppleScript keeps returning 'missing value' when trying to add a file breakpoint. My current AppleScript looks like this (where PROJECTNAME obviously is the name of my current project) : tell application "Xcode" -- Get the name of the selected document set selectedFile to text document 1 whose name ends with (word -1 of (get name of window 1)) set nameOfSelectedFile

Applescript application hangs on 10.9 when executing a shell command with administrator privileges

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 17:18:11
问题 I'm executing the following line in an Applescript application. set POSIX_path to "/Applications/iPhoto.app" do shell script "sudo rm -rfv " & quoted form of POSIX_path with administrator privileges The authentification screen pops up as it should but after authenticating the application just freezes upon executing this command. This problems only occurs in 10.9. When I set the permissions of the folder to be delete to "everyone can read & write" it works. Does anyone have a clue what has

Non-blocking Dialog box in Applescript

依然范特西╮ 提交于 2019-12-10 16:38:47
问题 I have to write a small script to deploy a patch for our Application. The patch will replace a couple of files in the application.I decided to depploy the patch using Applescript. The files to be copied are quite large and it takes some time for the files to be copied. I wanted to know if there is any way I can get a dialog box which doesn't block the execution of the script so that I can display some message like Updating.. etc while the patch is applied and then close the dialog box after