PG Music Home
Posted By: lrosicky Is BIAB apple scriptable? - 07/15/10 10:08 AM
I would like to write a script which would print lead sheets from a list of songs.

Lanny
Posted By: Benny Re: Is BIAB apple scriptable? - 07/17/10 04:47 AM
Looks like it works. I popped open "Automator," you know, that apple scripting program in your applications folder? Anyways, I hit record, click BIAB, type "Apple P", then clicked OK. I then hit stop in automator, and it recorded my script.
You tried that yet?

here's the resulting code that I got. I wish I understood how it worked:

-- Bring the window “Band-in-a-Box [No File Name] 2:49 [ZZJAZZ.STY:Jazz Swing Style]” to the front.
delay 1.783014
set timeoutSeconds to 2.000000
set uiScript to "click window \"Band-in-a-Box [No File Name] 2:49 [ZZJAZZ.STY:Jazz Swing Style]\" of application process \"Band-in-a-Box\""
my doWithTimeout( uiScript, timeoutSeconds )

-- Press ⌘P
delay 0.064018
set timeoutSeconds to 2.000000
set uiScript to "keystroke \"p\" using command down"
my doWithTimeout( uiScript, timeoutSeconds )

-- Type '
'
delay 1.056103
set timeoutSeconds to 2.000000
set uiScript to "keystroke \"
\""
my doWithTimeout( uiScript, timeoutSeconds )

-- Click the “Print” button.
delay 3.200038
set timeoutSeconds to 2.000000
set uiScript to "click UI Element \"Print\" of window \"Print\" of application process \"Band-in-a-Box\""
my doWithTimeout( uiScript, timeoutSeconds )

on doWithTimeout(uiScript, timeoutSeconds)
set endDate to (current date) + timeoutSeconds
repeat
try
run script "tell application \"System Events\"
" & uiScript & "
end tell"
exit repeat
on error errorMessage
if ((current date) > endDate) then
error "Can not " & uiScript
end if
end try
end repeat
end doWithTimeout
Posted By: ericdano Re: Is BIAB apple scriptable? - 07/17/10 04:16 PM
Thats not really the same as what he was asking.....that is AppleScript simply recording all your movements and playing them back. Scriptable applications are different.
Posted By: Benny Re: Is BIAB apple scriptable? - 07/17/10 09:43 PM
Dano,
Yeah, you're right, I don't think it is... but still, it's recordable.. so you can still do lots of automation. Seems to me if he wants to print his list of lead sheets, he might be able to do it using the record feature.
You still in the bay area?

Also, you guys ever check out Keyboard maestro? It's another macro enabling program. Easy to use and highly reviewed.
Posted By: ericdano Re: Is BIAB apple scriptable? - 07/18/10 08:04 PM
Problem with recording stuff is that when it expects that BinaB puts a window at position x, and it ends up in position x+2 it could mess things up pretty badly.

If you open AppleScript and see what Scriptable programs can do, it's pretty darn cool. Hopefully down the road PGMusic will add some scripting support but I'm just happy they seem to be fully supporting the Mac platform again. The couple year hiatus between version 12 and 2009 was pretty rough. I had written them off.....but they proved me wrong and really hit it out of the park.

Another scripting program I use is iKey.....mainly cause it came with this programmable USB footswitch I use.....
Posted By: Benny Re: Is BIAB apple scriptable? - 07/19/10 04:15 AM
nice. Are you using the foot switch to turn pages while you play? What's your setup for viewing music?

Also, here's my attempt to stay on topic... one way to avoid weird window positions is to use keyboard shortcuts. automator pics up on them. you still in the bay area? Where are you playing these days? I still use that PDF you made a long time ago on pentatonic patterns based on the bergonzi stuff. Good stuff man.
© PG Music Forums