Jump to content

FT_Pocket - 0.0.1.2 - Send/Receive file(s) to/from your friend(s) !


FireFox
 Share

Recommended Posts

FT_Pocket - 0.0.1.2

! New version, download it now !

Update :

Version 0.0.0.1File transfert is now workingAdded transfered KbAdded file nameReduced refresh timeAdded local IPVersion 0.0.0.2Added Skype soundsVarious bugs fixedVersion 0.0.0.3Added Kb/s for transfertAdded save/delete ip/portNew functions (remake by FireFox)Tray menu addedVersion 0.0.0.3Sender window isn't frozen anymore !Version 0.0.0.4Various bugs fixedVersion 0.0.0.5New functions (remake by TheMadMan)Version 0.0.0.6New functions (remake by FireFox)New tray structure (about & run start-up)Added 'send amount' sliderVersion 0.0.0.7Now possible to restart the transfert without fail !New functions for better stability (_TCP[...]Close)New tray structure (Show/Hide)Fixed name clear problem and minor bugs fixedThe source is now available in the FT pack (sorry for last time)Version 0.0.0.8Private use onlyNew tray structure (modern menu)Version 0.0.0.9Changed and improved send amount windowAdded Setup installation/RemoveVersion 0.0.1.0Deleted SA window (default SA is now 128)Changed Setup installation/removeAt launch the 1st IP/Port is selectedFixed trayitem iconsDefault receive directory is desktop if anyVersion 0.0.1.1SA is now available on line 6 of .sav fileIPs have been replaced with namesAdded time remainingKB/s is now on window titleFixed wrong KB/s for receiverAdded a drop window on rightVersion 0.0.1.2Added "Return" object on tcp errorsthe script add a firewall exception on start

Description :

(The main GUI is available by double clicking on the tray Icon; but not always...)

This script can send a file to an other computer over lan and vice versa for receive

Show percent,progress bar and kb/s

Set the ip and port to send file to the Client/Host

How can I use it ?

-Start the setup, then left-click on the trayicon; select FT menu and click on "show"

(if you start FT_Pocket with the desktop icon, the main GUI will be shown)

-Click on the "..." button; wich is on the left of "SEND !" button.

-Enter a friend name or whatever you want; on second inputbox you will have to enter the ip with goes with the name entered.

-At start the port 27000 is set, dont enter it again or it will be deleted (press cancel or enter another port)

-You have now 2 solutions for send a file;

*drop option : click on "»" button and drop a file on the picture

*browse option : click on the "..." button, wich is above the "SEND !" button.

-You can now click on "SEND !" button (your client has to press the receive button)

ScreenShot :

Posted Image

Notes :

It's not possible to make a multiple file transfert in so far as autoit does not support multithreading.

Your IP is in the window title, wich is always available on the traytooltip.

In order test it, you can send and receive a file to yourself with this ip adress : 127.0.0.1

the traymenu contains Exit/About/Cancel/Show/Hide functions.

On about window, you can select for run FT_Pocket on start-up

Attachments :

Previous download(s) : 551

Source : FTPocket_Source.txt

Setup (recommended for use) : FTPocket_Setup.txt

Enjoy ! :)

Cheers, FireFox.

Edited by FireFox
Link to comment
Share on other sites

nice :)

some suggestions:

make it a larger gui that can send&recv multiple files

make it send/recv parts of the file(needed for the next)

make it send/recv from multiple users (torrent like:P)

pause&resume download/upload

Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Link to comment
Share on other sites

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=148_shell32.ico
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_UseAnsi=y
#AutoIt3Wrapper_Res_Description=d3mon Corporation
#AutoIt3Wrapper_Res_Fileversion=1.0
#AutoIt3Wrapper_Res_LegalCopyright=d3mon Corporation. All rights reserved.
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <INet.au3>
#include <GuiEdit.au3>

HotKeySet('{ESC}', '_STOPSF')

Opt('GuiOnEventMode', 1)
Local $rem = @IPAddress1, $InetIP = _GetIP(), $STOP = False

