Sign in to follow this  
Followers 0
4Eyes

Remote control a pc on a LAN

12 posts in this topic

At risk of being flamed again, I'd like to ask if anybody has WORKING code that enables remote control of a pc on a LAN. I want to see their screen, and control their mouse and send keypresses. I found

RemoteAmI, Slaughter's ARC and AutoITSmithsRC but these either don't seem to do anything even after adding the includes and trying to fix the syntax to work with modern AutoIT.

Please note I do NOT want solutions involving vnc, ssh or mstsc.

I have not the foggiest idea how to do this with any speed... I can grab a screen and transfer it, I suppose I could move the mouse and send keypresses but surely this would be extraordinarily slow.

Any pointers appreciated.

Share this post


Link to post
Share on other sites



vncviewer is the best tool you can find for LAN

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites

Sheesh... I specifically said, not VNC or RDP!

Is there a native AutoIT solution? Seems there's been attempts years ago but I see nothing current.

Share this post


Link to post
Share on other sites

You're asking others to provide you with code without doing a bit of work yourself, and then biting their heads off after they give you perfectly good solutions to your problem. AutoIt is certainly not the language to be coding that in. VNC is without a doubt the solution.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

my bad. Basically all you need to do is a little trojan:

controlling the mouse & sending keys is really wery simple. to see the screen you will need to capture the scraeen & send the image to your pc. This is also very simple but requires a more time + coding.

The real problem is how to open the images that were sent to you. I do not know how to do this.

but other than that you can use the UDF that was written by Kip. Basically its TCP client/server. But it is rather easy to use.

He did not include the URL so you will have to search the forum for original post. Hire are the files I personally use. so the Client & server are modified a little, but last time I checked it was working fine.

EDIT: k im not sure i think it was kip who made the UDF

TCP.au3

#include-once
;Server Functions
;_TCP_Server_Start(IP, Port)
;_TCP_Server_Stop()
;_TCP_Server_SetOnEvent(Event, Function)
;_TCP_Server_Send(Message, UsersID (send to all by default))
;_TCP_Server_GetConnections()
;
;Client Functions
;_TCP_Client_Start(IP, Port)
;_TCP_Client_Stop()
;_TCP_Client_SetOnEvent(Event, Function)
;_TCP_Client_Send(Message)
;
;Internal Functions
;_TCP_Server_Events
;_TCP_Client_Events

;The Variables you may use in your scripts
Global Const $Tcp_Client_Event_Open     = 0
Global Const $Tcp_Client_Event_Close    = 1
Global Const $Tcp_Client_Event_Recv     = 2

Global Const $Tcp_Server_Event_Open     = 0
Global Const $Tcp_Server_Event_Close    = 1
Global Const $Tcp_Server_Event_Recv     = 2

;Internal Variables
Global $TCP_SERVER_CLIENT[1]
Global $TCP_SERVER_CONNECTION

Global $TCP_SERVER_RECV_FUNCTION        = ""
Global $TCP_SERVER_CONN_FUNCTION        = ""
Global $TCP_SERVER_LOST_FUNCTION        = ""
Global $_TCP_SERVER_TIMER
Global $_TCP_SERVER_TIMERCALLBACK

Global $TCP_CLIENT_CONNECTION

Global $TCP_CLIENT_RECV_FUNCTION        = ""
Global $TCP_CLIENT_CONN_FUNCTION        = ""
Global $TCP_CLIENT_LOST_FUNCTION        = ""

Global $_TCP_CLIENT_TIMER
Global $_TCP_CLIENT_TIMERCALLBACK

