JPT Icon

Scripting JPT

While JPT is very powerful on its own, its true power comes from being able to control it using AppleScript. JPT has very robust AppleScript support. You can control every aspect of JPT from AppleScript including setting the Dialing Rules and Dial Method, the preferences, looking up contacts, converting mnemonics, and, of course, dialing numbers. With AppleScript support you can create very powerful dialing systems that meet your own unique requirements for transforming numbers and dialing from just about any application such as FileMaker Pro or some other custom database.

The easiest way to learn how to control JPT from AppleScript is to look at the example AppleScripts included in the “Goodies” folder on the JPT disk image. You may also look at the JPT AppleScript dictionary in the Script Editor to see the properties and commands that JPT supports. That said, the following should also help.

script tell application "Jon's Phone Tool"
    set the_number to "212-555-1212"
    --to have the user enter the number, un-comment the next line:
    --set the_number to text returned of (display dialog "What number shall I dial?" default answer the_number)
    
    --to grab the number from the clipboard, un-comment the next line:
    --set the_number to (the clipboard)
    
    --to take the value from a cell in FMP, un-comment the following code:
    (*
property cell_name : ""
repeat while cell_name = ""
    set cell_name to text returned of (display dialog "What cell name should I use?" default answer cell_name)
end repeat
try
    tell application "FileMaker Pro" to set the_number to cellValue of cell cell_name of current record of document 1
on error the_error
    beep
    display dialog the_error buttons {"OK"} default button 1 with icon 0 giving up after 10
    set cell_name to ""
    return
end try
*)
    
    --to dial a number (make sure JPT's dialing parameters are properly set--see above):
    dial number the_number
    
    --to dial a number and to set the name used in the call log, use the optional "name" parameter:
    dial number the_number name "NYC Information"
    
    (*
    if your number is already completely formatted with the appropriate prefixes and suffixes, you
    can tell JPT to dial the number exactly as formatted without adding any additional prefixes or
    suffixes that it would otherwise add by using the optional "literal" parameter.
    This does not change the configuration of JPT, for that set the current Location settings as described above.
    *)
    set the_number to "9,1-212-555-1212" --a completely formatted number dialing "9" for an outside line and prefixing with "1"
    dial number the_number name "NYC Information" with literal
end tell

script tell application "Jon's Phone Tool"
    --get the current location:
    set current_location to current location
    
    --to get all locations, use the command "list locations":
    set all_locations to list locations
    
    --to set a location, make sure you are using a location that exists from the "list locations" command
    set the_location to "Office"
    if the_location is in (list locations) then set current location to the_location
    
    --get the current location settings:
    set current_location_settings to current location settings
    
    --to set the current location settings, you use a record of one or more of the location settings
    --to set the call type Dial Methods, the Dial Method must be one of the following constants:
    --{Speaker DM, Modem DM, Bluetooth Phone DM, Asterisk DM, CallVantage DM, Cisco IP Phone DM, Phlink DM, PhoneValet DM, Skype DM, URL DM, Vonage DM, CounterPath Softphone DM, AppleScript DM}
    --Note: if you try to set the Dial Method to a Method that is not available on your system,
    --the set command will have no effect
    
    --so, here are settings appropriate for New York City:    
    set current location settings to {preprocess number script:"", country:"United States", local country code:"+1", outside prefix enabled:false, outside prefix:"9,", call waiting prefix:"*70,", caller ID block prefix:"*82,", literal Dial Method:Speaker DM, maximum internal length:4, internal prefix:"", internal suffix:"", internal Dial Method:Speaker DM, maximum local length:7, local area codes:"212, 718, 917, 646", include local area code:true, local prefix:"1", local suffix:"", local Dial Method:Modem DM, domestic prefix:"1", domestic suffix:"", domestic Dial Method:Speaker DM, international delimiter:"+", include international delimiter:false, international prefix:"011", international suffix:"", international Dial Method:Speaker DM, toll free codes:"800, 866, 877, 888", toll free prefix:"1", toll free suffix:"", toll free Dial Method:Speaker DM, SIP Dial Method:URL}
    
    --here are settings appropriate for using SkypeOut in the US:    
    set current location settings to {preprocess number script:"", country:"Custom", local country code:"", outside prefix enabled:false, outside prefix:"", call waiting prefix:"", caller ID block prefix:"", literal Dial Method:Skype DM, maximum internal length:4, internal prefix:"", internal suffix:"", internal Dial Method:Skype DM, maximum local length:7, local area codes:"", include local area code:true, local prefix:"+1", local suffix:"", local Dial Method:Skype DM, domestic prefix:"+1", domestic suffix:"", domestic Dial Method:Skype DM, international delimiter:"+", include international delimiter:false, international prefix:"", international suffix:"", international Dial Method:Skype DM, toll free codes:"800, 866, 877, 888", toll free prefix:"+1", toll free suffix:"", toll free Dial Method:Skype DM, SIP Dial Method:URL}
end tell

script tell application "Jon's Phone Tool"
    --to get all available Dial Methods, use the command "list Dial Methods":
    set all_Dial_Methods to list Dial Methods
    -->{Speaker DM, Modem DM, Bluetooth Phone DM, Asterisk DM, CallVantage DM, Cisco IP Phone DM, Phlink DM, PhoneValet DM, Skype DM, URL DM, Vonage DM, CounterPath Softphone DM, AppleScript DM}
    
    (*
    to set a Dial Method, it must be one of the following constants:
    Speaker DM/Modem DM/Bluetooth Phone DM/Asterisk DM/CallVantage DM/Ciscco IP Phone DM/Phlink DM/PhoneValet DM/Skype DM/URL DM/Vonage DM/CounterPath Softphone DM/AppleScript DM
    Note: if you try to set a Dial Method to a Method that is not available on your system, the set command will have no effect.
    Also remember that Dial Methods are linked to call types in a Location so to change them, use the following construction:
    *)
    set current location settings to {local Dial Method:Modem DM} -- or literal Dial Method, internal Dial Method, domestic Dial Method, etc.
end tell

script tell application "Jon's Phone Tool"
    --get the speaker dial method settings:
    set speaker_settings to speaker DM settings
    
    --to set the speaker dial method settings, you use a record of one or more of the speaker settings:
    set speaker DM settings to {speaker dial speed:fast, speaker comma pause:1.5, use pregenerated tones:false, override system volume:true, override system volume level:20}
end tell

script tell application "Jon's Phone Tool"
    --get the modem dial method settings:
    set modem_settings to modem DM settings
    
    --to set the modem dial method settings, you use a record of one or more of the modem dial method settings:
    set modem DM settings to {device:"modem", init string:"AT&FS10=255", initialize at launch:true, sound enabled:true, wait for dial tone:true, touchtones:true, calling tones disabled:false, wait for response:true, redial on busy:false, redial on busy pause:1, redial on busy total attempts:3, hang up timeout:10, release on hang up:false}
end tell

script tell application "Jon's Phone Tool"
    --get the Bluetooth phone dial method settings:
    set bluetooth_settings to Bluetooth phone DM settings
    
    --to set the Bluetooth dial method settings, you use a record of one or more of the Bluetooth dial method settings:
    set Bluetooth phone DM settings to {device:"Bluetooth-Modem", init string:"AT&F", alternate mobile dial string:false}
end tell

script tell application "Jon's Phone Tool"
    --get the Asterisk dial method settings:
    set asterisk_settings to Asterisk DM settings
    
    --to set the Asterisk dial method settings, you use a record of one or more of the Asterisk dial method settings:
    set Asterisk DM settings to {Asterisk username:"", Asterisk password:"", Asterisk alert on found servers:true, Asterisk update credentials:true, Asterisk extension:"", Asterisk connected device type:SIP Phone or Adapter, Asterisk context:"", Asterisk caller ID:"", Asterisk verbose logging enabled:true, Asterisk local server:false, Asterisk remote IP:"127.0.0.1", Asterisk remote server port:5038}
end tell

script tell application "Jon's Phone Tool"
    --get the CallVantage dial method settings:
    set callvantage_settings to CallVantage DM settings
    
    --to set the CallVantage dial method settings, you use a record of one or more of the CallVantage dial method settings:
    set CallVantage DM settings to {CallVantage number:"2125551212", CallVantage password:""}
end tell

script tell application "Jon's Phone Tool"
    --get the Cisco IP Phone dial method settings:
    set cisco_settings to Cisco IP Phone DM settings
    
    --to set the Cisco IP Phone dial method settings, you use a record of one or more of the Cisco settings:
    set Cisco IP Phone DM settings to {Cisco username:"", Cisco password:"", Cisco IP address:"192.168.0.100", Cisco priority:0}
end tell

script tell application "Jon's Phone Tool"
    --get the Phlink dial method settings (you can return these even if Ovolab Phlink is not available on your system):
    set phlink_settings to Phlink DM settings
    
    --to set the Phlink dial method settings, you use a record of one or more of the Phlink dial method settings:
    set Phlink DM settings to {Phlink recording enabled:true, Phlink silence detection enabled:true, Phlink hang up timeout:10, Phlink remote:true, Phlink remote username:"", Phlink remote password:"", Phlink remote IP address:"192.168.0.100"}
end tell

script tell application "Jon's Phone Tool"
    --get the PhoneValet dial method settings (you can return these even if Parliant's PhoneValet is not available on your system):
    set phonevalet_settings to PhoneValet DM settings
    
    --to set the PhoneValet dial method settings, you use a record of one or more of the PhoneValet dial method settings (well, there's currently only one setting):
    set PhoneValet DM settings to {PhoneValet dial exact:true, PhoneValet remote:true, PhoneValet remote username:"", PhoneValet remote password:"", PhoneValet remote IP address:"192.168.0.100"}
end tell

script tell application "Jon's Phone Tool"
    --get the URL dial method settings
    set url_settings to URL DM settings
    
    --to set the URL dial method settings, you use a record of one or more of the URL dial method settings:
    set URL DM settings to {URL DM path:"http://www.google.com/search?sa=X&oi=fwp&pb=f&q=%#", URL DM called silently:false, URL DM encoding:None}
end tell

script tell application "Jon's Phone Tool"
    --get the Vonage dial method settings:
    set vonage_settings to Vonage DM settings
    
    --to set the Vonage dial method settings, you use a record of one or more of the Vonage dial method settings:
    set Vonage DM settings to {Vonage username:"", Vonage password:"", Vonage number:""}
end tell

script tell application "Jon's Phone Tool"
    --get the CounterPath softphone dial method settings (you can return these even if no CounterPath softphone is available on your system):
    set counterpath_settings to CounterPath softphone DM settings
    
    --to set the CounterPath softphone dial method settings, you use a record of one or more of the CounterPath softphone dial method settings:
    set CounterPath softphone DM settings to {CounterPath strip formatting:true, CounterPath delay dial:15}
end tell

script tell application "Jon's Phone Tool"
    --get the AppleScript dial method settings:
    set applescript_settings to AppleScript DM settings
    
    --to set the AppleScript dial method settings, you use a record of one or more of the AppleScript dial method settings:
    set AppleScript DM settings to {script path:"path:to:script to use as Dial Method"}
end tell

script tell application "Jon's Phone Tool"
    --get the application preferences:
    set application_preferences to {launch status window enabled:launch status window enabled, login item enabled:login item enabled, main window shows on launch:main window shows on launch, textures enabled:textures enabled, status window enabled:status window enabled, alternate main enabled:alternate main enabled, main opacity:main opacity, main shadow enabled:main shadow enabled, recents menu max:recents menu max, separate recently dialed numbers menu enabled:separate recently dialed numbers menu enabled, separate Quick Dial menu enabled:separate Quick Dial menu enabled, include clipboard extras:include clipboard extras, convert mnemonics on dial:convert mnemonics on dial, hide PIM on lookup:hide PIM on lookup, voice enabled:voice enabled, tool tips enabled:tool tips enabled, JPT shows in Dock enabled:JPT shows in Dock enabled, dial confirmation enabled:dial confirmation enabled, external application on dial:external application on dial, pause iTunes on dial:pause iTunes on dial, change iTunes volume on dial:change iTunes volume on dial, iTunes volume on dial:iTunes volume on dial, pause DVD Player on dial:pause DVD Player on dial, change iChat status on dial:change iChat status on dial, iChat status on dial:iChat status on dial, display restore dialog:display restore dialog, global hotkey enabled:global hotkey enabled, global hotkey:global hotkey, global hotkey use Command modifier:global hotkey use Command modifier, global hotkey use Control modifier:global hotkey use Control modifier, global hotkey use Option modifier:global hotkey use Option modifier, global hotkey use Shift modifier:global hotkey use Shift modifier}
    -->{launch status window enabled:true, login item enabled:false, main window shows on launch:false, textures enabled:false, status window enabled:true, alternate main enabled:false, main opacity:1.0, main shadow enabled:true, recents menu max:10, separate recently dialed numbers menu enabled:true, separate Quick Dial menu enabled:true, include clipboard extras:true, convert mnemonics on dial:true, hide PIM on lookup:true, voice enabled:false, tool tips enabled:false, JPT shows in Dock enabled:false, dial confirmation enabled:false, external application on dial:"", pause iTunes on dial:true, change iTunes volume on dial:true, iTunes volume on dial:17, pause DVD Player on dial:true, change iChat status on dial:true, iChat status on dial:"On the phone...", display restore dialog:false, global hotkey enabled:true, global hotkey:"\\", global hotkey use Command modifier:true, global hotkey use Control modifier:true, global hotkey use Option modifier:true, global hotkey use Shift modifier:false}
    
    --to set the application preferences, set them individually. E.g.,:
    set separate Quick Dial menu enabled to (not (separate Quick Dial menu enabled))
end tell

script tell application "Jon's Phone Tool"
    --to get all Quick Dial Numbers, use the command "list Quick Dial Numbers":
    set all_Quick_Dial_Numbers to list Quick Dial Numbers
    -->{{contact name:"NYC Information", contact number:"(212) 555-1212"}}
    
    --to add a new Quick Dial Number, send the command "add Quick Dial" with the parameters "name" and "number" (both required):
    add Quick Dial contact name "NYC Information" contact number "(212) 555-1212"
end tell

script tell application "Jon's Phone Tool"
    --to get all recently dialed numbers, use the command "list recently dialed numbers":
    set recently_dialed_numbers to list recently dialed numbers
    -->{{contact name:"NYC Information", contact number:"(212) 555-1212"}}
end tell

script tell application "Jon's Phone Tool"
    --if you have your preferences set such that JPT pauses iTunes, DVD Player, or modifies your iChat status, you can rest these applications by issuing a "restore iApp status" command:
    restore iApp status
end tell

script tell application "Jon's Phone Tool"
    --get the call notification settings:
    set call_notification_settings to call notification settings
    
    --to set the call notification settings, you use a record of one or more of the call notification settings:
    set call notification settings to {broadcast outgoing calls:true, call detection enabled:false, device:"modem", call detection caller ID enabled:true, call detection caller ID init string:"AT+VCID=1", call detection caller ID lookup site:"Address Book", call detection alert enabled:true, call detection speak alert enabled:true, call detection off hook enabled:false, external application on call detection:"", broadcast incoming calls:true}
end tell

script tell application "Jon's Phone Tool"
    --get the current search site:
    set current_search_site to current search site
    -->"Address Book"
    
    --to get all search sites, use the command "list search sites":
    set all_search_sites to list search sites
    -->{"Address Book", "MS Entourage", "Now Contact", "Palm Desktop", "AnyWho", "Google", "Switchboard"}
    
    --to set a search site, make sure you are using a search site that exists from the "list search sites" command
    set the_search_site to "Address Book"
    if the_search_site is in (list search sites) then set current search site to the_search_site
    
    --now that you have the search sites, lookup someone:
    set the_name to "Apple" -- string
    set search_site to (item 1 of all_search_sites) -- string from fixed set of search sites
    lookup contact the_name search site search_site
    
    --to constrain the search to companies only, use the optional "companies only" parameter:
    lookup contact the_name search site search_site with companies only
    activate --activate JPT to bring the search results to the front
end tell

script tell application "Jon's Phone Tool"
    --get the call timer settings:
    set call_timer_settings to call timer settings
    -->{timer enabled:false, timer frequency:1.0, beep enabled:true, auto start:false, timer reset on start:true}
    
    --to set the call timer settings, you use a record of one or more of the call timer settings
    --Note: "timer enabled" is a read-only property
    --to start or stop a timer, use the "start timer" & "stop timer" commands
    set call timer settings to {timer frequency:0.5, beep enabled:true, auto start:false, timer reset on start:true}
end tell

script tell application "Jon's Phone Tool"
    --to use the timer, you need to set a frequency and whether or not to use a beep:
    set the_frequency to 0.5 -- real number as minutes, e.g., 0.5 = 30 seconds    
    start timer frequency the_frequency with beep and reset
    delay 41 --wait for the timer to fire once and the alert to dismiss itself then stop the timer
    stop timer
end tell

script tell application "Jon's Phone Tool"
    --to convert a mnemonic string to a phone number:
    set the_mnemonic to "1-800-SOS-APPL" -- string
    set converted_mnemonic to convert mnemonic the_mnemonic
    -->1-800-767-2775
end tell

script tell application "Jon's Phone Tool"
    --you can also script the modem through JPT:
    initialize modem using "AT&F"
    take modem off hook
    delay 10
    put modem on hook
    delay 10
    take modem off hook
    delay 10
    hang up
    release modem
end tell

Copyright © 2004 - 2017 JNSoftware LLC. All Rights Reserved.
All other products mentioned are copyright of their respective owners.
No endorsement of or affiliation with any third-party product or service is implied.