applescript

How to open multiple random files with applescript?

别等时光非礼了梦想. 提交于 2019-12-11 10:28:14
问题 I am successfully opening 1 random file, like this: tell application "Finder" open some file of folder "HD:random" end tell I would like to open 3 random files in the folder. 3 different ones. If I run the applescript 3 times I will get the same ones sometimes. Thanks! 回答1: Here's 1 way using "some file"... set theNumber to 3 set theFolder to choose folder set theFiles to {} repeat tell application "Finder" to set aFile to (some file of theFolder) as text if aFile is not in theFiles then set

Change laptop Mac OS X wallpaper upon location [closed]

亡梦爱人 提交于 2019-12-11 10:17:09
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I'd like to display different wallpapers regarding the physical location where I turn on my laptop. I.e.: at home I want to see Wallpaper-A and at office I want it to be Wallpaper-B. Is there a way (an App, an AppleScript) that could detect laptop's location (i.e. wifi connection) and then update wallpaper? I

Run applescript using java on selenium webdriver(Grid) in sauce lab

限于喜欢 提交于 2019-12-11 09:56:14
问题 I am facing certification security issue[showing popup with continue] when we launch https URL on MAC safari browser using selenium remote web-driver(using selenium grid) To click "continue" button, I wrote the apple script and ran manually its working fine. Now the problem is not able to run the apple script in java. I tried with below ways:: getting java.io.IOException: Cannot run program "osascript": CreateProcess error=2, The system cannot find the file specified, error getting displayed

Running AppleScripts through the ScriptMonitor.app Utility

我是研究僧i 提交于 2019-12-11 09:52:20
问题 When AppleScripts are run through the system-wide Script Menu, their progress is displayed in the menu bar using the ScriptMonitor applet (located in /System/Library/CoreServices/ScriptMonitor.app , introduced in OS X Yosemite). This allows you to stay aware of running scripts, monitor progress, and easily stop running scripts. Is it possible to run AppleScripts through the ScriptMonitor from outside the Script Menu, for example from Terminal or from system calls from other applications? I

Programmatically Create Apple Script

梦想与她 提交于 2019-12-11 09:45:41
问题 I am using privelaged javascript which has access to python like ctypes and the whole mac api. Programmatically I'm trying to create an applescript file and set its icon. I'm trying follow this tutorial here on how to make profile shortcuts on macs: http://weblogs.mozillazine.org/asa/archives/2008/08/shortcut_to_lau.html Is this as simple as creating a text file and populating it with some text? I dont have a mac, just coding for my mac users. 回答1: You'll want to use the command line tool

Swift NSScriptCommand performDefaultImplementation

▼魔方 西西 提交于 2019-12-11 09:28:07
问题 I used this code in Objective C: @implementation KDOrderInfo - (id)performDefaultImplementation { NSString *theRequest = [self directParameter]; NSDictionary *arguments = [self evaluatedArguments]; NSLog(@"arguments = %@ %ld",arguments, [arguments count]); NSLog(@"theRequest----> %@",theRequest); /*....... .....*/ return @YES } This code works OK in Objective C. I converted this code to Swift code as follows: class OrderInfo : NSScriptCommand { override func performDefaultImplementation() ->

Applescript - Get status of windows ( Visible or in the dock )

余生长醉 提交于 2019-12-11 09:17:46
问题 I need some help for my appleScript. For all open windows, I want to know which one is hidden (in the dock), which one is visible and which one is focused? To list windows I use : tell application "System Events" set procs to processes set windowName to {} repeat with proc in procs try if exists (window 1 of proc) then repeat with w in windows of proc copy w's name to the end of windowName end repeat end if end try -- ignore errors end repeat end tell return windowName I tried focused

How to grep umlauts and other accented text characters via AppleScript

拜拜、爱过 提交于 2019-12-11 09:03:29
问题 I have a problem trying to execute shell scripts from apple script. I do a "grep", but as soon as it contains special characters it doesn't work as intended. (The script reads a list list ob subfolders in a directory and checks if any of the subfolders appear in a file.) Here is my script: set searchFile to "/tmp/output.txt" set theCommand to "/usr/local/bin/pdftotext -enc UTF-8 some.pdf" & space & searchFile do shell script theCommand tell application "Finder" set companies to get name of

Open a local html file with url params through applescript

时光怂恿深爱的人放手 提交于 2019-12-11 08:47:47
问题 I need some help with a very simple applescript. I need it to open a local URL on mac with a url parameter. set str to "open -a 'Firefox' file:///Users/bob/Desktop/someFolder/index.html?val=28" do shell script str I can't find a way to get the webpage to open with the parameters, it always just opens the .html. Can someone help? Thanks 回答1: You may want to use Safari, which is scriptable: tell application "Safari" make new document with properties {URL:"http://stackoverflow.com/questions

Objective-C Scripting Bridge and Apple Remote Desktop

落花浮王杯 提交于 2019-12-11 08:43:11
问题 Trying to automatically view a computer in Apple Remote Desktop via Scripting Bridge in Objective-C with this: @try { SBApplication *RD = [SBApplication applicationWithBundleIdentifier:@"com.apple.RemoteDesktop"]; // (code to check for ARD running and installed omitted here) [RD activate]; // works just fine RemoteDesktopComputer *computer = [[[RD classForScriptingClass:@"computer"] alloc] initWithProperties: [NSDictionary dictionaryWithObjectsAndKeys: ipAddress,@"InternetAddress", // looked