本帖最后由 ainizm 于 2013-10-25 23:56 编辑
做了个工具,现在程序有2问题,
1.剪贴后的窗口关不掉(用标题栏关);
2.我希望能剪贴图的窗口关掉后,程序不退出,鼠标热键能继续剪贴图
请教高手指点。
#include <Misc.au3>
#include <ScreenCapture.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOneventMode",1)
$WinMain = GUICreate("截图 V1.0", 55, 20, 88, 728, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE));,$WS_POPUP无边框 ;创建主窗口
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") ;当一个系统按钮被点击时调用一个用户自定义函数(UDF).
$Button0 = GUICtrlCreateButton("开始", 0, 0, 55, 20, 0)
GUICtrlSetOnEvent(-1, "AButton1Click");为指定控件的点击行为定义一个用户函数.
GUISetState(@SW_SHOW) ;显示当前窗口
Global $ScreenSaveToBit,$hpath,$bPos,$aPos,$hBmp,$hpath,$hWnd,$WinSub1,$I
$dll = DllOpen("user32.dll")
While 1
Sleep(100)
WEnd
Func AButton1Click()
While 1
Sleep ( 10 )
If _IsPressed("01", $dll) Then
If _IsPressed("02", $dll) Then
$aPos = MouseGetPos()
MsgBox(0, "鼠标坐标 X,Y:", $aPos[0] & "," & $aPos[1],1)
While 1
If _IsPressed("01", $dll) Then
$bPos = MouseGetPos()
;MsgBox(4096, "鼠标坐标 X,Y:", $bPos[0] & "," & $bPos[1])
jietu()
xianshi()
ExitLoop
EndIf
WEnd
EndIf
EndIf
WEnd
EndFunc
DllClose($dll)
Func jietu()
$hpath = "C:\Documents and Settings\Administrator\桌面\33.bmp"
; 当前窗口截图
$hBmp = _ScreenCapture_Capture($hpath, $aPos[0] , $aPos[1], $bPos[0], $bPos[1])
EndFunc
Func xianshi()
Sleep(200)
GUICreate( "22.jpg" , $bPos[0]-$aPos[0] , $bPos[1]-$aPos[1] , $aPos[0] , $aPos[1] , -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE));,$WS_POPUP无边框
GUISetOnEvent($GUI_EVENT_CLOSE, "AForm2Close")
FileInstall("C:\Documents and Settings\Administrator\桌面\33.bmp", "C:\Documents and Settings\Administrator\桌面\22.jpg");包含并装入指定文件到编译后的脚本程序中.FileInstall ( "源文件", "目标路径" [, 标志] )
GUICtrlCreatePic("C:\Documents and Settings\Administrator\桌面\22.jpg" , 0 , 0 , $bPos[0]-$aPos[0] , $bPos[1]-$aPos[1])
GUISetState(@SW_SHOW)
FileDelete("C:\Documents and Settings\Administrator\桌面\22.jpg")
EndFunc
Func AForm1Close()
Exit
EndFunc
Func AForm2Close()
FileDelete("C:\Documents and Settings\Administrator\桌面\22.jpg")
GUISetState(@SW_HIDE)
Exit
EndFunc
Func _Exit()
Exit
EndFunc |