I promise this will be the last of this for a while, but it seems people want to know more and more about it. The latest task I’ve had is to control projectors over a network without using any special software. This called for scripted mouse moves and mouse clicks, which is a common Applescript request on various forums. I came up with the following, which makes use of ‘Extra Suites’ available on kanzu.com. It’s only $10 and earned it’s money with me instantly. The code:
tell application “Safari”
activate
delay 8
tell application “Extra Suites” to ES move mouse {100, 100}
delay 1
tell application “Extra Suites” to ES click mouse
delay 2
tell application “System Events” to keystroke “q” using {command down}
end tell
This code simply opens up Safari which has the projectors internal server as it’s home page. It then moves the mouse cursor over a button in the Safari window and clicks it. It then quits Safari for me. This is only a small section of the final script, but it shows you how to control the mouse cursor in Applescript.
OK, enough of the scripts, I’ll start posting cool stuff again soon.
I’ve been getting quite a few e-mails from people asking how to auto launch and full screen a SWF file on start up, instead on a Quicktime movie. Here’s my Applescript code to make it work:
tell application “Flash Player”
activate
open alias “Macintosh HD:location:to:your:file.swf”
tell application “System Events”
keystroke “f” using command down
end tell
end tell
Hello.
I don’t normally like to post code updates without a screen shot or a link to the file, but sadly my hosting ability is down for a day or two whilst I migrate it. I’ve been working with the good old FLARToolkit and FLARManager, and my research showed that quite a few people are having issues getting FLARManager to work. Why would you want to use FLARManager? It allows you to easily use standard event listener code when working with marker detection, and it allows you to work easily with more than one marker at a time. The following code will move two squares around on the stage when two markers are seen. To use it you’ll need FLARManager:
http://words.transmote.com/wp/20090718/flarmanager-v05-for-flartoolkit/
and TweenMax:
http://blog.greensock.com/tweenmaxas3/
My document class code:
package {
import com.transmote.flar.FLARManager;
import com.transmote.flar.marker.FLARMarkerEvent;
import com.transmote.utils.time.FramerateDisplay;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.ErrorEvent;
import gs.TweenMax;
public class FLAR_BCard extends Sprite {
private var flarManager:FLARManager; //create a new instance of the flarmanager
private var bSquare:blueSquare = new blueSquare(); //these are the two little squares and will be replaced by much cooler shit
private var rSquare:redSquare = new redSquare();
public function FLAR_BCard () {
this.init(); //the defacto empty constructor running the init method
}
private function init () :void {
this.flarManager = new FLARManager(“resources/flarConfig.xml”); //tell the flar manager instance where it’s config file is
this.flarManager.addEventListener(ErrorEvent.ERROR, this.onFlarManagerError); //these are flar manager events, the first is a simple error handler
this.flarManager.addEventListener(FLARMarkerEvent.MARKER_ADDED, this.onMarkerAdded); //these three are like mouse down, mouse move and mouse up
this.flarManager.addEventListener(FLARMarkerEvent.MARKER_UPDATED, this.onMarkerUpdated);
this.flarManager.addEventListener(FLARMarkerEvent.MARKER_REMOVED, this.onMarkerRemoved);
}
private function onFlarManagerError (evt:ErrorEvent) :void { //simple error handler
this.flarManager.removeEventListener(ErrorEvent.ERROR, this.onFlarManagerError);
}
private function onMarkerAdded (evt:FLARMarkerEvent) :void { //this function simply adds the squares and moves them to the location of the seen marker
addChild(bSquare);
addChild(rSquare);
TweenMax.to(this.getMarkerByPatternId(evt.marker.patternId), 1, { x:evt.marker.centerpoint.x, y:evt.marker.centerpoint.y, rotationZ:evt.marker.rotationZ *-1 } );
}
private function onMarkerUpdated (evt:FLARMarkerEvent) :void {
TweenMax.to(this.getMarkerByPatternId(evt.marker.patternId), 1, { x:evt.marker.centerpoint.x, y:evt.marker.centerpoint.y, rotationZ:evt.marker.rotationZ *-1 });
}
private function onMarkerRemoved (evt:FLARMarkerEvent) :void {
TweenMax.to(this.getMarkerByPatternId(evt.marker.patternId), 1, { x:25, y:25, rotationZ:0 });
}
private function getMarkerByPatternId (patternId:int) {
switch (patternId) {
case 0:
return bSquare;
case 1:
return rSquare;
case null:
return null;
default:
return null
}
}
}
}
You’ll need to make an .fla file with two movieclips called bSquare and rSquare. I use the markers, xml and camera data parameters file that comes with FLARManager. Nice tweened 2D control of movieclips with tracked markers.
Hello.
Following on from my previous post, I thought I’d share this also. It seems to be a common question on Applescript forums, how to quit an app without save. Here’s how to shut down TextEdit then shut down the machine, all without saving anything. Of course you can replace TextEdit with an app of your choosing:
tell application “TextEdit” —tell our application
quit without saving —to quit without saving
delay 5 —wait 5 seconds to allow for full app quit
end tell
tell application “Finder” —tell Finder
shut down —to invoke the shutdown command
end tell
Hello.
I thought I’d share this as I couldn’t find how to do this anywhere online. It’s a little Applescript which sets Quicktime to load on boot, play a file of your choice full screen and loop forever. Quite handy if you use Mac Minis as A/V players.
The code:
tell application “QuickTime Player”
activate
open alias “Macintosh HD:Users:%username%:%path to movie file.mov%”
present document 1 scale screen
set the looping of document 1 to true
end tell
Stick that in the Applescript app, edit to suit, and save it as an application with ‘Startup Screen’ un-checked. Then just drag it to the startup items for the user account of your choice.
New Wings3D model, built in about 90 minutes. I’ve screen captured the build and will make an animated GIF soon, I’m away for three weeks though so it may take a while. I’d like to work on reducing the build time to about 30 minutes.
I decided to try and use Wings3D for a new base mesh for character development. This mesh is based upon one Elron did a few years back, I haven’t been able to find his tutorials online so came up with this, I take no credit for the flow. Depending upon requests I may make this into a beginners tutorial for Wings3D. It’s simply extrusions and tweaking of the resulting points, build time is about 15 minutes.
EDIT: I’ve just noticed that two frames from near the end of the file appear in the middle, not sure why though. I’ll try exporting another from Photoshop, if that fails I’ll cut something together in Final Cut and upload a .MOV.
Some more ears, that’s should be it for a while unless I decide to do another video. These took about 30 minutes for the three, now I know some of the other tools in Wings I think I could repeat the procedure in about 5 minutes, the same speed as I work in Silo. For all you 3D folks who haven’t tried Wings3D, you really should give it a go.