;#####################################
;_TCP_Server_Start($s_Ip, $s_Port)
;       $s_Ip = The Ip you want to use
;       $s_Port = The Port you want to use
;
;Returns:
;           True on succsess
;           False on failure
;
;Description: Starts up a simple multi user TCP Server.
;#####################################
Func _TCP_Server_Start($s_Ip, $s_Port)
    TCPStartup()
    $TCP_SERVER_CONNECTION = TCPListen($s_Ip, $s_Port)
    If @error Then Return False
    
    $_TCP_SERVER_TIMERCALLBACK = DllCallbackRegister("_TCP_Server_Events", "none", "hwnd;int;int;dword")
    $pTimerFunc = DllCallbackGetPtr($_TCP_SERVER_TIMERCALLBACK)
    $iResult = DllCall("user32.dll", "int", "SetTimer", "hwnd", 0, "int", Random(2000,2200,1), "int", '100', "ptr", $pTimerFunc)
    $_TCP_SERVER_TIMER = $iResult[0]

    Return True
EndFunc

;#######################
;_TCP_Server_Stop()
;Stops the TCP Server.
;#######################
Func _TCP_Server_Stop()
    If $TCP_SERVER_CONNECTION = -1 Then
        TCPShutdown() 
        Return False
    EndIf
    
    For $x = 1 To UBound($TCP_SERVER_CLIENT)-1
        TCPCloseSocket($TCP_SERVER_CLIENT[$x])
    Next
    TCPShutdown()
    DllCall("user32.dll", "int", "KillTimer", "hwnd", 0, "int", $_TCP_SERVER_TIMER)
    DllCallbackFree($_TCP_SERVER_TIMERCALLBACK)
    Return True
EndFunc

;#############################################
;_TCP_Server_SetOnEvent($s_Event, $s_Func)
;       $s_Event = The event you want to the declear a function to
;       $s_Func = The function you want the event to be handeld in
;
;Returns:
;           True on succsess
;           False on failure
;
;Descriptiong: Sets the function to be called on certin events.
;#############################################
Func _TCP_Server_SetOnEvent($s_Event, $s_Func)
    Switch $s_Event
        Case $TCP_SERVER_event_open
            $TCP_SERVER_CONN_FUNCTION = $s_Func
        Case $TCP_SERVER_event_close
            $TCP_SERVER_LOST_FUNCTION = $s_Func
        Case $TCP_SERVER_event_recv
            $TCP_SERVER_RECV_FUNCTION = $s_Func
        Case Else
            Return False
    EndSwitch
    Return True
EndFunc

;Internal Function
Func _TCP_Server_Events($hWnd, $iMsg, $iIDTimer, $dwTime)
    
    Local $temp_conn, $temp_recv
    $temp_conn = TCPAccept($TCP_SERVER_CONNECTION)
    If $temp_conn <> -1 Then
        For $x = 1 To UBound($TCP_SERVER_CLIENT)-1
            If Not $TCP_SERVER_CLIENT[$x] Then 
                $TCP_SERVER_CLIENT[$x] = $temp_conn
                Call($TCP_SERVER_CONN_FUNCTION, $x)
                $TCP_SERVER_CLIENT[0] += 1
                $x = 0
                ExitLoop
            EndIf
        Next
        If $x <> 0 Then
            ReDim $TCP_SERVER_CLIENT[UBound($TCP_SERVER_CLIENT)+1]
            $TCP_SERVER_CLIENT[UBound($TCP_SERVER_CLIENT)-1] = $temp_conn
            If $TCP_SERVER_CONN_FUNCTION <> "" Then Call($TCP_SERVER_CONN_FUNCTION, UBound($TCP_SERVER_CLIENT)-1)
            $TCP_SERVER_CLIENT[0] += 1
        EndIf
    EndIf
    
    For $x = 1 To UBound($TCP_SERVER_CLIENT)-1
        If Not $TCP_SERVER_CLIENT[$x] Then ContinueLoop
        $temp_recv = TCPRecv($TCP_SERVER_CLIENT[$x],4096)
        If @error Then
            Call($TCP_SERVER_LOST_FUNCTION, $x)
            TCPCloseSocket($TCP_SERVER_CLIENT[$x])
            $TCP_SERVER_CLIENT[0] -= 1
            $TCP_SERVER_CLIENT[$x] = False
        ElseIf $temp_recv = "" Then 
            ContinueLoop
        ElseIf $TCP_SERVER_RECV_FUNCTION <> "" Then
            Call($TCP_SERVER_RECV_FUNCTION, $temp_recv, $x)
        EndIf
    Next
    
    Return True
