是将剪贴板的内容写成位图文件?
#include <GuiConstantsEx.au3>
#include <ClipBoard.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
Global $iMemo
_Main()
Func _Main()
Local $hGUI, $btn_SetData, $btn_GetData, $hMemory, $tData, $iFormat
$hGUI = GUICreate("Clipboard", 400, 350)
$btn_SetData = GUICtrlCreateButton("抓图", 50, 310, 140, 30)
$btn_GetData = GUICtrlCreateButton("写入图片", 210, 310, 140, 30)
GUISetState()
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $btn_SetData
msgbox(0,0,"需要先抓图到剪贴板")
Case $btn_GetData
If Not _ClipBoard_Open($hGUI) Then _WinAPI_ShowError("_ClipBoard_Open failed")
$count = _ClipBoard_CountFormats()
For $i = 1 To $count
$iFormat = _ClipBoard_EnumFormats($iFormat)
If $iFormat <> 0 Then
$temp = _ClipBoard_FormatStr($iFormat)
If $temp="Bitmap" Then
$hMemory = _ClipBoard_GetDataEx($CF_bitmap)
If $hMemory = 0 Then _WinAPI_ShowError("_ClipBoard_GetDataEx failed")
_ClipBoard_Close()
_GDIPlus_Startup()
$hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hMemory)
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
_GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 0, 0)
_GDIPlus_ImageSaveToFile ($hBitmap, @ScriptDir & "\Explame_Image.jpg")
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_ImageDispose($hBitmap)
_WinAPI_DeleteObject($hMemory)
_GDIPlus_Shutdown()
ShellExecute(@ScriptDir & "\Explame_Image.jpg")
EndIf
EndIf
Next
EndSwitch
WEnd
EndFunc ;==>_Main
|