回复 7# xms77
算了,我请你看神仙妹妹,好嘛!
#NoTrayIcon
#Include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <Memory.au3>
#include <String.au3>
#include <GDIPlus.au3>
Global $SocketID
_SlidePicture()
Func _SlidePicture()
Local $hImage, $iWidth, $iHeight, $hGui
Local $sLink = "myarticle.enet.com.cn", $sPic = "/images/2007/0917/1189986155220/"
Opt("GUIOnEventMode", 1)
$hGui = GUICreate("Slide Picture", -1, -1, -1, -1, -1, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW))
GUISetState()
WinSetOnTop($hGui, "", 1)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_GuiOnEvent", $hGUI)
For $i = 1 To 6
_GDIPlus_Startup()
$hImage = _ImageFromNet($sLink, $sPic & $i & ".jpg")
$iWidth = _GDIPlus_ImageGetWidth($hImage)
$iHeight = _GDIPlus_ImageGetHeight($hImage)
WinMove($hGUI, "", -1, -1, $iWidth, $iHeight)
For $j = 0 to 255 step 1
_SetGuiBitmap($hGui, $hImage, $j)
Sleep(10)
Next
For $j = 255 to 0 step -1
_SetGuiBitmap($hGui, $hImage, $j)
Sleep(10)
Next
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
Next
GUIDelete($hGUI)
EndFunc
Func _ImageFromNet($sHost, $sSource)
Local $sIp, $sData, $sSocket, $sRecvHeader = "", $sRecvBin = "0x", $aRet
Local $iBytes, $mBitmap, $iLength, $hData, $pData, $tMem, $aResult
TCPStartup()
$sIp = TCPNameToIP($sHost)
$sData = "GET " & $sSource & " HTTP/1.1" & @Crlf & "Host: " & $sHost & @Crlf & @CRLF
$sSocket = TCPConnect ($sIp, 80)
TCPSend ($sSocket, $sData)
If @error Then Return Seterror(1, 1, 1)
Do
$sRecvHeader = TCPRecv($sSocket, 1)
Until $sRecvHeader <> ""
Do
$sRecvHeader &= TCPRecv($sSocket, 1)
Until StringInStr($sRecvHeader, @Crlf & @Crlf)
$aRet = _StringBetween($sRecvHeader, 'Content-Length: ', @Crlf )
If IsArray($aRet) Then
$iBytes = $aRet[0]
Do
$sRecvBin &= StringTrimLeft(TCPRecv($sSocket, 1024, 1 ), 2)
Until BinaryLen(Binary($sRecvBin)) >= $iBytes
TCPCloseSocket($sSocket)
TCPShutdown()
$mBitmap = Binary($sRecvBin)
$iLength = BinaryLen($mBitmap)
$hData = _MemGlobalAlloc ($iLength, $GMEM_MOVEABLE)
$pData = _MemGlobalLock ($hData)
$tMem = DllStructCreate ( "byte[" & $iLength & "]", $pData )
DllStructSetData ($tMem, 1, $mBitmap)
_MemGlobalUnlock ($hData)
$aResult = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "hwnd", $pData, "int", True, "ptr*", 0)
If @error Then Return SetError(@error, @extended, 0)
$aResult = DllCall ($ghGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $aResult[3], "int*", 0)
If @error Then Return SetError (@error, @extended, 0)
Return $aResult[2]
Else
TCPCloseSocket($SocketID)
TCPShutdown( )
Return Seterror(1, 1, 1)
EndIf
EndFunc
Func _SetGuiBitmap($hGUI, $hImage, $iTrans)
Local $hDC, $hCDC, $hBitmap, $hObj, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
$hDC = _WinAPI_GetDC(0)
$hCDC = _WinAPI_CreateCompatibleDC($hDC)
$hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
$hObj = _WinAPI_SelectObject($hCDC, $hBitmap)
$tSize = DllStructCreate($tagSIZE)
$pSize = DllStructGetPtr($tSize)
DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
$tSource = DllStructCreate($tagPOINT)
$pSource = DllStructGetPtr($tSource)
$tBlend = DllStructCreate($tagBLENDFUNCTION)
$pBlend = DllStructGetPtr($tBlend)
DllStructSetData($tBlend, "Alpha" , $iTrans)
DllStructSetData ($tBlend, "Format", 1)
_WinAPI_UpdateLayeredWindow($hGUI, $hDC, 0, $pSize, $hCDC, $pSource, 0, $pBlend, $ULW_ALPHA)
_WinAPI_ReleaseDC(0, $hDC)
_WinAPI_SelectObject($hCDC, $hObj)
_WinAPI_DeleteObject($hBitmap)
_WinAPI_DeleteDC($hCDC)
EndFunc
Func _GuiOnEvent()
ConsoleWrite("Hit Left key!" & @CRLF)
EndFunc
|