EndFunc

;#########################################
;_TCP_Server_Send($s_Msg, $s_Who=0)
;   $s_Msg = The message you want to send
;   $s_Who = the connection Id the client you want to send the data too
;   Sends message to everyone by default
;
;Returns:
;           True on succsess
;           False on failure
;
;Descriptiong: Sends Data from the server to the client(s)
;#########################################
Func _TCP_Server_Send($s_Msg, $s_Who=0)
    If $s_Who < 1 Then
        For $x = 1 To UBound($TCP_SERVER_CLIENT)-1
            If Not $TCP_SERVER_CLIENT[$x] Then ContinueLoop
            TCPSend($TCP_SERVER_CLIENT[$x], $s_Msg)
        Next
        Return True
    ElseIf $s_Who < UBound($TCP_SERVER_CLIENT) Then
        Return TCPSend($TCP_SERVER_CLIENT[$s_Who], $s_Msg)
    EndIf
    Return False
EndFunc

;#################################
;Returns: A array containing the TCP sockets
;   [0] = Socket count
;   [n] = Socket for userId n or false if not in use
;#################################
Func _TCP_Server_GetConnections()
    Return $TCP_SERVER_CLIENT
EndFunc

;#####################################
;_TCP_Client_Start($s_Ip, $s_Port)
;       $s_Ip = The Ip you want to connect to
;       $s_Port = The Port you want to use
;
;Returns:
;           True on succsess
;           False on failure
;######################################
Func _TCP_Client_Start($s_Ip, $s_Port)
    TCPStartup()
    $TCP_CLIENT_CONNECTION = TCPConnect($s_Ip, $s_Port)
    If @error Then Return False
    
    $_TCP_CLIENT_TIMERCALLBACK = DllCallbackRegister("_TCP_Client_Events", "none", "hwnd;int;int;dword")
    $pTimerFunc = DllCallbackGetPtr($_TCP_CLIENT_TIMERCALLBACK)
    $iResult = DllCall("user32.dll", "int", "SetTimer", "hwnd", 0, "int", Random(2000,2200,1), "int", '100', "ptr", $pTimerFunc)
    $_TCP_CLIENT_TIMER = $iResult[0]
    Return True
EndFunc

;#############################################
;_TCP_Client_SetOnEvent($s_Event, $s_Func)
;       $s_Event = The event you want to the declear a function to
;       $s_Func = The function you want the event to be handeld in
;
;Returns:
;           True on succsess
;           False on failure
;
;Descriptiong: Sets the function to be called on certin events.
;#############################################
Func _TCP_Client_SetOnEvent($s_Event, $s_Func)
    Switch $s_Event
        Case $Tcp_client_event_open
            $TCP_CLIENT_CONN_FUNCTION = $s_Func
        Case $Tcp_client_event_close
            $TCP_CLIENT_LOST_FUNCTION = $s_Func
        Case $Tcp_client_event_recv
            $TCP_CLIENT_RECV_FUNCTION = $s_Func
        Case Else
            Return False
    EndSwitch
    Return True
EndFunc

;######################
;_TCP_Client_Stop()
;Stops the TCP Stuff
;######################
Func _TCP_Client_Stop()
    If $TCP_CLIENT_CONNECTION = -1 Then 
        TCPShutdown()
        Return False
    EndIf
    
    TCPCloseSocket($TCP_CLIENT_CONNECTION)
    TCPShutdown()
    
    DllCall("user32.dll", "int", "KillTimer", "hwnd", 0, "int", $_TCP_CLIENT_TIMER)
    DllCallbackFree($_TCP_CLIENT_TIMERCALLBACK)
    Return True
EndFunc

