Jump to content

Ideea of script - like TeamViewer


Recommended Posts

I would like to make a script similar to TeamViewer, but I got stuck before even starting it.

First of all how could I send ScreenShots from one computer to anotherone by just using an ID and a Password, without using the IP? Perhaps through a server, but how?

-The screen shots need to be as small as posible...something as 3-4 kB (I think this would be great)...using Autoit's _ScreenCapture_Capture() function with _ScreenCapture_SetJPGQuality(25) (a reasonable quality) I got a 56-60Kb file. (for sending 10pictures/sec it would take about 0.5 MB/s transfer speed, but it would be great to work with 10 pictures/sec even for a low speed connection such as a modem)

-Using Autoit's _ScreenCapture_Capture() function it takes about 2 pictures/second, but it would be good to take around 10pictures/sec to create the impresion of continuity.

Any Ideeas are welcomed!

Thx in advance.

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Link to comment
Share on other sites

Look at TCP IP, if you are new to AutoIt I wouldn't start with such things.

With a simple search you can find some examples on how to make a server to connect to and clients. (yes you can integrate id and pw)

How about resize the picture with GDI+ before sending it?

2 sec for _ScreenCapture_Capture()? That sounds insane, for me it's some ms...

10 pictures/sec sounds insane to if you ask me, you might better look at monoceres avi capture udf for that.

Edited by Pain
Link to comment
Share on other sites

Look at TCP IP, if you are new to AutoIt I wouldn't start with such things.

With a simple search you can find some examples on how to make a server to connect to and clients. (yes you can integrate id and pw)

How about resize the picture with GDI+ before sending it?

2 sec for _ScreenCapture_Capture()? That sounds insane, for me it's some ms...

10 pictures/sec sounds insane to if you ask me, you might better look at monoceres avi capture udf for that.

Thx for reply!

I'm not new to Autoit.

I have tryed using TCP IP with other applications, but it doesn't work if a router is pressent and I whant it to work no matter what the computer/network configuration is.

I have also looked at monoceres avi capture udf but it doesn't help me.

_ScreenCapture_Capture() makes 2 pictures/sec not the way you said...I timed if using:

#include <ScreenCapture.au3>
Local $file = @ScriptDir & "\screencap.png"
$Loops = 10
$begin = TimerInit()

For $i = 1 to $Loops
    _ScreenCapture_Capture($file)
Next

ConsoleWrite("Number of pictures taken in a second: "&round($Loops/(TimerDiff($begin)/1000),2)&@CRLF);2.13 p/s for me

I want this to be as fast as posible and by resizing it it will make harder to obtain a good frames/sec rate.

Do you think 10 frames/sec is too much?...maybe 4-5 frames/sec it will be acceptable, but I need a method that could improuve this rate having in mind that those pictures will have to be sent, and this will lower the frames rate (I approximate by half)....this is the reason why I need another method of taking screen captures.

Please try the code above and tell me how many pictures/sec it takes for you.

Thx for reply

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Link to comment
Share on other sites

Your code returned 6.19 for me.

Try something like this to get a better result.

#Include <ScreenCapture.au3>
Local $file = @ScriptDir & "\screencap.png"
$Counter = 0
$begin = TimerInit()

Do
    _ScreenCapture_Capture($file)
    $Counter += 1
Until TimerDiff($begin) >= 1000

ConsoleWrite($Counter)

For me it took 7 pictures.

If you noticed the CPU percentage you will see that it uses 100% of the CPU (atleast for me because I got a single core cpu) so I think you need to look for another way if you want 10 pic/sec.

Edited by Pain
Link to comment
Share on other sites

Your code returned 6.19 for me.

Try something like this to get a better result.

#Include <ScreenCapture.au3>
Local $file = @ScriptDir & "\screencap.png"
$Counter = 0
$begin = TimerInit()

Do
    _ScreenCapture_Capture($file)
    $Counter += 1
Until TimerDiff($begin) >= 1000

ConsoleWrite($Counter)

For me it took 7 pictures.

