applescript

Applescript - move files to folder which name begins with first 7 characters of filename

跟風遠走 提交于 2019-12-12 04:06:20
问题 I've got 2 folders the first folder contains all the files which I'd like to move to a subfolder of the second folder. I'd like to this based on the first 7 characters of both the file & folder names. So if the first 7 characters of the subfolder in FOLDER 2 matches the first 7 characters of the file in FOLDER 1. The file get's moved into the subfolder of FOLDER 2 Right now I've got an Applescript which works, but it's terribly slow. Here's the script so far: set mgFileList to "" set

How do I change an NSImageView object to its alternate image in Objective C applescript?

拈花ヽ惹草 提交于 2019-12-12 03:47:03
问题 Using Xcode I am trying to change an image object to another image. I am using ObjC Applescript. I have an IB Outlet testImage : missing value and using tell testImage to setImage("sample.png") to change the image. 回答1: The following code should do the trick: set image to current application's NSImage's imageNamed_("sample.png") testImage's setImage_(image) 来源: https://stackoverflow.com/questions/42965369/how-do-i-change-an-nsimageview-object-to-its-alternate-image-in-objective-c-appl

How to turn an AppleScript path into a posix path and pass to shell script?

孤街醉人 提交于 2019-12-12 03:44:00
问题 I´m trying to create a textfile that my ffmpeg-command can use to merge two videofiles. The problem I´m having is getting my folder/file-paths to look like I want. The two lines that cause my problems are: set theFile to path to replay_folder & "ls.txt" I simply want this path to be the path of replay_folder and ls.txt In the shell script line I want the same thing. do shell script "cd " & replay_folder & " /usr/local/bin/ffmpeg -f concat -i ls.txt -c copy merged.mov" I get this path with the

AppleScript return on random float

限于喜欢 提交于 2019-12-12 03:43:15
问题 I'm trying to create code in AppleScript that will click my mouse randomly every 1-2 seconds... I want a video game I'm playing to not know or be able to tell that a robot is clicking for me so I need it to be RANDOM... not every second or every 2 seconds but every x seconds where x is a constantly changing variable in-between 1 and 2 seconds... Here is the code so far but it clicks every 1 second: on idle tell application "System Events" key code 87 end tell return 1 end idle I thought

escape shell arguments in AppleScript?

风流意气都作罢 提交于 2019-12-12 03:29:35
问题 I have the following command line works well in terminal rename 's/\d+/sprintf("%04d",$&)/e' ~/Downloads/test/*.pdf but I couldn't escape quotes (have single quote and backslash in the script) in applescript, this is what I tried, applescript didn't give me error but I didn't get my files renamed. set renamer_command to "'s/\\d+/sprintf(\"%04d\",$&)/e'" do shell script "/opt/local/bin/rename " & quoted form of renamer_command & " ~/Downloads/test/*.pdf" This is the output I get from

Applescript confirm sudo password in ssh connection

拜拜、爱过 提交于 2019-12-12 03:23:58
问题 I´m opening a ssh connection to an Ubuntu Box with applescript. How can I provide the sudoer password asked by apt: tell application "Terminal" set currentTab to do script ("ssh -p" & pnumber & " " & user & "@localhost;") delay 2 do script ("sudo apt-get update") in currentTab -- start provide here password for sudo -- this ends in keystroke cannot be read keystroke "password" keystroke return -- end provide password do script ("exit;") in currentTab end tell 回答1: try set resultText to (do

Closing QuickTime by Applescript

♀尐吖头ヾ 提交于 2019-12-12 03:12:37
问题 I am trying to play a movie fullscreen one time, then close the player programmably. I have tried using QTMovieView, command line and AppleScript and found the Applescript is the most simple way. BUT, as I really don't know Applescript, I can not make the QuickTime auto close after movie playing. Everything works fine but the "done" was unrecognized in the repeat line. Here is the script with this error: error "QuickTime Player got an error: Can't make done of document 1 into type specifier."

“Expose” effect in a Mac application

淺唱寂寞╮ 提交于 2019-12-12 03:05:01
问题 Is there any way or function that can be used to obtain the expose effect in Mac, when a button is clicked? I tried searching, but I had no luck, so far. 回答1: There is no API for this. AFAIK the only way to do it is to use NSWorkspace to launch either the Exposé app (Mac OS X versions < 10.7) or the Mission Control app (Mac OS X versions >= 10.7). This code uses the com.apple.exposelauncher bundle ID which is the same for all versions of Mac OS X that ship with Exposé: [[NSWorkspace

Code sign bundled app made with osacompile

喜欢而已 提交于 2019-12-12 02:58:21
问题 Programmatically I trying to achieve this on Mac OS X: a file on desktop that when clicked will launch Firefox with a certain profile. I do this with AppleScript and bash. Manual steps Open the Script Editor Write some AppleScript ( do shell script "/Applications/Firefox.app/Contents/MacOS/firefox -ProfileManager &> /dev/null &" ) Save your new AppleScript > Save As > Application Bundle Set icon This works perfectly fine manually it follows this tutorial: Asa Dotzler Blog Firefox Shortcut