;Internal Function
Func _TCP_Client_Events($hWnd, $iMsg, $iIDTimer, $dwTime)
    Local $temp_recv
    If $TCP_CLIENT_CONNECTION = -1 Then Return False
    
    $temp_recv = TCPRecv($TCP_CLIENT_CONNECTION,4096)
    If @error Then
        $TCP_CLIENT_CONNECTION = -1
        Call($TCP_CLIENT_LOST_FUNCTION)
        TCPCloseSocket($TCP_CLIENT_CONNECTION)
    ElseIf $TCP_CLIENT_RECV_FUNCTION <> '' And $temp_recv <> '' Then
        Call($TCP_CLIENT_RECV_FUNCTION, $temp_recv)
    EndIf
EndFunc

;#########################################
;_TCP_Client_Send($s_Msg)
;   $s_Msg = The message you want to send
;
;Returns:   See TCPSend
;           
;Descriptiong: Sends Data to the server
;#########################################
Func _TCP_Client_Send($s_Msg)
    Return TCPSend($TCP_CLIENT_CONNECTION, $s_Msg)
EndFunc

Client

#include "TCP.au3"
    #include <GUIConstantsEx.au3>

;~  Gui
;~  ##########################################################
    $Gui = GUICreate('Test Client',600,400)
    $Edit1 = GUICtrlCreateEdit('',5,5,590,355)
    $Input1 = GUICtrlCreateInput('', 5, 370,540,20)
    $Button1 = GUICtrlCreateButton('Send', 550, 370, 45, 20)
    GUISetState()   
;~  ##########################################################  

    Global $IP_, $Port_
    
    $IP_ =  '127.0.0.1'
    $Port_ = 30213
        
;~  Try To connect
;~  ==================================  

     $Connection = _TCP_Client_Start($IP_, $Port_)

    If $Connection = False Then     
        _Rconnect()
    Else        
        ConsoleWrite('Connected to:' & $IP_ & @CRLF) 

;~      _TCP_Client_SetOnEvent($Tcp_Client_Event_Close,'_Rconnect') ; if we loose active connection
        _TCP_Client_SetOnEvent($Tcp_Client_Event_Recv,'_On_Recv')       
    EndIf   
        
;~  ============================================
;~ Reconect Func
;~  ============================================
Func _Rconnect()

    $Stop_Connecton = _TCP_Client_Stop() ; Stop TCP 

    ConsoleWrite('Cant connect to:' & $IP_ & @CRLF)
    
    ConsoleWrite('Connection closed = ' & $Stop_Connecton & @CRLF)
    
;~ #CS      
;~  Reconnecting Count Down
;~  ----------------------
    For $a=1 To 2
        Sleep(1000)
        ConsoleWrite('Reconnecting in: ' & $a & ' sec' & @CRLF)
    Next

;~  Try To connect again
;~  ---------------------
     $Connection = _TCP_Client_Start($IP_, $Port_)
     
     If $Connection = False Then    
;~      _Rconnect()
        Exit
    Else        
        ConsoleWrite('Connected to:' & $IP_ & @CRLF)        
    EndIf
;~ #CE
EndFunc


;~  ============================================
;~  If we recive a message from Server do stuff
;~  ============================================    
Func _On_Recv($s_msg)
    Switch StringLeft($s_msg,3)
        Case 'Msg'
            GUICtrlSetData($Edit1, GUICtrlRead($Edit1) & StringTrimLeft($s_msg,4) & @CRLF)
            
            If StringTrimLeft($s_msg,4) = 123 Then GUICtrlSetData($Edit1, GUICtrlRead($Edit1) & 'Server Sent: ' & StringTrimLeft($s_msg,4) & @CRLF)
            
    EndSwitch
EndFunc




While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case -3         ; If exit GUI
            _GUI_exit()
            
        Case $Button1
            _TCP_Client_Send('Msg:' & GUICtrlRead($Input1))
            GUICtrlSetData($Input1,'')
    EndSwitch
WEnd

;~  ===============
;~  Exsit Func
;~  ===============
Func _GUI_exit()
    _TCP_Client_Stop()
    Exit    
EndFunc

Server