If you noticed the CPU percentage you will see that it uses 100% of the CPU (atleast for me because I got a single core cpu) so I think you need to look for another way if you want 10 pic/sec.

Your code returned 2-3 for me, and I have noticed the 100% of the CPU. I whant this to work for any computer and to be fast, so I thought of using an API because they are fast and hopefully CPU friendly, but I haven't found one yet.

Mihai

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Link to comment
Share on other sites

Your code returned 2-3 for me, and I have noticed the 100% of the CPU. I whant this to work for any computer and to be fast, so I thought of using an API because they are fast and hopefully CPU friendly, but I haven't found one yet.

Mihai

Using LAzyCat's dll, captdll.dll, I tested the same thing and to my surprise I got a frames/sec lower than with Autoit's _ScreenCapture_Capture() function....I got a 1.43 fps and it also uses 100% of the CPU, with a picture quality of 25%...:)

TeamViewer manages to take very good pictures and also it doesn't use mode than 25% of my CPU, witch is...wow...this is what I try to recreate...somehow...perhaps with some help.

Local $file = @ScriptDir & "\screencap.png"
$Loops = 10
$dllCap = DllOpen(@ScriptDir & "\captdll.dll")
$begin = TimerInit()

For $i = 1 to $Loops
    DllCall($dllCap, "int:cdecl", "CaptureScreen", "str", $file, "int", 25)
Next

ConsoleWrite("Number of pictures taken in a second: "&round($Loops/(TimerDiff($begin)/1000),2)&@CRLF)

DllClose($dllCap)
Edited by darzanmihai

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Link to comment
Share on other sites

Using LAzyCat's dll, captdll.dll, I tested the same thing and to my surprise I got a frames/sec lower than with Autoit's _ScreenCapture_Capture() function....I got a 1.43 fps and it also uses 100% of the CPU, with a picture quality of 25%...:)

TeamViewer manages to take very good pictures and also it doesn't use mode than 25% of my CPU, witch is...wow...this is what I try to recreate...somehow...perhaps with some help.

Local $file = @ScriptDir & "\screencap.png"
$Loops = 10
$dllCap = DllOpen(@ScriptDir & "\captdll.dll")
$begin = TimerInit()

For $i = 1 to $Loops
    DllCall($dllCap, "int:cdecl", "CaptureScreen", "str", $file, "int", 25)
Next

ConsoleWrite("Number of pictures taken in a second: "&round($Loops/(TimerDiff($begin)/1000),2)&@CRLF)

DllClose($dllCap)
#Include <ScreenCapture.au3>
_ScreenCapture_SaveImage_Array_Start()
Local $file = @ScriptDir 
$Counter = 0
$begin = TimerInit()

