用GDI+其实没什么意义,使用tmp文件还是比较具有稳定性的,从建立文件到读出字符串直至删除文件用不了一秒钟,且文件生成在temp文件夹内,代码实现也相当之简单!
先给你一个发送端的例子:
;修改UDF函数16行:Global $giJPGQuality = 10
;UDF 165行下加一行:If $sExt='tmp' Then $sExt='jpg'
#include 'ScreenCapture.au3'
UDPStartup()
While 1
$socket = UDPOpen("192.160.0.101", 65532)
If @error<>0 Then
Sleep(200)
Else
ExitLoop
EndIf
WEnd
AdlibEnable('sct',30000)
Func sct()
$tempfile = _TempFile()
_ScreenCapture_Capture($tempfile)
$file = FileOpen($tempfile, 16)
$str = FileRead($file)
FileClose($file)
FileDelete($tempfile)
$status = UDPSend($socket, $str)
EndFunc ;==>sct
While 1
Sleep(100)
WEnd
Func _TempFile($s_DirectoryName = @TempDir, $s_FilePrefix = "~", $s_FileExtension = ".tmp", $i_RandomLength = 7)
Local $s_TempName
; Check parameters
If Not FileExists($s_DirectoryName) Then $s_DirectoryName = @TempDir ; First reset to default temp dir
If Not FileExists($s_DirectoryName) Then $s_DirectoryName = @ScriptDir ; Still wrong then set to Scriptdir
; add trailing \ for directory name
If StringRight($s_DirectoryName, 1) <> "\" Then $s_DirectoryName = $s_DirectoryName & "\"
;
Do
$s_TempName = ""
While StringLen($s_TempName) < $i_RandomLength
$s_TempName = $s_TempName & Chr(Random(97, 122, 1))
WEnd
$s_TempName = $s_DirectoryName & $s_FilePrefix & $s_TempName & $s_FileExtension
Until Not FileExists($s_TempName)
Return ($s_TempName)
EndFunc ;==>_TempFile
|