?

Log in

applescript [entries|archive|friends|userinfo]
applescript

[ website | Apple's AppleScript Home Page ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Finder renaming script? [Jun. 17th, 2011|01:36 pm]
applescript

johncoxon
Hey all.

Before I tell you the script I'm trying to use I want to give you guys an idea of what I'm trying to achieve with it. I'm an avid Minecraft player, and the game places a folder in Application Support called Minecraft. In this folder is a file: /bin/minecraft.jar. In order to mod the game, you rename the file to minecraft-original.jar, unzip and then put new files in the resulting minecraft.jar folder. In order to bring back your vanilla Minecraft installation, you rename the folder minecraft.jar to minecraft-mods.jar, and the file called minecraft-original.jar is renamed minecraft.jar.

What I am attempting to do is create an AppleScript that looks to see whether the folder minecraft-mods.jar exists, and if it does, go back to the vanilla build, but if it doesn't, go to the modded build. My proposed script is below:

tell application "Finder"
set thisFolder to "/Users/John/Dropbox/Minecraft/minecraft/bin"
if folder "minecraft-mods.jar" of thisFolder exists then
set file "minecraft.jar" of thisFolder as "minecraft-original.jar"
set folder "minecraft-mods.jar" of thisFolder as "minecraft.jar"
else
set folder "minecraft.jar" of thisFolder as "minecraft-mods.jar"
set file "minecraft-original.jar" of thisFolder as "minecraft.jar"
end if
end tell

I get the error, "Expected class name but found """." What am I doing wrong?
link19 comments

Unexpected gibberish [Jul. 15th, 2009|08:28 am]
applescript
rbygrave
Sorry, can't get screen cap or clipboard to do this at all. My keyboard won't respond to shift-command-3 or shift-command-4, also the Grab service on the services menu has its options greyed out.

What I see is an alphabet soup of alpha/num/punct characters and foreign characters (accented chars, s-zetts, ae ligatures, Greek sigma &c) along with non-alpha characters. Example 'words' include 'mrZhop', 'olzdq', 'cLip', 'ruiac', 'yko#zz' and so on, mixed in with string literals and variable names from the script and app internals for iTunes like 'pDur' or 'pStop'. I came back to one of my most-frequently-used iTunes scripts a couple of days ago and it had gone like this (luckily I had a not-quite-up-to-date backup).

I don't think it was to do with anything I did, I don't think it's a binary app, and I don't think Script Editor can make any more sense of it than I can. What has happened here, and how can I stop it happening again?

I'm on the point of believing software rot literally exists. Help!



link1 comment|post comment

Unexpected gibberish [Jul. 14th, 2009|12:15 pm]
applescript
rbygrave
An entire iTunes script seems to have turned into nonsense like this:
_
link1 comment|post comment

Unexpected gibberish... [Jul. 14th, 2009|12:05 pm]
applescript
rbygrave
Anyone seen anything like this?Collapse )
link3 comments|post comment

Applescript to modify Modifier keys. [Apr. 10th, 2009|05:51 pm]
applescript

scavgraphics
I'm trying to make an applescript to toggle the caps lock on and off in the "Modifier Keys" section of the Keyboard & Mouse control panel.

As I'm researching if this is possible, I keep running into GUI scripting.

Do you actually need to have it open dialogs and click buttons to modify system preferences? There's not just a bit of code or flag that can get easily flipped?
link5 comments|post comment

Auto Buddy Icon 1.0 [Mar. 12th, 2009|09:19 am]
applescript

kiodane
[music |On The Water - The Walkmen]

xv and I came up with an AppleScript that either captures your iSight or USB camera or your currently playing album art in iTunes and sets that as your iChat buddy icon. Most the hard work capturing the image was his. I wrote most of the error handling and program flow.

Download Auto Buddy Icon 1.0 from my iDisk public folder.

Version 1.0 requires downloading and installing the isightcapture CLI program to the ~/Library/Scripts/Applications/iChat folder. If you know a GNU GPL or FOSS method of capturing a frame from a webcam on a Mac, I'm welcome to suggestions.

If you have problems, errors, or want help, please come to me first for support.

-Mike

x-posted
linkpost comment

connect to smb volume and open each folder there [Feb. 24th, 2009|12:33 pm]
applescript

carlogulliani
 hi, i've remote volume, which connected to apple base station via usb. on mac i can see him in Shared. My remote disk has the path: "smb://Base Station._smb._tcp.local/My%20Book/", each time before launching Transmission i should choose my disk in finder and i should choose each folder there, because w/o it i can upload files in transmission (i've getting message, that transmission cannot find file, etc). I wanna write script, which will launch Finder, mount my smb's volume, open each folder there (i don't know count of folders - script must find it itself) and after close finder and open transmission. 

i begin so:

tell application "Finder"
mount volume "smb://Base Station._smb._tcp.local/My%20Book/" as user name "myusername" with password "mypassword"
-- here i should get count of my folders on disk and open each folder
end tell
close Finder
open "Transmission"
linkpost comment

User Authentication Failure [Jan. 25th, 2009|02:04 am]
applescript

xv
This is going to be a weird one, I don't really expect an answer, BUT...

I have a stay-open application bundle that randomly targets a process running in a switched-out user from the active user with remote apple events on the same machine. Still with me? It worked flawlessly on day one. On day two it's giving me this:



Here's where it gets weird: I can open the file and run it in Script Editor without incident. But if I copy the plain text to a new script application, that app gets the same authentication error. It's not a big issue, I'm sure a restart will fix it, but I guess I wish I knew more about what the hell was going on and why it would be different on two days without a recompile, and not different on the same day through recompiles. I will update this if I learn more.

update: a restart did not fix it, and now it doesn't work at all, and with new errors that prevent me from opening and compiling the code. Oh well.
linkpost comment

how can i save some string to xml file? [Jan. 9th, 2009|09:10 pm]
applescript

carlogulliani
hi, everybody, does anybody can help me?
i need to save 4 lines to xml file, i wrote the next code:

set thepath to "" & (path to desktop)

set theFile to thepath & "control.xml"

set TheText to "<?xml version='1.0' encoding='UTF-8'?>

<remote>

<command value='aaa'/>

<remote>" & return

 

open for access file theFile with write permission

set eof file theFile to 0

write TheText to file theFile starting at eof as Unicode text

close access file theFile


but it doesn't correct work for me, i receiving file like SimpleText Document and i don't working with it like xml document (after all i wanna load it in my flash app)

link3 comments|post comment

power settinmgs switch [Dec. 24th, 2008|06:40 pm]
applescript

azacs
 Here is a little program that will automatically toggle between two different plugged in power settings.  I will use this when watching videos and I don't want the screen to go to sleep.  Further info on the pmset command can be found here: http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/pmset.1.html



set curset to do shell script "pmset -g" user name "your name" password "password" with administrator privileges

set curset to paragraph 5 of curset

if curset ends with 0 then

do shell script "pmset -c displaysleep 3 disksleep 10 sleep 13 halfdim 1" user name "your name" password "your password" with administrator privileges

else

do shell script "pmset -c displaysleep 0 disksleep 0 sleep 0 halfdim 0" user name "your name" password "password" with administrator privileges

end if

linkpost comment

navigation
[ viewing | most recent entries ]
[ go | earlier ]