Do
_ScreenCapture_Capture_Array($file & "\" & $Counter & ".jpg")
    $Counter += 1
    sleep(100)
Until TimerDiff($begin) >= 1000
SaveImage_Array()
_ScreenCapture_SaveImage_Array_Shutdown()



Func SaveImage_Array()
For $i = 1 To $ImagesArray[0][0] Step 1
$sFileName2 = $ImagesArray[$i][1] 
$hBitmap2 =$ImagesArray[$i][2]
 _ScreenCapture_SaveImage($sFileName2, $hBitmap2)
Next
EndFunc




Func _ScreenCapture_SaveImage_Array_Start()
Global $ImagesArray[1][3]
$ImagesArray[0][0] = 0
EndFunc

Func _ScreenCapture_SaveImage_Array_Shutdown()
Global $ImagesArray = ""
EndFunc
Func _ScreenCapture_Capture_Array($sFileName = "", $iLeft = 0, $iTop = 0, $iRight = -1, $iBottom = -1, $fCursor = True)
    Local $iH, $iW, $hWnd, $hDDC, $hCDC, $hBMP, $aCursor, $aIcon, $hIcon

    If $iRight = -1 Then $iRight = _WinAPI_GetSystemMetrics($__SCREENCAPTURECONSTANT_SM_CXSCREEN)
    If $iBottom = -1 Then $iBottom = _WinAPI_GetSystemMetrics($__SCREENCAPTURECONSTANT_SM_CYSCREEN)
    If $iRight < $iLeft Then Return SetError(-1, 0, 0)
    If $iBottom < $iTop Then Return SetError(-2, 0, 0)

    $iW = $iRight - $iLeft
    $iH = $iBottom - $iTop
    $hWnd = _WinAPI_GetDesktopWindow()
    $hDDC = _WinAPI_GetDC($hWnd)
    $hCDC = _WinAPI_CreateCompatibleDC($hDDC)
    $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iW, $iH)
    _WinAPI_SelectObject($hCDC, $hBMP)
    _WinAPI_BitBlt($hCDC, 0, 0, $iW, $iH, $hDDC, $iLeft, $iTop, $__SCREENCAPTURECONSTANT_SRCCOPY)

    If $fCursor Then
        $aCursor = _WinAPI_GetCursorInfo()
        If $aCursor[1] Then
            $hIcon = _WinAPI_CopyIcon($aCursor[2])
            $aIcon = _WinAPI_GetIconInfo($hIcon)
            _WinAPI_DrawIcon($hCDC, $aCursor[3] - $aIcon[2] - $iLeft, $aCursor[4] - $aIcon[3] - $iTop, $hIcon)
            _WinAPI_DestroyIcon($hIcon)
        EndIf
    EndIf

    _WinAPI_ReleaseDC($hWnd, $hDDC)
    _WinAPI_DeleteDC($hCDC)
    If $sFileName = "" Then Return $hBMP
    $ImagesArray[0][1] = "sFileName"
    $ImagesArray[0][2] = "hBMP"
    ReDim $ImagesArray[$ImagesArray[0][0] + 2][3]
    $ImagesArray[$ImagesArray[0][0] + 1][1] = $sFileName
    $ImagesArray[$ImagesArray[0][0] + 1][2] = $hBMP
    $ImagesArray[0][0] = $ImagesArray[0][0] + 1
EndFunc   ;==>_ScreenCapture_Capture

صرح السماء كان هنا

 

Link to comment
Share on other sites

Very nice script wolf9228, but the overall time is the same, althought it takes 10 pictures/sec, it takes about 5 more seconds to write to disk(for my computer)...so, one ideea would be not to write to disk, but directly send pictures before writting to disk, and still it uses 100% CPU and alot of memory.

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Link to comment
Share on other sites

My question is why you need to be able to capture screenshots and I quote:

I whant it to work no matter what the computer/network configuration is.

and

-The screen shots need to be as small as posible...something as 3-4 kB (I think this would be great)

and

First of all how could I send ScreenShots from one computer to anotherone by just using an ID and a Password, without using the IP? Perhaps through a server, but how?

Ummm, Can you explain your REAL reason for wanting this? You are STRONGLY implying something that will be used for bad purposes. Trying to bypass IP? Why do that? To get past a firewall?

Either you are trying to be a Big brother type, or you are to steal information from someone's PC. It is as if you want something you don't want noticed by the user, but can watch them all you want. Sorry, but this is giving me the creeps.

Link to comment
Share on other sites

My question is why you need to be able to capture screenshots and I quote:

and

and

Ummm, Can you explain your REAL reason for wanting this? You are STRONGLY implying something that will be used for bad purposes. Trying to bypass IP? Why do that? To get past a firewall?

Either you are trying to be a Big brother type, or you are to steal information from someone's PC. It is as if you want something you don't want noticed by the user, but can watch them all you want. Sorry, but this is giving me the creeps.

:):lmao::think:

I have amused myself to death. Ok. My real intentions are as I mentioned above, and now I will explain them:

I whant it to work no matter what the computer/network configuration is.

---I do not whant it to be configurable, just like TeamViewer, because I work at a company for witch I have created a software that they use alot and many persons use it, and I am not in the same city as they are and I am tired of talking at the phone with them and trying to gues what is rong.

By creating this soft I will just send it and nobody will have to configure anything.

-The screen shots need to be as small as posible...something as 3-4 kB (I think this would be great)

- by decreasing the size as much as posible you will gain speed and as I mentioned in my first post (I think) I need it to work great for internet connection throught modem (90% of the employees have laptops with Orange modems for flexibility)

First of all how could I send ScreenShots from one computer to anotherone by just using an ID and a Password, without using the IP? Perhaps through a server, but how?

- I think this is the best/easiest way for the user...and I haven't mentioned nothing about :

noticed by the user

And the final reason is that it would be a great thing for me and everybody that helps me to leave for the Autoit comunity.

As I finished this reply I became angry of the thought that you thought of that!

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Link to comment
Share on other sites

You still would have to save a temporary file before sending it.

Not realy...I have modified the script wolf9228 posted:

#Include <ScreenCapture.au3>
_ScreenCapture_SaveImage_Array_Start()
Local $file = @ScriptDir
$Counter = 0

_GDIPlus_StartUp()
$begin = TimerInit()
Do
    _ScreenCapture_Capture_Array($file & "\" & $Counter & ".png")
    SaveImage_Array()
    $Counter += 1
Until TimerDiff($begin) >= 1000
$a=TimerDiff($begin)/1000
ConsoleWrite("Number of pictures taken and saved in a second: "&round($Counter/$a,2)&@CRLF&"Time spent: "&round($a,2)&@CRLF)

_GDIPlus_ShutDown()

_ScreenCapture_SaveImage_Array_Shutdown()


Func SaveImage_Array()
For $i = 1 To $ImagesArray[0][0] Step 1
$sFileName2 = $ImagesArray[$i][1]
$hBitmap2 =$ImagesArray[$i][2]
 _ScreenCapture_SaveImage_New($sFileName2, $hBitmap2)
Next
EndFunc

Func _ScreenCapture_SaveImage_Array_Start()
Global $ImagesArray[1][3]
$ImagesArray[0][0] = 0
EndFunc

Func _ScreenCapture_SaveImage_Array_Shutdown()
Global $ImagesArray = ""
EndFunc

Func _ScreenCapture_Capture_Array($sFileName = "", $iLeft = 0, $iTop = 0, $iRight = -1, $iBottom = -1, $fCursor = True)
    Local $iH, $iW, $hWnd, $hDDC, $hCDC, $hBMP, $aCursor, $aIcon, $hIcon

    If $iRight = -1 Then $iRight = _WinAPI_GetSystemMetrics($__SCREENCAPTURECONSTANT_SM_CXSCREEN)
    If $iBottom = -1 Then $iBottom = _WinAPI_GetSystemMetrics($__SCREENCAPTURECONSTANT_SM_CYSCREEN)
    If $iRight < $iLeft Then Return SetError(-1, 0, 0)
    If $iBottom < $iTop Then Return SetError(-2, 0, 0)

    $iW = $iRight - $iLeft
    $iH = $iBottom - $iTop
    $hWnd = _WinAPI_GetDesktopWindow()
    $hDDC = _WinAPI_GetDC($hWnd)
    $hCDC = _WinAPI_CreateCompatibleDC($hDDC)
    $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iW, $iH)
    _WinAPI_SelectObject($hCDC, $hBMP)
    _WinAPI_BitBlt($hCDC, 0, 0, $iW, $iH, $hDDC, $iLeft, $iTop, $__SCREENCAPTURECONSTANT_SRCCOPY)

    If $fCursor Then
        $aCursor = _WinAPI_GetCursorInfo()
        If $aCursor[1] Then
            $hIcon = _WinAPI_CopyIcon($aCursor[2])
            $aIcon = _WinAPI_GetIconInfo($hIcon)
            _WinAPI_DrawIcon($hCDC, $aCursor[3] - $aIcon[2] - $iLeft, $aCursor[4] - $aIcon[3] - $iTop, $hIcon)
            _WinAPI_DestroyIcon($hIcon)
        EndIf
    EndIf

    _WinAPI_ReleaseDC($hWnd, $hDDC)
    _WinAPI_DeleteDC($hCDC)
    If $sFileName = "" Then Return $hBMP
    $ImagesArray[0][1] = "sFileName"
    $ImagesArray[0][2] = "hBMP"
    ReDim $ImagesArray[$ImagesArray[0][0] + 2][3]
    $ImagesArray[$ImagesArray[0][0] + 1][1] = $sFileName
    $ImagesArray[$ImagesArray[0][0] + 1][2] = $hBMP
    $ImagesArray[0][0] = $ImagesArray[0][0] + 1
EndFunc ;==>_ScreenCapture_Capture

Func _ScreenCapture_SaveImage_New($sFileName, $hBitmap, $fFreeBmp = True)
    Local $hClone, $sCLSID, $tData, $sExt, $hImage, $pParams, $tParams, $iResult, $iX, $iY
    If @error Then Return SetError(-1, -1, False)

    $sExt = StringUpper(_GDIPlus_ExtractFileExt($sFileName))
    $sCLSID = _GDIPlus_EncodersGetCLSID($sExt)
    If $sCLSID = "" Then Return SetError(-2, -2, False)
    $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)
    If @error Then Return SetError(-3, -3, False)
    
;$hImage    would be the var that would need to be directly sent
;$r = _Send_ImageBitmap($hImage);not made yet

    If IsDllStruct($tParams) Then $pParams = DllStructGetPtr($tParams)
    $iResult = _GDIPlus_ImageSaveToFileEx($hImage, $sFileName, $sCLSID, $pParams)
    
    _GDIPlus_ImageDispose($hImage)
    If $fFreeBmp Then _WinAPI_DeleteObject($hBitmap)
    Return SetError($iResult, 0, $iResult = 0)
EndFunc ;==>_ScreenCapture_SaveImage

I have modified so it will work only with .png files and it works a bit faster than other methods I tried.

In the _ScreenCapture_SaveImage_New() function it could be implemented another function to remotely send $hImage and recreate it by the remote computer, but the problem is that I have no clue about what kind of data is stored by $hImage and how it should be handled.

So, as it takes pictures it sends them without writting to disk...in theory

Edited by darzanmihai

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Link to comment
Share on other sites

:):lmao::think:

I have amused myself to death. Ok. My real intentions are as I mentioned above, and now I will explain them:

---I do not whant it to be configurable, just like TeamViewer, because I work at a company for witch I have created a software that they use alot and many persons use it, and I am not in the same city as they are and I am tired of talking at the phone with them and trying to gues what is rong.

By creating this soft I will just send it and nobody will have to configure anything.

- by decreasing the size as much as posible you will gain speed and as I mentioned in my first post (I think) I need it to work great for internet connection throught modem (90% of the employees have laptops with Orange modems for flexibility)

- I think this is the best/easiest way for the user...and I haven't mentioned nothing about :

And the final reason is that it would be a great thing for me and everybody that helps me to leave for the Autoit comunity.

As I finished this reply I became angry of the thought that you thought of that!

Ok, valid reasons. I can live with that. You should understand your typing and grammar are somewhat hard to read. I take it English is not your first language. We have had many post in the past with folks trying to make keyloggers and screen loggers who were really intent on stealing. I'm not implying that is your intent. You have explained it is for a business purpose and your case makes sense. Saying that....

Have you looked into VNC? You can make a simple install package that they run and it sets itself. If should do what you need.

Edited by Volly
Link to comment
Share on other sites

Ok, valid reasons. I can live with that.

Have you looked into VNC? YOu can make a simple install package that they run and it sets itself. If should do what you need.

Yes, but it would be nice to make something functional with Autoit...besides, I think this is why we all love AutoIt, because its new and you can never learn it all and you can never get tired of making things with it.

For the moment I'm using TeamViewer and it's ok because you can do anything you like for 15-30 minutes and then you reconect..no problem, but how about making it in Autoit...it's the perfect opportunity for me to learn more Autoit.

I do not like stupid and idiot people that write idiot things...If you are one, do not write.

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...