FAQFAQ   SearchSearch   UsergroupsUsergroups   RegisterRegister   ProfileProfile    Log inLog in   RSS Feed

Tutorial: A simple phone event script

 
Post new topic   Reply to topic    Salling Software Forums Forum Index -> Scripting Salling Clicker for Windows
View previous topic :: View next topic  
Author Message
salling
Site Admin


Joined: 27 Jul 2004
Posts: 7498
Location: Stockholm, Sweden

PostPosted: Wed Oct 19, 2005 2:09 pm    Post subject: Tutorial: A simple phone event script Reply with quote

Here's a mini-tutorial on how to create a simple Phone Event script. In other words: a script that responds to phone calls and proximity events.

This article assumes you're interested in building script plugins for Salling Clicker and that you have some experience in working with JScript or some other scripting language for Windows.

I have chosen to not make this script available as a simple download, as it is merely an example.

[b]The anatomy of a script package[/b]
(this is a recap from the last tutorial post)

Every Salling Clicker script is packaged in a directory containing at least one script file for the implementation and one XML file describing the script. Our sample script will be packaged like so:

\CallNotifier\CallNotifier.xml
\CallNotifier\CallNotifier.js

I used JScript because I like it better than VBScript, but VBScript would work equally well if you're more comfortable with this scripting language.

Start by creating the directory "CallNotifier" on your desktop. Then create two text files inside it "CallNotifier.xml" and "CallNotifier.js"

[b]The package description file (for a phone event script)[/b]

Now, let's fill those files with some meaning. Starting with the XML file, here's what it should contain:

[code:1]
<?xml version="1.0" encoding="utf-8"?>

<ClickerScript>
<Path>CallNotifier.js</Path>
<Author>Salling Software AB</Author>
<Category>Samples</Category>
<Description></Description>
<UUID>B83E366F-3764-44f4-AAD0-8C99C12D82F3</UUID>
<Title>Call Notifier</Title>
<Type>PhoneEvent</Type>
<URL>http://clicker.salling.com</URL>
</ClickerScript>
[/code:1]

This tells Salling Clicker who wrote the script, what its title is, and whether it's a "Clicker Item" or "Phone Event" script, among other things. Of particular importance are the UUID and Path elements. These give your script a unique identifier and also point to the script file that we shall soon implement.

[b]Important:[/b] as you make your own scripts, make sure each script has its own unique ID. You can use this web page to make new UUIDs: http://kruithof.xs4all.nl/uuid/uuidgen


[b]Our simple script implementation[/b]

What I had in mind is (again) exceptionally simple. When there's an incoming call, I want to show a short message on the computer's display, showing the caller ID, if this information is available.

On to the script! Open your file "CallNotifier.js" in a text editor and paste the following:

[code:1]
function CallStatusChanged( theTerminal, theCallStatus, thePhoneNumber, theCallType, theCID )
{
if( theCallStatus == 7 ) {
var message = theTerminal.bluetoothName + "\r";
if( thePhoneNumber != null && thePhoneNumber != "" ) {
message += "Incoming call from " + thePhoneNumber;
} else {
message += "Incoming call";
}
ShowMessage( message );
}
}
[/code:1]

Now what does this do? Well, CallStatusChanged() is called whenever the phone status changes on the phone (not all phones support this functionality, but many do; please see the device compatibility list). The arguments passed contain the following:

[b]theTerminal[/b] = the terminal object representing the device.
[b]theCallStatus[/b] = (1:idle, 2:calling, 3:connecting, 4:active, 5:holding, 6:waiting, 7:alerting, 8:busy) all phones do not make use of all codes
[b]thePhoneNumber[/b] = a string containing the phone number, if available
[b]theCallType[/b] = (1:voice, 2:data, 3:fax, 4:voice 2) all phones do not make use of all codes
[b]theCID[/b] = the ID for the call. Used with some phones when multiple calls are in progress.

We've mentioned the "theTerminal" object before. It has a number of properties holding information about the connected device. One of them is "bluetoothName".

