Friday, February 27, 2009

Skype Auto Caller [with time delay]

I was experiencing some horrible internet connection last night while I was talking to my girlfriend on Skype. I was going offline about every half an hour or so, and I didn't want to have to use my mouse or keyboard to call my girlfriend back; I wanted there be a way for skype to just automatically call that specific friend every time the call turned off. I thought of different ways I could solve the problem. I was thinking that I could find functions for audio output and make a function to turn audio output into a boolean value that would be false when there was no output and true when there was. Before I went on, I decided to make sure someone hadn't already created a solution to my problem. I didn't find an auto caller, but I did find some useful information that would make things a lot simpler.





I was googling around and found out that you can create a short cut to call a specific skype user. All I needed now was to figure out how to get this short cut to open all on its own. I thought I could have an executable run that would open the file, and I remebered a line of code for opening files with C++ from a yahoo question. Now all I needed was to block the file opening line in a never ending loop. I did that but I knew that would create a program that opened the short cut continuously (which doesnt seem like such a bad idea now that I think of it). So, I went looking for the sourcode for a time delay that would cause the open file in to execute only after every certain amount of time. Finally, I ended up with this:

// include insertion symbols
#include stdio.h
#include stdlib.h
#include time.h

void sleep( clock_t wait );
int main( void )
{
long i = 6000000L;
clock_t start, finish;
double duration;

while (true)
{
// Delay for a specified time.
printf( "Delay for 2 minutes\n" );
sleep( (clock_t)120 * CLOCKS_PER_SEC );
printf( "Calling!\n" );
system("C:/calluser.url");

/*the line just above this comment opens the shortcut you have to make. Right click desktop, click new, click short cut, and type in

skype:username?chat

and then press OK or whatever. In the case of my sourcecode, the shortcut's name is calluser with the url extension, but you can name the shortcut whatever you want. My shortcut's location is C:/. Remember to replace "username" with a username on your skype contact list or a number.*/

}
system ("PAUSE"); // unncessary and not reccomended
}


// Pauses for a specified number of milliseconds.

void sleep( clock_t wait )
{
clock_t goal;
goal = wait + clock();
while
( goal > clock() ) ;
}

/*********************************************************

There's potential for more features. I could change some literals into variables that can be changed by the user so I don't have to change the source code and compile every time I want to change the length of the delay. I could also just eliminate the time delay all together so it would execute continuously, but now that I think of this method again, I remember that you get an error message when you try to call someone when you're offline and if I had it do that I'd get a 1000 of those error messages every time I went offline with the auto caller program running, so that's no good. The delay stays! I could add some code that creates the url for you and asks you for the username or number using some stream methods.

**********************************************************/

No comments: