Sign in to follow this  
Followers 0
abarth

Control remotely a computer @ a network (lan/wan/internet)

16 posts in this topic

Hi

is it possible (if yes could you give some ideas of how to?) to create something like console in order to control a remote computer. I want it to be invisible over the remote computer (server). I only need the client to be able for example control the volume(+/-).

thnx!

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

ehm

erm

u're just right

i just didnt believe that someone would need a tcp/ip remote control for volume :whistle:

PS1

also, some of us have very very very few time (with 2 children, 1 office and some other works) and... confused mind, so I thought easiest to ask ....

but u're right :P This is law in everything: first search then ask ...

sorry for bothering :D

PS2

though i havent tried anything from the links you provided.... but i believe one or more of them will be fine

Edited by abarth

Share this post


Link to post
Share on other sites

hm this is using php though

I dont want to use php

I just want to have a service on the server installed

and a client (a simple console) that adjusts the volume of the server (and ofcourse nothing is 'seen' on the server) ...

i am still looking because some of them need php(i dont want to install php), some of them just dont run and some of them are not for my case :whistle: but i am still searching ....

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

hm this is using php though

I dont want to use php

I just want to have a service on the server installed

and a client (a simple console) that adjusts the volume of the server (and ofcourse nothing is 'seen' on the server) ...

i am still looking because some of them need php(i dont want to install php), some of them just dont run and some of them are not for my case :whistle: but i am still searching ....

Well ofcourse you need TCP/IP for sending stuff over a network. Doesn't matter what it is.

BUT... I would normally never do this... But since:

1) I am in such a good mood today due to multiple personal reasons

2) I love the way you apologize

3) I would actually like this functionality myself so I can control my desktop volume at night in bed through my laptop without using VNC or something (bad reason, but hey, I need to have some sort of ratification for spending my time on what's going to follow)

4) And ofcourse since I am such a very very nice guy in general...

Guess what?? I coded the whole thing for you. NOTE: THIS WOULD NORMALLY NEVER HAPPEN! I just thought it would be funny and, again, I am in a very very good mood today! (Normally we all would want to see what you had produced yourself and then help you with any trouble.)

And I tested it extensively and it seems to work 100%, post reply if you find bugs.

Notes:

- you will need to change my LAN ip's for your ip's.

- hiding the tray icon vor the serverside version can be done, but that's so simple that I forgot to add it. Search the help for that last thing.

Server side:

$g_IP = "192.168.0.100"

; Start The TCP Services
;==============================================
TCPStartup()

; Create a Listening "SOCKET"
;==============================================
$MainSocket = TCPListen($g_IP, 65432, 100)
If $MainSocket = -1 Then Exit

$aliveCounter = 0

While 1
    $ConnectedSocket = TCPAccept($MainSocket)
    If $ConnectedSocket >= 0 Then
        While 1
            $input = TCPRecv($ConnectedSocket, 3)
            If $input <> "" And $input <> "xxx" Then
                setVol(Number($input))
            EndIf

            If $input = "" Then
                $aliveCounter += 1
            Else
                $aliveCounter = 0 ; <-- any msg has been received, connection lives
            EndIf

            Sleep(100)

            If $aliveCounter = 50 Then
                ExitLoop ; <-- 20*100 msec = 2 seconds, if no client msg has been received in 2 sec then break + go sit and eat out of your nose (as we say in Dutch) and wait for new connection
; /EDIT: 20*100msec = _2_ sec, not 10 sec like the comment in the previous line said before this edit  :"> 
            EndIf
        WEnd
    EndIf
    $aliveCounter = 0
    Sleep(100)
WEnd

Func setVol($percent)
    If Not SoundSetWaveVolume(Round(Number($percent))) Then
        MsgBox(0, "SoundSetWaveVolume error", "SoundSetWaveVolume error: " & @error&@CRLF&"Percent: "&Round(Number($percent)))
    EndIf
EndFunc   ;==>setVoloÝ÷ Ù©ÝêÞËayÉbz{l׺Ú"µÍÝÙ^TÙ]
    ][ÝÞÑTÐßI][ÝË    ][ÝÑ^][É][ÝÊBÌÍÜ[[ÝRTH ][ÝÌNLML  ][ÝÂÌÍÜÜH
MÌÈÝHÔÙXÙÂÏOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOBÔÝ

BÌÍÐÛÛXÝYÛØÚÙ]HÔÛÛXÝ
    ÌÍÜ[[ÝRT    ÌÍÜÜ
BYÜ[SÙÐÞ
    ][ÝÔ[[ÝHÛ[YHÛÛÛ  ][ÝË  ][ÝÑZ[YÈÛÛXÝÈÙÌÌÎÈÝÈ^][Ë][ÝÊBQ^][YÌÍÛXZ[ÝZHHÕRPÜX]][ÝÔ[[ÝHÛ[YHÛÛÛ  ][ÝËLL
BÌÍÝÛ[YTÛYHÕRPÝÜX]TÛYMKK
L
BÕRPÝÙ][Z]
    ÌÍÝÛ[YTÛYL
BÈHY][HÛYÈÛ]]Ú[ÛHHÙ[YÛY[ÚYHÚ[ÙÈ]ÜHÝ[YKÕRTÙ]Ý]J
BÌÍÛÛÛY[YHHÚ[HBIÌÍÜÛY[YHHÕRPÝXY
    ÌÍÝÛ[YTÛYBRY   ÌÍÜÛY[YH    ÉÝÈ  ÌÍÛÛÛY[YH[BIÌÍÜÙ[Ý[ÈHÝ[ÑÜX]
    ][ÝÉLÚI][ÝËÝ[Ê   ÌÍÜÛY[YJJBBUÔÙ[
    ÌÍÐÛÛXÝYÛØÚÙ] ÌÍÜÙ[Ý[ÊBBRYÜ[ÙÐÞ
    ][ÝÙÜ][ÝË  ][ÝÙÜ[ÔÙ[  ][ÝÉ[ÐÜBBIÌÍÛÛÛY[YHH   ÌÍÜÛY[YBQ[ÙHÈ ËKHÙ[ÙY[]HÙÈ   ][ÝÞ  ][ÝÂBUÔÙ[
    ÌÍÐÛÛXÝYÛØÚÙ] ][ÝÞ  ][ÝÊBBRYÜ[ÙÐÞ
    ][ÝÙÜ][ÝË  ][ÝÙÜ[ÔÙ[  ][ÝÉ[ÐÜBQ[YTÛY
L
BÑ[[È^][Ê
BQ^][[
Edited by SadBunny

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

first of all:

thank u very much

and I feel lucky that you're in a good mood today :whistle:

also I have to say that everything worked OK!

Just one thing to mention:

the volume u can adjust has a maximum that is set by the server.

That means that if I have the server muted(or volume=0) then u cannot raise the volume (u can slide it up but u wont hear anything)

The maximum u can hear when u set the client slide at maximum is the volume that the server has set already.

This is not a problem though, but I cant figure out why its happening.

Anyway thnx for the code because I can learn from it too many things.

I am creating serverside scripts with autoit and this is my ...3rd day I am 'playing' with it :P and so far I have created some stuff nice (autocreate music lists, autostart and autokill processes etc, select lists from checkboxs and merge them etc...) still learning and featuring :D

thnx!

Share this post


Link to post
Share on other sites

thnx!

No problem, was a fun little excercise for me too. Had some trouble first, whatever I did I kept receiving values other than I sent, but that was because I forgot to StringFormat the string to send, so it first sent for instance 9, and then 13, and the serverside reads 3 chars, so 913 was actually sent. The volume control does not like that :whistle: This just as a general tip for sending strings :P

Anyway, good to hear that you profit from my fun, and thanks for your feedback. Cheers!


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

Nice script you put there. I think I will use it and learn from it too :whistle: It has many potentials for what I need.

And if you want to remote control a PC (view what the user is actually doing and even take over their keyboard / mouse), then look at RealVNC or Dameware (This one might not be recommended). You can easily script either one to silently install a service and then remote into the PC silently and look at what they are doing.

I haven't scripted these yet but I plan to in the future as part of my admin toolbox. VNC should be pretty simple via command line.


Digital Chaos - Life as we know it today.I'm a Think Tank. Problem is, my tank is empty.The Quieter you are, the more you can HearWhich would you choose - Peace without Freedom or Freedom without Peace?Digital Chaos Macgyver ToolkitCompletely Dynamic MenuSQLIte controlsAD FunctionsEXCEL UDFPC / Software Inventory UDFPC / Software Inventory 2GaFrost's Admin Toolkit - My main competitor :)Virtual SystemsVMWAREMicrosoft Virtual PC 2007

Share this post


Link to post
Share on other sites

Nice script you put there. I think I will use it and learn from it too :whistle: It has many potentials for what I need.

And if you want to remote control a PC (view what the user is actually doing and even take over their keyboard / mouse), then look at RealVNC or Dameware (This one might not be recommended). You can easily script either one to silently install a service and then remote into the PC silently and look at what they are doing.

I haven't scripted these yet but I plan to in the future as part of my admin toolbox. VNC should be pretty simple via command line.

I do use VNC, but sometimes when you want some really simple fire-and-forget functionality, it is more of a hassle to have to login, control the mouse etc.. If like in this case it is only one function at a time that you need, it is faster to just directly access it in this kind of shortcut way. On top of that, the user of the VNC server sees you move the mouse ofcourse, so while you can silently install and monitor a VNC server, to control it silently is impossible if you need something that requires manipulating GUI's on the server in any way.

Btw, Some time ago on this forum someone had the idea of making a gui with an IE spawned in it, and make that connect to the VNC server's integrated webserver. Didn't get around to it yet but that should be quite slick-looking... :P


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

Btw, Some time ago on this forum someone had the idea of making a gui with an IE spawned in it, and make that connect to the VNC server's integrated webserver. Didn't get around to it yet but that should be quite slick-looking... :P

Thanks for the idea. :whistle: I'll implement that in a few days or so..

Share this post


Link to post
Share on other sites

Just one thing to mention:

the volume u can adjust has a maximum that is set by the server.

That means that if I have the server muted(or volume=0) then u cannot raise the volume (u can slide it up but u wont hear anything)

The maximum u can hear when u set the client slide at maximum is the volume that the server has set already.

This is not a problem though, but I cant figure out why its happening.

One more thing, I forgot to answer this: perhaps you didn't notice in the helptext about the SoundSetWaveVolume() that this function sets the Windows WAVE volume control, not the master volume control.


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

aww.. wish I read this thread earlier. I created a set of tools a while back for my place to control just about all media on my entertainment system from any computer!! Coulda shared that part.

btw: It might be more useful to use

Send("{VOLUME_UP}")

instead of setting the wav volume. That way it doesn't have to be wav audio! :whistle:

Edited by CrewXp

Share this post


Link to post
Share on other sites

aww.. wish I read this thread earlier. I created a set of tools a while back for my place to control just about all media on my entertainment system from any computer!! Coulda shared that part.

btw: It might be more useful to use

Send("{VOLUME_UP}")

instead of setting the wav volume. That way it doesn't have to be wav audio! :P

LOL! Thanks anyway :whistle:

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

hm

i ve made some changes :

1.put a txt in same directory with client just to write the iP of server so that the client.exe will read this iP (you wont need to change the .exe etc)

#include <GUIConstants.au3>

HotKeySet("{ESC}","Exiting")
$TextFileName = "volume.txt"
if FileExists($TextFileName)=True Then
            $file = FileOpen($TextFileName, 0)

If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    
    Exit
EndIf


While 1
    $line = FileReadLine($file)

    If @error = -1 Then ExitLoop
    $remoteIP=$line

Wend


FileClose($file)
dim $remoteIP


        EndIf
        if $remoteIP="" then 
            $remoteIP = "192.168.1.1" ; here you can write your server's IP if something goes wrong
        Else
        EndIf
         MsgBox(0, "Server IP:", $remoteIP)
oÝ÷ Ûb­æ­yݺÛhÏ¿¶^²Ûay!
¢{k¢T×îËb¢v®¶­s`¢b33c¶ÖäwVÒuT7&VFRgV÷Cµ6W'fW"7F'FW"´&'FÒgV÷C²ÃcÃc²vÆÂ7&VFRFÆör&÷FBvVâF7ÆVB26VçFW&V@¢b33c´'WGFöåóÒuT7G&Ä7&VFT'WGFöâgV÷C²²gV÷C²ÂÂRÂ3Ã#¢b33c´'WGFöåó"ÒuT7G&Ä7&VFT'WGFöâgV÷C²ÒgV÷C²ÂÂ#RÃ3Ã# oÝ÷ Û{azxi»­¶â²Þ²Çjö¥¹è¬±éíßÝwõú+ù©ÝßÝ·õú+jëh×6
While 1
    $msg = GUIGetMsg()
    if $msg=$Button_1 Then
        TCPSend($ConnectedSocket,"1")
        ;MsgBox(0,"error","error in TCPSend: "&"1")
        If @error Then MsgBox(0,"error","error in TCPSend: "&@error)
    EndIf
    if $msg=$Button_2 Then
        TCPSend($ConnectedSocket,"2")
        If @error Then MsgBox(0,"error","error in TCPSend: "&@error)
        EndIf
        ;if $msg="" Then  <----I tried this to 'keep' the connection alive all the time but it didnt work fine :)
        ;TCPSend($ConnectedSocket,"3")
        ;If @error Then MsgBox(0,"error","error in TCPSend: "&@error)
        ;EndIf
     if $msg = $GUI_EVENT_CLOSE Then
            ExitLoop
            exit
        EndIf
        
    ;Sleep(100)
WEnd

oÝ÷ Û­¶¬z»Þ¯lr^ÈZ²)Þ±«­¢+Ø(ÀÌØí}%@ô%AÉÍÌÄíѼÐÑ¡ÍÉÙÈÌäíÌ¥ÀÕѽµÑ¥((oÝ÷ Ù«­¢+Ø(%ÀÌØí¥¹ÁÕбÐìÐìÅÕ½ÐìÅÕ½Ðì¹ÀÌØí¥¹ÁÕбÐìÐìÅÕ½ÐíááàÅÕ½Ðì¹ÀÌØí¥¹ÁÕÐôÅÕ½ÐìÄÅÕ½ÐìQ¡¸(íÍÑY½°¡9ÕµÈ ÀÌØí¥¹ÁÕФ¤($$$%
½¹Ñɽ±M¹ ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐííÙ½±Õµ}ÕÀÕôÅÕ½Ðì¤í¤ÕÍÔÑ¥µÌ½ÈÍÑÈ¡¹è¤($$$$íM¹ ÅÕ½ÐííÙ½±Õµ}ÕÀÉôÅÕ½Ðì¤(¹%($$%%ÀÌØí¥¹ÁÕбÐìÐìÅÕ½ÐìÅÕ½Ðì¹ÀÌØí¥¹ÁÕбÐìÐìÅÕ½ÐíááàÅÕ½Ðì¹ÀÌØí¥¹ÁÕÐôÅÕ½ÐìÈÅÕ½ÐìQ¡¸(íÍÑY½°¡9ÕµÈ ÀÌØí¥¹ÁÕФ¤($$$%
½¹Ñɽ±M¹ ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐííÙ½±Õµ}½Ý¸ÕôÅÕ½Ðì¤($$$$íM¹ ÅÕ½ÐííÙ½±Õµ}½Ý¸ÉôÅÕ½Ðì¤(

i tried SEND and ControlSend but neither was good enough as the slidebar&setVol .... do you know why?

How can I make the connection keep alive for minutes? I tried to change some values (eg $aliveCounter = 50 -> $aliveCounter = 550 , or sleep(500) etc) but didnt work ....

anyway thnx!

Edited by abarth

Share this post


Link to post
Share on other sites

1.put a txt in same directory with client just to write the iP of server so that the client.exe will read this iP (you wont need to change the .exe etc)

Fine, whatever works for you! :whistle:

2.

I created 2 buttons +/- to test the SEND or ControlSend function

I liked the slidebar better myself, but again, whatever works for you! :P

3.

then if a button is pressed a value is sent:

'1' for + and '2' for -

TCPSend($ConnectedSocket,"1")
<...>
TCPSend($ConnectedSocket,"2")
Remember the StringFormat I used, it makes the tcpsend always send 3 characters. This because the server always wanted to receive 3 characters because it also needed to be able to read "100". Your hacked-up pieces of code from the serverside do not show what you did to the receiving part, make sure it only reads 1 character if you send only 1 character strings! (Or, if you want to make the server also accept 3 character strings or whatever, use something like my StringFormat to make sure that the string that is sent always contains the same number of characters.) (Or, advanced mode, if you feel like it, make a more flexible protocol that first sends the amount of characters to expect in the next packet section in a fixed format, and then reads that amount of characters. But I think that's overkill in this example.)

i tried SEND and ControlSend but neither was good enough as the slidebar&setVol .... do you know why?

Well what went wrong with them?

How can I make the connection keep alive for minutes? I tried to change some values (eg $aliveCounter = 50 -> $aliveCounter = 550 , or sleep(500) etc) but didnt work ....

Might have to do with the amount of characters sent (what I said above). You still seem to check for "xxx" but did you change the number of characters the server expects to receive?

The reason I even used the keepalive message is because it was the easiest way to make sure that if the client quits the clientside app, and then restarts the clientside app, the serverside re-accepts it's connection. This because of the loop I used in the serverside, which went something like:

1 - loop waiting for client connection

2 - if client connected, loop while waiting for client messages (meaning: the serverside will NOT accept new client 'logins'

/2 - quit loop if clientside does not send messages anymore

/1 - go back to 1, accept new connections

So if you send keepalive messages from the client in a format that the server understands, and make sure that they have the amount of characters the server reads in, increasing the 50 to 550 like you did *should* make the timeout threshold 11 times as long like you expected. (First I had a 10 sec timeout and I only had to change the number to make it a 2 sec timeout, should work in reverse too, ofcourse.)

You could also loop constantly while checking for new connections (and make an array of incoming connections), and in the loop, loop through the connected sockets and try to accept messages from them all. That way you can control your server with multiple clients at the same time, if you want to, AND you don't have to worry about sending keepalive messages from the client, since you can just reconnect and use another socket connection. (You would just need a timeout counter on the server to close dead connections, but you don't need to send anything for that.)

That would be more elegant and also cooler, but also a little bit more work from what I already made, and I was already a little bit late for my Rock&Roll dancing class! :D (I think I broke the sound barrier riding my bicycle to there...)


Roses are FF0000, violets are 0000FF... All my base are belong to you.

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