本帖最后由 dtooboss 于 2010-4-16 01:15 编辑
回复 gyuwlsz
你先测试下看看有没有问题。
dtooboss 发表于 2010-4-16 00:34
服务端源码#include <ScreenCapture.au3>
#include <File.au3>
TCPStartup()
Global $TCPListen = TCPListen(@IPAddress1, 3825)
_ScreenCapture_SetJPGQuality(30)
$ScreenshotName = _TempFile(@TempDir, "test", ".jpg")
While 1
Do
$TCPAccept = TCPAccept($TCPListen)
Sleep(100)
Until $TCPAccept <> -1
While True
Sleep(50)
_ScreenCapture_Capture($ScreenshotName)
$ScreenshotHandle = FileOpen($ScreenshotName, 16)
$data = FileRead($ScreenshotHandle)
FileClose($ScreenshotHandle)
$data = NumtoBin(BinaryLen($data)) & $data
TCPSend($TCPAccept, $data)
If @error Then
ExitLoop
EndIf
WEnd
Sleep(50)
WEnd
防止干坏事省去六行
客户端源码#include<GDIPlus.au3>
#include<GuiConstantsex.au3>
#include <File.au3>
Opt("GUIONEVENTMODE", 1)
_GDIPlus_Startup()
TCPStartup()
$hGUI = GUICreate("test", 1024, 768)
GUISetOnEvent($GUI_EVENT_CLOSE, "quit")
GUISetState()
$Sip = InputBox("提示", "请输入远程机器的ip地址", "")
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$ScreenshotName = _TempFile(@TempDir, "test", ".jpg")
While 1
Sleep(50)
Global $TCPConnect = TCPConnect($Sip, 3825)
If $TCPConnect = -1 Then ContinueLoop
$TCPRecv = Binary("")
$timer = TimerInit()
While 1
Sleep(50)
Local $k = TCPRecv($TCPConnect, 20000000, 0)
If @error Then
ExitLoop
EndIf
If $k Then
$TCPRecv = $TCPRecv & $k
If BinaryLen($TCPRecv) < 4 Then ContinueLoop
If BinaryLen($TCPRecv) >= BintoNum(BinaryMid($TCPRecv, 1, 4)) + 4 And BintoNum(BinaryMid($TCPRecv, 1, 4)) + 4 > 0 Then
$ScreenshotHandle = FileOpen($ScreenshotName, 18)
FileWrite($ScreenshotHandle, BinaryMid($TCPRecv, 5))
FileClose($ScreenshotHandle)
$hBitmap = _GDIPlus_BitmapCreateFromFile($ScreenshotName)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, 1024, 768)
_GDIPlus_BitmapDispose($hBitmap)
FileDelete($ScreenshotName)
$TCPRecv = BinaryMid($TCPRecv, 5 + BintoNum(BinaryMid($TCPRecv, 1, 4)))
$timer = TimerInit()
EndIf
EndIf
WEnd
WEnd
防止干坏事省去六行
Func quit()
Exit
EndFunc
在需要监控的机器上运行 服务端
在你的机器上运行 客户端 |