Now. Save the files and drag the package directory into My Documents\My Clicker Scripts. Open Salling Clicker -> Phone Events, and check the "Call Notifier" item. Click Apply and try calling yourself...

[b]Note:[/b] You may need to disconnect and reconnect for a changed phone event script to "reload".

[b]Exercise[/b]

The ambitious reader might want to try and integrate with Outlook, to log phone calls, perhaps even finding the names of the callers. This could be useful to better bill clients calling you all day. Rounding the call duration up according to company practices, of course.;-)

I hope you found this sample useful!

Cheers.
--
Jonas
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Greget
Newbie


Joined: 15 Oct 2005
Posts: 10

PostPosted: Wed Oct 19, 2005 9:53 pm    Post subject: Reply with quote

Great example!
But is there someway to change the timeout of the message on the screen?
like ShowMessage(message, time) ?
Back to top
View user's profile Send private message
salling
Site Admin


Joined: 27 Jul 2004
Posts: 7498
Location: Stockholm, Sweden

PostPosted: Wed Oct 19, 2005 10:02 pm    Post subject: Reply with quote

Yep. Try this:

ShowMessage( message, NoIcon, -1, 10000 );

message = your text string
NoIcon = don't show an icon
-1 = don't show progress bar
10000 = 10 seconds viewing time

Best.
--
Jonas
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Greget
Newbie


Joined: 15 Oct 2005
Posts: 10

PostPosted: Wed Oct 19, 2005 10:05 pm    Post subject: Reply with quote

WOHOO!!!
Thanks!
:D
Back to top
View user's profile Send private message
Greget
Newbie


Joined: 15 Oct 2005
Posts: 10

PostPosted: Wed Oct 19, 2005 11:02 pm    Post subject: Reply with quote

One more question:
Is it possible to "catch" a sms-notification?
I guess the "theCallStatus" just concerns call status (wild guess),
so what I am wondering is if there is some way to get the type of the alert?
Back to top
View user's profile Send private message
salling
Site Admin


Joined: 27 Jul 2004
Posts: 7498
Location: Stockholm, Sweden

PostPosted: Wed Oct 19, 2005 11:14 pm    Post subject: Reply with quote

Not at this time, I'm afraid.

Best.
--
Jonas

[quote="Greget"]One more question:
Is it possible to "catch" a sms-notification?
I guess the "theCallStatus" just concerns call status (wild guess),
so what I am wondering is if there is some way to get the type of the alert?[/quote]
Back to top
View user's profile Send private message Send e-mail Visit poster's website
t3chnofre4k
Newbie


Joined: 17 Apr 2006
Posts: 3

PostPosted: Mon Apr 17, 2006 4:52 am    Post subject: Reply with quote

Hello!

Nice tutorial =)

I'm just wondering if it's possible to make it show the callers name from the phonebook instead of the phonenumber, assuming the number's saved in the phonebook.

So if my friend Bob in my phonebook calls it says Bob instead of his Phonenumber

Regards,
Rob
Back to top
View user's profile Send private message
salling
Site Admin


Joined: 27 Jul 2004
Posts: 7498
Location: Stockholm, Sweden

PostPosted: Mon Apr 17, 2006 11:06 am    Post subject: Reply with quote

That is an excercise left to the reader. ;-)

Seriously, this depends on what phone book you have.

Best.
--
Jonas

[quote="t3chnofre4k"]Hello!

Nice tutorial =)

I'm just wondering if it's possible to make it show the callers name from the phonebook instead of the phonenumber, assuming the number's saved in the phonebook.

So if my friend Bob in my phonebook calls it says Bob instead of his Phonenumber

Regards,
Rob[/quote]
Back to top
View user's profile Send private message Send e-mail Visit poster's website
t3chnofre4k
Newbie


Joined: 17 Apr 2006
Posts: 3

PostPosted: Tue Apr 18, 2006 4:26 am    Post subject: Caller ID phonebook names Reply with quote