#Region Sound
FileInstall('etf.mp3', @TempDir & '\etf.mp3', 1)
FileInstall('rdf.mp3', @TempDir & '\rdf.mp3', 1)
FileInstall('rtf.mp3', @TempDir & '\rtf.mp3', 1)
FileInstall('scf.mp3', @TempDir & '\scf.mp3', 1)
#EndRegion Sound
;

#Region GUI
$GUI = GUICreate('SF <d3montools>', 300, 160, -1, -1, -1, 262288)
GUISetOnEvent(-3, '_Exit')
GUISetOnEvent(-13, '_DROP')

#Region Send
GUICtrlCreateTab(5, 5, 290, 150)
GUICtrlCreateTabItem('SEND')
$E_FILE = GUICtrlCreateEdit('Drag a file to send or click on browse button >>', 15, 35, 240, 20, 2176)
GUICtrlSetState(-1, 8)

GUICtrlCreateButton('...', 262, 35, 23, 20)
GUICtrlSetOnEvent(-1, '_BIN')

$CIP = GUICtrlCreateCombo($InetIP, 15, 62, 108, 20, 0x3)
GUICtrlCreateLabel(':', 126, 65, 5, 15)
$CPORT = GUICtrlCreateCombo('21', 132, 62, 53, 20, 0x3)

GUICtrlCreateButton('...', 190, 62, 23, 21)
GUICtrlSetOnEvent(-1, '_AddCIP')

$send = GUICtrlCreateButton('SEND !', 220, 62, 65, 21)
GUICtrlSetOnEvent(-1, '_SEND')
GUICtrlSetState(-1, 128)

$pro_s = GUICtrlCreateProgress(15, 90, 270, 20)
$l_s = GUICtrlCreateLabel('0%', 130, 93, 25, 17, 1)
_SetAttrib(-1, 0x000000)

$l_ns = GUICtrlCreateLabel('', 15, 114, 265, 17)
GUICtrlSetFont($l_ns, 10, 700, 1, 'Arial')

$l_bs = GUICtrlCreateLabel('', 15, 134, 150)
#EndRegion Send

#Region Receive
GUICtrlCreateTabItem('RECEIVE')
$OUT = GUICtrlCreateEdit(@DesktopDir, 15, 35, 240, 20, 2176)
GUICtrlCreateButton('...', 262, 35, 23, 20)
GUICtrlSetOnEvent(-1, '_BOUT')

$LIP = GUICtrlCreateCombo(@IPAddress1, 15, 62, 108, 20, 0x3)
GUICtrlCreateLabel(':', 126, 65, 5, 15)
$LPORT = GUICtrlCreateCombo('21', 132, 62, 53, 20, 0x3)

GUICtrlCreateButton('...', 190, 62, 23, 21)
GUICtrlSetOnEvent(-1, '_AddLIP')

GUICtrlCreateButton('RECEIVE !', 220, 62, 65, 21)
GUICtrlSetOnEvent(-1, '_RECEIVE')

$pro_r = GUICtrlCreateProgress(15, 90, 270, 20)
$l_r = GUICtrlCreateLabel('0%', 130, 93, 25, 17, 1)
_SetAttrib(-1, 0x000000)

$l_nr = GUICtrlCreateLabel('', 15, 114, 265, 17)
GUICtrlSetFont($l_nr, 10, 700, 1, 'Arial')

$l_br = GUICtrlCreateLabel('', 15, 134, 155,60)
#EndRegion Receive

#Region Console
GUICtrlCreateTabItem('CONSOLE')
$CSLE = GUICtrlCreateEdit('', 15, 35, 270, 107, 3147968)
#EndRegion Console

GUISetState(@SW_SHOW, $GUI)
#EndRegion GUI
;

While 1
    Sleep(250)
WEnd

Func _STOPSF()
    If $STOP = False Then
        Global $STOP = True
        GUICtrlSetData($pro_s, 0)
        GUICtrlSetData($l_s, '0%')
        GUICtrlSetData($l_bs, '')
        GUICtrlSetData($pro_r, 0)
        GUICtrlSetData($l_r, '0%')
        GUICtrlSetData($l_br, '')
        _ConsoleWrite('Operation Cancelled !')
        SoundPlay(@TempDir & '\etf.mp3')
    EndIf
EndFunc   ;==>_STOPSF

