Pages: 1 2
Topic closed
One of the coolest features of the current Scratch version 1.2.1 is the ability to let Scratch projects immediately run full-screen (in "presentation mode"), like "commercial applications", as John remarked. Unfortunately this feature is currently only available using a command line in Windows, so I suspect nobody's really using it at all....
Well, now you can have it the easy way:
I've put together a little bashfully primitive installation routine which will add an additional entry in the right-click object-menu of any Scratch Project on your system, letting you choose to run this project full screen right away. It's a tiny (37 Kb) executable you can download here:
http://www.moenig.org/scratch/ScratchShell.exe
After you run it once, you can enjoy this new powerful feature from anywhere within your Windows system, e.g. from within the Explorer. After the installation you can either double click on a Scratch project to open it in Scratch, or right click on it and then choose to either open it in Scratch or to run it in presentation mode right away. You can also safely delete the program again.
If you remove Scratch using the official deinstallation routine the changes made by this little programm will also be reverted.
Just so you know what you're doing, The NSIS code for this executable is exactly this (we're open source here, after all...):
Name "Scratch Presentation Mode Starter"
OutFile "ScratchShell.exe"
InstallDir nil
InstallDirRegKey HKLM "Software\Scratch" "Path"
Section
StrCmp $INSTDIR "nil" 0 +2
Abort "Aborting: Scratch needs to be installed before running this add-on."
WriteRegStr HKCR "Scratch Project\shell" "" "open"
WriteRegStr HKCR "Scratch Project\shell\run in presentation mode\command" "" '$INSTDIR\Scratch.exe "$INSTDIR\Scratch.image" "presentation" "%1"'
System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
sectionEndOh, you can of course download this huge and complex oevre
from here:
http://www.moenig.org/scratch/ScratchPresentationModeStarter.nsi
This installation routine checks if Scratch is installed on your computer and aborts if it isn't. Else it adds the presentation mode command line option to the Scratch Project's shell menu.
One caveat: This programm only checks for "Scratch" to be installed, it doesn't look for the correct version (since the Scratch installation apparently doesn't store its version number anywhere in the registry). Therefore if you install this on a previous version of Scratch the new menu entry will not work correctly (everything else still will, though).
BTW, you can also configure the Windows shell manually using regedit, but this would take too long to explain in this post.
I'd suggest the next Scratch release to incorporate this registry option in the Windows version, so this little app will become obsolete.
Have fun!
Last edited by Jens (2008-02-12 02:09:02)
Offline
Jens, you are a wizard! That sounds very useful.
As an alternate approach, I am using the Presentation mode feature currently and I'm not running from a command line (exactly). What I do is set up Shortcuts to the Scratch image file (copy the desktop shortcut to Scratch, for instance), than edit the shortcut Target to add the keyword "presentation" to the run line and then the path to the scratch project. Then, all you have to do is double click on the shortcut and up pops the project in Presentation mode. Here is the Target line from one of my shortcuts:
"C:\Program Files\Scratch\Scratch.exe" "C:\Program Files\Scratch\Scratch.image" presentation "C:\Users\Owner\AppData\Local\VirtualStore\Program Files\Scratch\Projects\Dad's Projects\icebounce.sb"
I can build these using Copy and Paste functions so it's not as bad as it looks.
Offline
Here's a success report....your program works even on Vista! Very nice!
Offline
Thanks for testing it on Vista, Paddle2See. I only have XP and ME, so I didn't know if the shell32 call would work on Vista, or if you'd need to restart Windows. Glad it does and you don't!
Offline
Now all we need is a Mac OS X hack so that double-clicking on a project brings it up in presentation mode. Of course, the best thing would be for the .sb file itself to have a bit to indicate whether to open in presentation mode or developer mode.
I have multiple versions of Scratch installed on my Mac, and it is sometimes difficult to get the .sb files to automatically open with the right version. I don't have this problem with other Mac applications that I have multiple versions of, so I'm wondering what the difference is.
Offline
Oops, I just found and fixed a tiny glitch that occasionally would alter the default action for the 'open' menu entry. Now it should work flawlessly (it's amazing that you can have glitches in mini-scripts such as this one - and an argument in favor of something like Scratch). I've also edited my first post in this thread and updated the linked files accordingly.
Offline
Hi, Kevin.
The same command-line flag to start in presentation mode works on Mac's, too. But I am not enough of a Mac wizard to know if there is a way to alter the double-click behavior to use it the way Jens did for Windows.
If this feature becomes really popular we could make it the default behavior on all platforms when you open Scratch by double-clicking on a project.
-- John
Offline
Wow! This is amazing! Media Lab must make a feature that lets you save your project so it opens in presentation mode. Way to go. Now to sell your games you make using Scratch you would have to put this program in, the actual Scratch program and your game. But this is still awsome.
Offline
If I understand the mysterious Windows code, I should be able to run
/Applications/Scratch v1.2.1 for OS X/Scratch.app/Contents/MacOS/Scratch -- presentation ~/Documents/Karplus_Scratch/Karplus\ Projects/Smooth\ Glide.sb
to open "Smooth Glide" in presentation mode. Well, it opens Smooth Glide ok, but not in presentation mode. (It also complains about freeing things with no pool in place, so some of the environment needed for an application is probably missing when run this way:
2008-02-11 22:19:06.760 Scratch[1871] *** _NSAutoreleaseNoPool(): Object 0x508e50 of class NSCFString autoreleased with no pool in place - just leaking
Offline
Kevin, I don't know anything about macs, but it occurs to me that you probably would have to spell out the "scratch.image" parameter explicitly, including the '*.image' suffix, and leave a space between the vm call and the image parameter.
The Squeak command line always goes:
vm image [application defined parameters].
The Scratch command line syntax for macs (like windows) thus would be:
fullpath/scratch.app fullpath/scratch.image presentation fullpath/project.sb
It consists of four parts separated by blanks.
(I keep forgetting which way to slant the dashes in different OS's).
Offline
Paddle2See wrote:
Here's a success report....your program works even on Vista! Very nice!
Good! Because I'm running Vista!
Offline
Hi, Kevin.
Here's an example of a command line that works on Mac OS X:
./Scratch.app/Contents/MacOS/Scratch Scratch.image - presentation MyProject.sb
The non-obvious part is that the Squeak VM needs an extra parameter (which it ignores) between the image name and the "presentation" keyword. I've passed a dash here, but it really doesn't matter since that argument is ignored. (You could ask on the Squeak mailing list what it was for, but it's somewhat irrelevant to Scratch.)
Those error messages from the VM are harmless, as far as I can tell. Again, you could check with the Squeak list to find out more about them.
-- John
Offline
Thanks, other than the error messages
2008-02-12 21:19:41.574 Scratch[2249] *** _NSAutoreleaseNoPool(): Object 0x508e80 of class NSCFString autoreleased with no pool in place - just leaking
2008-02-12 21:19:41.576 Scratch[2249] *** _NSAutoreleaseNoPool(): Object 0x50ad50 of class NSPathStore2 autoreleased with no pool in place - just leaking
2008-02-12 21:19:41.577 Scratch[2249] *** _NSAutoreleaseNoPool(): Object 0x50aeb0 of class NSPathStore2 autoreleased with no pool in place - just leaking
and the fact that running from a terminal window leaves the terminal window in front of presentation mode, that works.
Offline
Aha, I didn't know about the extra parameter needed for the Mac version of the Squeak VM. Isn't it possible to create a simple shell script (let's call it "Scratch presentation mode") on a Mac that starts up Scratch with the 'presentation' flag specified passing an argument (an .sb file) along, and then to change the file association for .sb files from "Scratch" to "Scratch presentation mode" using the .sb file's "Get Info" window?
Offline
I've never learned how to bundle a program as a Mac application. The Mac applications are actually unix directories,
Scratch.app/Contents/ contains
Info.plist
PkgInfo
and directories MacOS and Resources
I'm not sure what I need to edit in the Info.plist to run a shell script rather than the standard executable for a clickable application. I made an edit that I *thought* should work (changing the CFBundleExecutable field of the XML file, but that didn't work.
I may have had any number of bugs in what I did, but I'm reluctant to experiment given my current lack of knowledge of how OS X applications are structured.
Offline
I just coded up a simple droplet for OS X that will open up Scratch projects in presentation mode.
You can find the application and source code here.
I hope it's of use to someone!
-- Tony
Offline
I tried SpeedyAlkhest's droplet under Mac OS 10.3.9 and it didn't do anything, either by dropping an sb file on it or by setting up the sb file to use it as the application.
Is this a technique that works only under 10.4 or 10.5?
Offline
Hmm... apparently there are some incompatibilities between versions vis-a-vis AppleScript and droplets. The original package was built for 10.4.x. I just built another one for 10.5.x and put it on the site.
Unfortunately, I don't have any machines that are still running 10.3.x. Do you have Xcode installed? If so, I'd be curious to see what happens if you build it with that.
-- Tony
Last edited by SpeedyAlkahest (2008-03-02 14:52:24)
Offline
Also, the 10.4.x version was built on PPC and the 10.5.x version was built on Intel, 'cause that's what I have. :-)
Edit: I just checked and the project is set to build universal binaries, so the architecture, at least, shouldn't be a problem.
Last edited by SpeedyAlkahest (2008-03-02 15:12:38)
Offline
Paddle2See wrote:
Jens, you are a wizard! That sounds very useful.
As an alternate approach, I am using the Presentation mode feature currently and I'm not running from a command line (exactly). What I do is set up Shortcuts to the Scratch image file (copy the desktop shortcut to Scratch, for instance), than edit the shortcut Target to add the keyword "presentation" to the run line and then the path to the scratch project. Then, all you have to do is double click on the shortcut and up pops the project in Presentation mode. Here is the Target line from one of my shortcuts:
"C:\Program Files\Scratch\Scratch.exe" "C:\Program Files\Scratch\Scratch.image" presentation "C:\Users\Owner\AppData\Local\VirtualStore\Program Files\Scratch\Projects\Dad's Projects\icebounce.sb"
I can build these using Copy and Paste functions so it's not as bad as it looks.
Thanks! THats sooooo useful. Do you know if it works in Scratch 1.3.1?
Offline
I haven't tried it myself recently, but I would expect it to work still unless someone changed the registry-entry for the Scratch-installer, which to my knowledge hasn't happen. If it doesn't work, please tell me about it, and I'll fix it.
Offline
Paddle2See wrote:
Jens, you are a wizard! That sounds very useful.
As an alternate approach, I am using the Presentation mode feature currently and I'm not running from a command line (exactly). What I do is set up Shortcuts to the Scratch image file (copy the desktop shortcut to Scratch, for instance), than edit the shortcut Target to add the keyword "presentation" to the run line and then the path to the scratch project. Then, all you have to do is double click on the shortcut and up pops the project in Presentation mode. Here is the Target line from one of my shortcuts:
"C:\Program Files\Scratch\Scratch.exe" "C:\Program Files\Scratch\Scratch.image" presentation "C:\Users\Owner\AppData\Local\VirtualStore\Program Files\Scratch\Projects\Dad's Projects\icebounce.sb"
I can build these using Copy and Paste functions so it's not as bad as it looks.
Good Job! I saw your other posts and didn't get it to work, but now it does. Thanks!
Offline
Topic closed
Pages: 1 2