OK, so if it's possible on my k750i and using the winversion, what is the caller id command to put in the script? would be glad if you could cut me some slack on that one at least? :?

Have been staring my eyes crossways over the net for two nights, and that's just cause I'm a noob in this VB scripting language, fiddled a bit with java in the early days, so now it's the only knowledge I have in handy :wink:

I have made a couple of other scripts and got em working so thats no problem, just finding that right line to put in to get the caller names to show up. for example, I made a macro to work around the disconnect prob when exiting the java-app,

so when I get the hang of this I'll certainly purchase a license too :D

Regards /Robin the swede
Back to top
View user's profile Send private message
salling
Site Admin


Joined: 27 Jul 2004
Posts: 7498
Location: Stockholm, Sweden

PostPosted: Tue Apr 18, 2006 3:48 pm    Post subject: Reply with quote

Unfortunately, It's not a matter of a adding a simple command.

You'd need to write the JScript/VBScript code to do [b]reverse lookup[/b] in your address book. You've still not told us what address book application you're using; this is of significant importance.

Most likely, you'll need to make the script loop over the contacts in your address book application, comparing the phone number for each of them with the incoming phone number (as provided by Clicker as a parameter to the script function). You'd be best off comparing only, say, the last 5 digits. Make sure to strip out spaces, hypens, and parenthesis.

If you're lucky, you're address book application has a dedicated command for doing this reverse lookup.

Best.
--
Jonas
Back to top
View user's profile Send private message Send e-mail Visit poster's website
simplymehmood
Junior Member


Joined: 04 Jul 2006
Posts: 22
Location: Romania

PostPosted: Fri Jul 07, 2006 2:22 am    Post subject: Reply with quote

hey.. is it possible to make a sms notifier?!... if it is can u?...plz...
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
lipkiss
Newbie


Joined: 12 Feb 2007
Posts: 9

PostPosted: Mon Feb 12, 2007 8:50 pm    Post subject: Reply with quote

[quote="salling"]Yep. Try this:

ShowMessage( message, NoIcon, -1, 10000 );

message = your text string
NoIcon = don't show an icon
-1 = don't show progress bar
10000 = 10 seconds viewing time

Best.
--
Jonas[/quote]

Where do i make these changes.
Back to top
View user's profile Send private message Send e-mail
salling
Site Admin


Joined: 27 Jul 2004
Posts: 7498
Location: Stockholm, Sweden

PostPosted: Tue Feb 13, 2007 2:30 am    Post subject: Reply with quote

In the JScript-file that is quoted at the top of this thread.

Best.
--
Jonas

[quote="lipkiss"][quote="salling"]Yep. Try this:

ShowMessage( message, NoIcon, -1, 10000 );

message = your text string
NoIcon = don't show an icon
-1 = don't show progress bar
10000 = 10 seconds viewing time

Best.
--
Jonas[/quote]

Where do i make these changes.[/quote]
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dzid_
Newbie


Joined: 09 May 2007
Posts: 13
Location: Poland

PostPosted: Sat May 12, 2007 4:07 pm    Post subject: Reply with quote

How is it possible to get info about system mute state. The 'Mute While On Phone' script needs it because in situation when volume is muted firstly, after call it changes to unmute. - in that situation this script schould do nothing.
Back to top
View user's profile Send private message
salling
Site Admin


Joined: 27 Jul 2004
Posts: 7498
Location: Stockholm, Sweden

PostPosted: Sat May 12, 2007 4:15 pm    Post subject: Reply with quote

Hi,

Not sure I understand your question (or rather it's relation to the Mute While On Phone script). The systemMute property can be both read and written to.

Best.
--
Jonas

[quote="dzid_"]How is it possible to get info about system mute state. The 'Mute While On Phone' script needs it because in situation when volume is muted firstly, after call it changes to unmute. - in that situation this script schould do nothing.[/quote]
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Salling Software Forums Forum Index -> Scripting Salling Clicker for Windows All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group