Func _SetAttrib($c_ID, $color)
    GUICtrlSetColor($c_ID, $color)
    GUICtrlSetBkColor($c_ID, -2)
EndFunc   ;==>_SetAttrib

Func _ConsoleWrite($s_text, $Call = 2)
    If $Call = 1 Then
        _GUICtrlEdit_AppendText($CSLE, $s_text & @CRLF)
        _STOPSF()
    Else
        _GUICtrlEdit_AppendText($CSLE, $s_text & @CRLF)
    EndIf
EndFunc   ;==>_ConsoleWrite

Func _BIN()
    $ADD = FileOpenDialog('Select file to send', '', 'd3monCorp (*.*)', 1 + 2, '')
    If Not @error Then
        GUICtrlSetData($E_FILE, $ADD)
        $_p = StringSplit($ADD, '\')
        GUICtrlSetData($l_ns, $_p[$_p[0]])
        GUICtrlSetState($send, 64)
    EndIf
EndFunc   ;==>_BIN

Func _DROP()
    GUICtrlSetData($E_FILE, @GUI_DragFile)
    $_p = StringSplit(@GUI_DragFile, '\')
    GUICtrlSetData($l_ns, $_p[$_p[0]])
    GUICtrlSetState($send, 64)
EndFunc   ;==>_DROP

Func _BOUT()
    $ADD = FileSelectFolder('Select output folder for file(s) received', '', 6, @DesktopDir)
    If Not @error Then
        GUICtrlSetData($OUT, $ADD)
    EndIf
EndFunc   ;==>_BOUT

Func _AddCIP()
    $NIP = InputBox('SF - Add new Client', 'Enter new IP with port', '000.000.000.000:0000', '', 100, 100)
    If Not @error Then
        If $NIP = '' Then
            GUICtrlSetData($CIP, '')
            GUICtrlSetData($CIP, $InetIP & ':21', $InetIP & ':21')
        Else
            $_c = StringSplit($NIP, ':')
            If UBound($_c) - 1 > 1 Then
                GUICtrlSetData($CIP, $_c[1])
                GUICtrlSetData($CPORT, $_c[2])
            Else
                MsgBox(48, 'SF - Input error', 'Please enter a valid port !')
            EndIf
        EndIf
    EndIf
EndFunc   ;==>_AddCIP

Func _AddLIP()
    $NIP = InputBox('SF - Add new Host', 'Enter new IP with port', '000.000.000.000:0000', '', 100, 100)
    If Not @error Then
        If $NIP = '' Then
            GUICtrlSetData($LIP, '')
            GUICtrlSetData($LIP, $rem & ':21', $rem & ':21')
        Else
            $_c = StringSplit($NIP, ':')
            If UBound($_c) - 1 > 1 Then
                GUICtrlSetData($LIP, $_c[1])
                GUICtrlSetData($LPORT, $_c[2])
            Else
                MsgBox(48, 'SF - Input error', 'Please enter a valid port !')
            EndIf
        EndIf
    EndIf
EndFunc   ;==>_AddLIP

Func _Exit()
    #Region Sound
    FileDelete(@TempDir & '\etf.mp3')
    FileDelete(@TempDir & '\rdf.mp3')
    FileDelete(@TempDir & '\rtf.mp3')
    FileDelete(@TempDir & '\scf.mp3')
    #EndRegion Sound
    Exit ;Exit SF
EndFunc   ;==>_Exit


Func _SEND()
    Global $STOP = False
    _FileSend(GUICtrlRead($E_FILE), GUICtrlRead($CIP), GUICtrlRead($CPORT))
EndFunc   ;==>_SEND

Func _RECEIVE()
    Global $STOP = False
    _FileReceive(GUICtrlRead($LIP), GUICtrlRead($LPORT))
EndFunc   ;==>_RECEIVE


#Region File Send
; #FUNCTION# =============================================================
; Name............: _FileSend
; Description.....: Send file by TCP
; Return Value(s).: _ConsoleWrite / percent
; Author(s).......: TheMadman
; Note............: Modified by FireFox into an UDF and more...
;=========================================================================
Func _FileSend($FILE, $IP, $PORT)
    If Not FileExists($FILE) Then _ConsoleWrite('!> FileExists error !', 1)
    GUICtrlSetData($pro_s, 0)
    GUICtrlSetData($l_s, '0%')
    
    TCPStartup()
    $size = FileGetSize($FILE)
    If $size < 1 Then _ConsoleWrite('!> FileGetSize error !', 1)
    
    $_sock = TCPConnect($IP, $PORT)
    If @error Then _ConsoleWrite('!> Unable to connect to the host!', 1)
    
    $recv = TCPRecv($_sock, 1000)
    $recv = StringTrimLeft($recv, 2)
    
    _ConsoleWrite('+> Waiting for Client reponse...')
    
    If ($recv = '') Then
        While 1 ;-----------
            $recv = TCPRecv($_sock, 1000)
            If @error Then _ConsoleWrite('!> Lost connection !', 1)
            If $recv <> '' Then ExitLoop
            If $STOP = True Then ExitLoop
        WEnd
    EndIf
    
    If $recv <> 'FILE_DATA' Then _ConsoleWrite('!> Got : "' & $recv & '" from the socket', 1)
    _ConsoleWrite('+> Starting download...')
    TCPSend($_sock, $FILE & '?' & $size)
    SoundPlay(@TempDir & '\scf.mp3')
    
    While 1
        $recv = TCPRecv($_sock, 1000)
        If @error Then _ConsoleWrite('!> Lost connection !', 1)
        If $recv <> '' Then ExitLoop
        If $STOP = True Then ExitLoop
    WEnd
    
    If $recv <> 'START_UL' Then _ConsoleWrite('!> Got : "' & $recv & '" from the socket', 1)
    _ConsoleWrite('+> Sending file...')
    Local $return = True, $bytes = 0, $Init = 400
    $fhandle = FileOpen($FILE, 16)
    $msg=""
    While $return
        $data = FileRead($fhandle,2*1024*1024)
        If $STOP = True Then ExitLoop
        $bytes += TCPSend($_sock, $data)
        If (TimerDiff($Init) >= 400) Then
            GUICtrlSetData($pro_s, Round($bytes * 100 / $size, 0))
            GUICtrlSetData($l_s, Round($bytes * 100 / $size, 0) & '%')
            $Init = TimerInit()
            GUICtrlSetData($l_bs, 'Sent : ' & Round($bytes / 1000, 1) _
                     & '/' & Round($size / 1000, 1) & ' KB')
        EndIf
        If $bytes = $size Then $return = False
    WEnd
    _ConsoleWrite('+> File successfuly sent !')
    SoundPlay(@TempDir & '\rtf.mp3')
    GUICtrlSetData($pro_s, 100)
    GUICtrlSetData($l_s, '100%')
    FileClose($fhandle)
    TCPShutdown()
EndFunc   ;==>_FileSend
#EndRegion File Send

#Region File Receive
; #FUNCTION# =============================================================
; Name............: _FileReceive
; Description.....: Receive file by TCP
; Return Value(s).: _ConsoleWrite / percent
; Requirement(s):   __start_recv ; __get_file_data
; Author(s).......: TheMadman
; Note............: Modified by FireFox into an UDF and more...
;=========================================================================
Func _FileReceive($_LIP, $PORT)
    TCPStartup()
    GUICtrlSetData($pro_r, 0)
    GUICtrlSetData($l_r, '0%')
    SoundPlay(@TempDir & '\scf.mp3')
    $_L_SOCK = TCPListen($_LIP, $PORT)
    If @error Then _ConsoleWrite('!> Unable to hook port !', 1)
    _ConsoleWrite('+> Listening...')
    While 1
        If $STOP = True Then ExitLoop
        $_tcp_acc = TCPAccept($_L_SOCK)
        If $_tcp_acc <> -1 Then
            $sr = __start_recv($_tcp_acc)
        EndIf
    WEnd
    SoundPlay(@TempDir & '\rtf.mp3')
    GUICtrlSetData($pro_r, 100)
    GUICtrlSetData($l_r, '100%')
    TCPShutdown()
EndFunc   ;==>_FileReceive

Func __start_recv($_sock)
    While True
        $_recv = TCPRecv($_sock, 8 * 1048576)
        If @error Then Return _ConsoleWrite('!> TCPRecv error !', 1)
        $FILE = __get_file_data($_sock)
        If @error Then
            $TRUSTED = False
            Return _ConsoleWrite('!> __get_file_data error !', 1)
        EndIf
        SoundPlay(@TempDir & '\rdf.mp3')
        GUICtrlSetData($l_nr, $FILE[0])
        $location = GUICtrlRead($OUT) & '\' & $FILE[0]
;~      $location = FileSaveDialog('Receive ' & $FILE[0], GUICtrlRead($OUT), _
;~              'Ext (*.' & $FILE[2] & ')', 16, $FILE[0])
;~      If @error Then
;~          $TRUSTED = False
;~          _ConsoleWrite('!> FileSaveDialog error !', 1)
;~          Return TCPCloseSocket($_sock)
;~      EndIf
        $fhandle = FileOpen($location, 18)
        TCPSend($_sock, 'START_UL')
        _ConsoleWrite('+> START_UL')
        Local $downloading = True, $bytes = 0, $Init = 400
        While $downloading
            $_data = TCPRecv($_sock, 8 * 1048576, 1)
            If @error Then
                FileClose($fhandle)
                FileDelete($location)
                $TRUSTED = False
                Return _ConsoleWrite('!> TCPRecv error !', 1)
            EndIf
            $bytes += BinaryLen($_data)
            FileWrite($fhandle, $_data)
            If (TimerDiff($Init) >= 400) Then
                GUICtrlSetData($pro_r, Round($bytes * 100 / $FILE[1], 0))
                GUICtrlSetData($l_r, Round($bytes * 100 / $FILE[1], 0) & '%')
                $Init = TimerInit()
                GUICtrlSetData($l_br, 'Received : ' & Round($bytes / 1000, 1) _
                         & '/' & Round($FILE[1] / 1000, 1) & ' KB')
            EndIf
            If $bytes = $FILE[1] Then $downloading = False
            If $STOP = True Then ExitLoop
        WEnd
        GUICtrlSetData($pro_r, Round($bytes * 100 / $FILE[1], 0))
        GUICtrlSetData($l_r, Round($bytes * 100 / $FILE[1], 0) & '%')
        GUICtrlSetData($l_br, 'Received : ' & Round($bytes / 1000, 1) _
                & '/' & Round($FILE[1] / 1000, 1) & ' KB')
        
        TCPSend($_sock, 'GOT_IT')
        MsgBox(0 , "Client" , "Done")
        _ConsoleWrite('+> File successfuly received !')
        FileClose($fhandle)
        TCPCloseSocket($_sock)
        ExitLoop
    WEnd
EndFunc   ;==>__start_recv

Func __get_file_data($_sock)
    TCPSend($_sock, 'FILE_DATA')
    _ConsoleWrite('+> FILE_DATA')
    Local $_recv = '', $data[3]
    While 1
        $_recv = TCPRecv($_sock, 1000)
        If @error Then Return SetError(2)
        If $_recv <> '' Or $STOP = True Then ExitLoop
    WEnd
    $path = StringLeft($_recv, StringInStr($_recv, '?') - 1)
    $s_n = StringSplit($path, '\')
    
    $size = StringMid($_recv, StringInStr($_recv, '?') + StringLen('?'))
    $sExt = StringRegExpReplace($path, '^.*\.', '')
    If @error Then _ConsoleWrite('!> Bad extension : ' & $path, 1)
    
    $data[0] = $s_n[$s_n[0]]
    $data[1] = $size
    $data[2] = $sExt
    Return $data
EndFunc   ;==>__get_file_data
#EndRegion File Receive

Try it now :)

i tried with files from 500k to 2gb and it updates ok

but for some reason recv gui freezes after you click the RECEIVE! button

cheers

Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Link to comment
Share on other sites

  • 2 weeks later...

Version 1.4 available (see first post for update)

Note : I would accept to help someone to transfert file(s) if needed ...

-------

Version 1.5 available (see first post for update)

Cheers, FireFox.

Edited by FireFox
Link to comment
Share on other sites

@Firefox - Thanks for sharing! :P

Good to see someone else has taken to using my download link text idea. :unsure:

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...