#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=..\My Pictures\11.ico
#AutoIt3Wrapper_outfile=截图.exe
#AutoIt3Wrapper_Res_Comment=CNSNC
#AutoIt3Wrapper_Res_Description=截图工具
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <Constants.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <ScreenCapture.au3>
FileInstall("Screen_Capture.ini",@ScriptDir&"\Screen_Capture.ini",0)
Opt("GUIOnEventMode", 1)
Opt("TrayMenuMode", 1)
Opt("TrayOnEventMode", 1)
Opt("MustDeclareVars",1)
Global $form[2], $Button[3], $Group[3], $Input[2], $Label[10], $combo[4], $ctrl_check[3], $alt_Check[3], $Radio[4], $hotkey[3], $MenuItem[4], $i
Global $Slider1,$trayitem[2],$pic_savename
Global Const $Inipath=@ScriptDir&"\Screen_Capture.ini"
$form[0] = GUICreate("设置", 294, 385, @DesktopWidth - 295, @DesktopHeight - 415,$WS_SYSMENU)
$Button[0] = GUICtrlCreateButton("确 认", 32, 328, 73, 25, 0)
$Button[1] = GUICtrlCreateButton("取 消", 186, 328, 73, 25, 0)
$Group[0] = GUICtrlCreateGroup("热键设置", 6, 2, 278, 102)
$Label[0] = GUICtrlCreateLabel("全屏截图", 12, 20, 60, 15)
$ctrl_check[0] = GUICtrlCreateCheckbox("CTRL", 90, 16)
$alt_Check[0] = GUICtrlCreateCheckbox("ALT", 154, 16)
$combo[0] = GUICtrlCreateCombo("", 204, 14, 72, 20)
$combo[1] = GUICtrlCreateCombo("", 204, 44, 72, 20)
$combo[2] = GUICtrlCreateCombo("", 204, 72, 72, 20)
$ctrl_check[1] = GUICtrlCreateCheckbox("CTRL", 90, 46)
$alt_Check[1] = GUICtrlCreateCheckbox("ALT", 154, 46)
$Label[1] = GUICtrlCreateLabel("区域截图", 12, 50)
$Label[2] = GUICtrlCreateLabel("窗口截图", 12, 78)
$ctrl_check[2] = GUICtrlCreateCheckbox("CTRL", 90, 74)
$alt_Check[2] = GUICtrlCreateCheckbox("ALT", 154, 74)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group[1] = GUICtrlCreateGroup("图像格式", 6, 110, 278, 129)
$Radio[0] = GUICtrlCreateRadio("PNG", 12, 130, 50, 17)
$Radio[1] = GUICtrlCreateRadio("GIF", 12, 155, 50, 17)
$Radio[2] = GUICtrlCreateRadio("JPEG", 12, 180, 50, 17)
$Radio[3] = GUICtrlCreateRadio("BMP", 12, 210, 50, 17)
$Slider1 = GUICtrlCreateSlider(135, 180, 140, 25, $TBS_NOTICKS)
GUICtrlSetOnEvent(-1, "gui")
$combo[3] = GUICtrlCreateCombo("", 136, 210, 140, 25)
GUICtrlSetData(-1, "16 bpp; 5 bits|24 bpp; 8 bits|32 bpp; 8 bits")
$Label[3] = GUICtrlCreateLabel("图像质量" , 70, 182, 56, 30)
$Label[4] = GUICtrlCreateLabel("BMP格式", 70, 212, 56, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group[2] = GUICtrlCreateGroup("图片保存", 6, 245, 278, 75)
$Input[1] = GUICtrlCreateInput("", 12, 260, 80, 21)
$Label[5] = GUICtrlCreateLabel("文件名,程序自动后缀时间", 101, 272)
$Input[0] = GUICtrlCreateInput("", 12, 292, 204, 21)
$Button[2] = GUICtrlCreateButton("浏览", 220, 292, 55, 21, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_HIDE)
For $i=0 to 2
GUICtrlSetOnEvent($Button[$i], "gui")
GUICtrlSetData($combo[$i], "F1|F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|1|2|3|4|5|6|7|8|9|0|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z")
Next
GUISetOnEvent(-3, "gui")
$trayitem[0] = TrayCreateItem("设置")
TrayCreateItem("")
$trayitem[1] = TrayCreateItem("退出")
TraySetState()
TrayItemSetOnEvent($trayitem[0], "tray")
TrayItemSetOnEvent($trayitem[1], "tray")
TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "tray")
TraySetClick(8)
_guilaoddata()
While 1
While 1
Sleep(300)
WEnd
WEnd
Func gui()
Local $path,$array
Switch @GUI_CtrlId
Case $Slider1
GUICtrlSetData($Label[3],"图像质量:"&@CRLF&GUICtrlRead($Slider1))
Case $Button[0]
GUISetState(@SW_HIDE)
_save_n_resethk()
Case $Button[1],-3
GUISetState(@SW_HIDE)
_guilaoddata()
Case $Button[2]
$path = FileSelectFolder("选择图片保存目录","",1)
If $path <> "" Then GUICtrlSetData($Input[0], $path)
Case $GUI_EVENT_PRIMARYUP
$array = WinGetPos($form[1])
GUICtrlSetData($Label[7], "座标:" & $array[0] & "," & $array[1])
GUICtrlSetData($Label[8], "大小:" & $array[2] & "," & $array[3])
Case $GUI_EVENT_SECONDARYUP
GUISetState(@SW_HIDE,$form[1])
GUIDelete($form[1])
EndSwitch
EndFunc ;==>gui
Func _guilaoddata()
Local $rd_data, $combo_data[3]
Local $path_data=IniRead($Inipath, "config", "Savepath","")
Local $path_=@MyDocumentsDir
For $i = 0 To 2
If IniRead($Inipath, "config", "Ctrl_check" & $i, "") = 1 Then GUICtrlSetState($ctrl_check[$i], $GUI_CHECKED)
If IniRead($Inipath, "config", "alt_check" & $i, "") = 1 Then GUICtrlSetState($alt_Check[$i], $GUI_CHECKED)
$combo_data[$i] = IniRead($Inipath, "config", "combo" & $i, "9")
If $combo_data[$i] <> "" Then GUICtrlSetData($combo[$i], $combo_data[$i])
$hotkey[$i] = IniRead($Inipath, "config", "hotkey" & $i, "")
HotKeySet($hotkey[$i], "_myhotkeyfunc" & $i)
Next
$rd_data = IniRead($Inipath, "config", "Picformat", "2")
GUICtrlSetState($Radio[$rd_data], $GUI_CHECKED)
GUICtrlSetData($Slider1, IniRead($Inipath, "config", "Jpegquality", "100"))
GUICtrlSetData($combo[3], IniRead($Inipath, "config", "Bmpformat", "24 bpp; 8 bits"))
If $path_data="" Then IniWrite($Inipath, "config", "Savepath",$path_)
GUICtrlSetData($Input[0], IniRead($Inipath, "config", "Savepath", $path_))
GUICtrlSetData($Input[1], IniRead($Inipath, "config", "Filename", "MyScreenCap"))
EndFunc ;==>_guilaoddata
Func _save_n_resethk()
Local $hotkey_old[3], $ctrl_Check_[3], $alt_check_[3], $combo_[3]
For $i = 0 To 2
$hotkey_old[$i] = IniRead($Inipath, "config", "hotkey" & $i, "")
HotKeySet($hotkey_old[$i])
If GUICtrlRead($ctrl_check[$i]) = 1 Then
$ctrl_Check_[$i] = "^"
IniWrite($Inipath, "config", "ctrl_Check" & $i, "1")
Else
$ctrl_Check_[$i] = ""
IniWrite($Inipath, "config", "ctrl_Check" & $i, "0")
EndIf
If GUICtrlRead($alt_Check[$i]) = 1 Then
$alt_check_[$i] = "!"
IniWrite($Inipath, "config", "Alt_check" & $i, "1")
Else
$alt_check_[$i] = ""
IniWrite($Inipath, "config", "Alt_check" & $i, "0")
EndIf
$combo_[$i] = GUICtrlRead($combo[$i])
IniWrite($Inipath, "config", "Combo" & $i, $combo_[$i])
$hotkey[$i] = $ctrl_Check_[$i] & $alt_check_[$i] & "{" & $combo_[$i] & "}"
IniWrite($Inipath, "config", "Hotkey" & $i, $hotkey[$i])
If GUICtrlRead($Radio[$i]) = 1 Then IniWrite($Inipath, "config", "Picformat", $i)
Next
If GUICtrlRead($Radio[3]) = 1 Then IniWrite($Inipath, "config", "Picformat", "3")
IniWrite($Inipath, "config", "Jpegquality", GUICtrlRead($Slider1))
IniWrite($Inipath, "config", "Bmpformat", GUICtrlRead($combo[3]))
IniWrite($Inipath, "config", "Savepath", GUICtrlRead($Input[0]))
IniWrite($Inipath, "config", "Filename", GUICtrlRead($Input[1]))
If $hotkey[0]<>$hotkey[1] And $hotkey[0]<>$hotkey[2] And $hotkey[1]<>$hotkey[2] Then
For $i=0 to 2
HotKeySet($hotkey[$i], "_myhotkeyfunc" & $i)
Next
Else
MsgBox(48,"热键冲突","热键冲突,请重新设置")
GUISetState(@SW_SHOW)
EndIf
EndFunc ;==>_save_n_resethk
Func _myhotkeyfunc0()
_ScreenCapture_Capture(_format_n_savename())
EndFunc ;==>_myhotkeyfunc0
Func _myhotkeyfunc1()
If IsHWnd($form[1]) Then GUIDelete($form[1])
$form[1] = GUICreate("", 408, 308, -1, -1, BitOR($WS_SIZEBOX, $WS_THICKFRAME, $WS_POPUP), _
BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_WINDOWEDGE))
WinSetTrans($form[1], "", 80)
GUISetBkColor(0x00FFFF)
$Label[6] = GUICtrlCreateLabel("", 0, 0, 408, 308, -1, $GUI_WS_EX_PARENTDRAG)
$Label[7] = GUICtrlCreateLabel("", 0, 0, 100, 17)
GUICtrlSetFont(-1, 10, 800, 2, "MS Sans Serif")
GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
$Label[8] = GUICtrlCreateLabel("", 315, 290, 100, 17)
GUICtrlSetFont(-1, 10, 800, 2, "MS Sans Serif")
GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKBOTTOM + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
GUISetOnEvent($GUI_EVENT_PRIMARYUP, "gui")
GUIRegisterMsg($WM_COMMAND, "Dclick_Rectcap")
GUISetOnEvent($GUI_EVENT_SECONDARYUP, "gui")
GUISetState(@SW_SHOW)
EndFunc ;==>_myhotkeyfunc1
Func _myhotkeyfunc2()
Local $winhwnd=DllCall("User32.dll", "hwnd", "GetForegroundWindow")
_ScreenCapture_CaptureWnd(_format_n_savename(), $winhwnd[0])
EndFunc ;==>_myhotkeyfunc2
Func Dclick_Rectcap($hWnd, $Msg, $wParam, $lParam)
Local $nNotifyCode = BitShift($wParam, 16)
Local $nID = BitAND($wParam, 0xFFFF)
If $nID = $Label[6] And $nNotifyCode = 1 Then
GUISetState(@SW_HIDE,$form[1])
_ScreenCapture_CaptureWnd(_format_n_savename(), $Form[1],0, 0, -1, -1, False)
GUISetState(@SW_SHOW,$form[1])
EndIf
EndFunc ;==>Dclick_Rectcap
Func _format_n_savename()
Local $extendedname,$iformat
Local $savepath=IniRead($Inipath,"Config","Savepath",@MyDocumentsDir)
Local $filename=IniRead($Inipath,"Config","Filename","MyScreenCap")
Local $picformat=IniRead($Inipath,"Config","Picformat","2")
Local $Jpegquality=IniRead($Inipath, "config", "Jpegquality", "100")
Local $Bmpformat=IniRead($Inipath, "config", "Bmpformat", "24 bpp; 8 bits")
Switch $Bmpformat
Case "16 bpp; 5 bits"
$iformat=0
Case "32 bpp; 8 bits"
$iformat=3
Case Else
$iformat=2
EndSwitch
Switch $picformat
Case 0
$extendedname="png"
case 1
$extendedname="gif"
case 2
$extendedname="jpeg"
_ScreenCapture_SetJPGQuality($Jpegquality)
case 3
$extendedname="bmp"
_ScreenCapture_SetBMPFormat($iformat)
EndSwitch
$pic_savename=$savepath&""&$filename&@HOUR&"-"&@MIN&"-"&@SEC&"."&$extendedname
SoundPlay ("D:\My Documents\My Music\Capture.wav")
return $pic_savename
EndFunc
Func tray()
Switch @TRAY_ID
Case $trayitem[0],$TRAY_EVENT_PRIMARYDOUBLE
GUISetState(@SW_SHOW, $form[0])
Case $trayitem[1]
Exit
EndSwitch
EndFunc ;==>tray
以前有人发的,不好意思,没记谁发的了。。其实我更推荐用QQ的截图,比较成熟哦,楼主有兴趣的话,去搜一搜,好几个呢,三恨都发过修改的呢。。