I see A_Str8 beat me to it but this is what I cooked up...
It's not compatible with Ae lock because of the get_prop 205/206's. It's a really good wear out test for the focus mechanics, I'm afraid...
A_Str8: AFAIK, different cameras may have different values coming out of get_focus... my a570is gives 65535 for infinity, not -1 like yours. But it doesn't matter with my script anyway, you can either specify the reference distance as a parameter or let the script measure it for you automagically.
edit: hmm... actually it does matter since if infinity is negative in your camera, you'll have to be creative and use the "further" mode if you select infinity as reference or the camera will never shoot. Didn't think of that since for my camera infinity is positive
Burst mode would probably be a desirable addition, but let's see how this one works first...
Digic III:
rem CHDK uBASIC script. Shoot when the camera finds focus closer/further
rem to a reference distance. At startup, camera must be pointed at
rem the reference distance or reference can be given as a parameter.
rem
rem To find a value for the reference parameter, use the auto mode
rem and read what the script reports you. It may or may not be
rem in millimeters, this depends on your camera model.
rem
rem Works on Digic III, developed on A570IS.
rem Change get_prop 206->205 for Digic II.
rem Author: Fudgey on 20080529
@title Focus Shoot
@param a Reference (0=Auto)
@default a 0
@param b Closer=0, Further=1
@default 0
if a=0 then gosub "getreference" else R=a
cls
print "Ref is", R
print "READY, SEARCHING FOCUS."
if b=1 then goto "further" else goto "closer"
:closer
press "shoot_half"
do
get_prop 206 P
until P=1
get_focus F
if F<R then click "shoot_full" else release "shoot_full"
do
get_prop 206 P
until P<>1
goto "closer"
:further
press "shoot_half"
do
get_prop 206 P
until P=1
get_focus F
if F>R then click "shoot_full" else release "shoot_full"
do
get_prop 206 P
until P<>1
goto "further"
:getreference
cls
print "Point at reference object,"
print "press MENU to get reference"
do
wait_click
is_key K "menu"
until K=1
press "shoot_half"
do
get_prop 206 P
until P=1
get_focus R
release "shoot_half"
return
Digic II:
rem CHDK uBASIC script. Shoot when the camera finds focus closer/further
rem to a reference distance. At startup, camera must be pointed at
rem the reference distance or reference can be given as a parameter.
rem
rem To find a value for the reference parameter, use the auto mode
rem and read what the script reports you. It may or may not be
rem in millimeters, this depends on your camera model.
rem
rem Developed on A570IS, modified for Digic II, hopefully works.
rem Change get_prop 205->206 for Digic III.
rem Author: Fudgey on 20080529
@title Focus Shoot
@param a Reference (0=Auto)
@default a 0
@param b Closer=0, Further=1
@default 0
if a=0 then gosub "getreference" else R=a
cls
print "Ref is", R
print "READY, SEARCHING FOCUS."
if b=1 then goto "further" else goto "closer"
:closer
press "shoot_half"
do
get_prop 205 P
until P=1
get_focus F
if F<R then click "shoot_full" else release "shoot_full"
do
get_prop 205 P
until P<>1
goto "closer"
:further
press "shoot_half"
do
get_prop 205 P
until P=1
get_focus F
if F>R then click "shoot_full" else release "shoot_full"
do
get_prop 205 P
until P<>1
goto "further"
:getreference
cls
print "Point at reference object,"
print "press MENU to get reference"
do
wait_click
is_key K "menu"
until K=1
press "shoot_half"
do
get_prop 205 P
until P=1
get_focus R
release "shoot_half"
return