#include "TCP.au3"

    $IP = '127.0.0.1'
    $Port = 30213

    If Not _TCP_Server_Start($IP, $Port) Then Exit

    ConsoleWrite('Server Started @:' & $IP & @CRLF) ;Debug, for fun :P 

    _TCP_Server_SetOnEvent($Tcp_Server_Event_Open,  "_On_Connect")
    _TCP_Server_SetOnEvent($Tcp_Server_Event_Close, "_On_Close")
    _TCP_Server_SetOnEvent($Tcp_Server_Event_Recv,  "_On_Recv")

While 1
    Sleep(1000) 
WEnd

Func _On_Close($s_Id)
    ConsoleWrite($s_Id & '->left' & @CRLF) ;Debug, for fun :P 
EndFunc

Func _On_Connect($s_Id)
    ConsoleWrite($s_Id & '->Connected' & @CRLF) ;Debug, for fun :P 
EndFunc

Func _On_Recv($s_Recv, $s_Id)
    ConsoleWrite($s_Id & '->message-> '  & $s_Recv & @CRLF) ;Debug, for fun :P 
    
    _TCP_Server_Send($s_Recv) ; send the text user sent back to user & it will be put on GUI line
    
    
    If StringInStr($s_Recv,'123') Then MsgBox(0,'','Bingo!') ; if user Sends text Uus
    
    
    _TCP_Server_Send(@CRLF &'test',1);$s_Who = the connection Id the client you want to send the data too (0)= to everyone
EndFunc

Func OnAutoitExit()
    _TCP_Server_Stop()
EndFunc
Edited by goldenix

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites

I did not ask anybody to supply code. I asked if anybody had working code. If you think that is biting their head off you are overly sensitive.

_*AND*_ I specifically asked about AutoIT solutions, not VNC, etc.

Share this post


Link to post
Share on other sites

A native AutoIt solution of what you want to do will be extremely slow. You will see approximately one screen capture every 2~3 seconds, and maybe you will be able to control mouse or keyboard once every 0.5 second. This is the reason that no one has continued their VNC-like projects in AutoIt. Your chances of finding one are extremely slim.

Share this post


Link to post
Share on other sites

Hi.

I'm into oing a similar project as yours, minus the screen capture, I have a working client/server but my issue is grabbing what key has been pressed to send it to the remote pc.

If you want to work with me on this then if you have skype add me mayhermayhermayheralexdood, msn mayhers@gmail.com

personal email humanity121@gmail.com

I was flamed and called a blackhat for wanting to make an accessible screen reader friendly remote controlled application with autoit on here, so yeah the flaming happens quite a lot. :)

If it's just impracticle to do this in autoit i'm thinking of starting a console based app in c# for now till I get comfortable with gui's.

Anyways contact me off list and I'll try help not good at the visual stuff though.

From

Humanity.

Share this post


Link to post
Share on other sites

I made a remote control for my desktop with AutoIt around Dec 2008, but its the type of slowness you guys don't want or already know about.

In a nutshell, I run an FTP server on the PC to be controlled. Then I can log on and upload text files with instructions on what to do to a specific folder, from any PC. It follows the instructions and saves screencaptures that I then download and look at from the off-site PC.

Yes I know, very very slow, but i enjoyed coding it (in an extremely noobish way), and at that time i needed something like that, where i was away from my pc frequently. It did its job.

The reason why i used my way over the other programs is because its through FTP, and I can use AnyClient.com or any protable FTP client to remote control over the internet. No Installs. And at that time i was using school PCs, which don't allow program installations.

I'm a noob to programming, but I am willing to work with someone casually to see what we can come up with.

But as Manadar stated, theres only some much we can do with AutoIt, at a limited speed too, and im sure many other more advanced coders have tried to tackle with this for autoit, so i dont feel too confident about seeing a good usable one in AI language.

msn use_of_power@hotmail.com

Share this post


Link to post
Share on other sites

Thanks yousifucv, that's interesting to know. There are many other programs out there that do remote control, I wonder how many of them are using VNC protocols? I'm not a brilliant programmer either but get immense satisfaction from my efforts. Our friend humanity is also interested in similar stuff so maybe 3 heads are better than one. I'll PM you as I have already to humanity but no response yet.

Regards,

4Eyes

Share this post


Link to post
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
Sign in to follow this  
Followers 0