Jump to content
Gonzalez

[C] uTorrent Seeder

Recommended Posts

Posted
/*
uTorrent Seeder
Coded by a59
*/
#include <windows.h>
#include <urlmon.h>
#include <stdio.h>
#pragma comment( lib, "Urlmon.lib" )

HWND uTorrentWindow = 0;

BOOL CALLBACK EnumProc( HWND hWnd, LPARAM lParam )
{
char szTitle[ 512 ];

GetWindowText( hWnd, szTitle, sizeof( szTitle ) );

if( strstr( szTitle, "\xB5Torrent" ) )
uTorrentWindow = hWnd;

return TRUE;
};

HWND FindUTorrent( )
{
EnumWindows( EnumProc, 0 );
return( uTorrentWindow );
};

void TypeString( char* szString )
{
int Length = strlen( szString ), i;
bool ShiftDown = false;
short sKey;

for( i = 0; i < Length; i++, szString++ )
{
sKey = VkKeyScan( *szString );

if( ( sKey >> 8 ) & 1 )
{
keybd_event( VK_LSHIFT, 0, 0, 0 );
ShiftDown = true;
}

keybd_event( (unsigned char)sKey, 0, 0, 0 );

if( ShiftDown )
{
keybd_event( VK_LSHIFT, 0, KEYEVENTF_KEYUP, 0 );
ShiftDown = false;
}
}
};

int SeedUTorrent( char* szUrl, char* szSaveAs, char* szSeedTo )
{
HWND uTorrentWindow = FindUTorrent( );

if( uTorrentWindow == 0 )
return 1;

if( URLDownloadToFile( 0, szUrl, szSaveAs, 0, 0 ) != S_OK )
return 2;

if( (int)ShellExecute( 0, "open", szSaveAs, 0, 0, SW_NORMAL ) <= 32 )
return 3;

ShowWindow( uTorrentWindow, SW_SHOW );
BringWindowToTop( uTorrentWindow );
SetForegroundWindow( uTorrentWindow );
SetFocus( uTorrentWindow );

if( !IsWindow( uTorrentWindow ) )
return 4;

Sleep( 300 );

if( *szSeedTo != 0 )
TypeString( szSeedTo );

keybd_event( VK_RETURN, 0, 0, 0 );
ShowWindow( uTorrentWindow, SW_MINIMIZE );

return 0;
};

int main( )
{
switch( SeedUTorrent( "http://www.shotsy.com/shotsyblog/t.torrent", "c:\\t.torrent", "c:\\lol.rar" ) )
{
case 0:
printf( "Seeded!\n" );
break;
case 1:
printf( "Unable to locate uTorrent\n" );
break;
case 2:
printf( "Unable to download file\n" );
break;
case 3:
printf( "Unable to execute file\n" );
break;
case 4:
printf( "Error with window\n" );
break;
};

return 0;
};

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...