已解决 请教,写了个程序,窗口关不掉
本帖最后由 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 & "," & $aPos,1)
While 1
If _IsPressed("01", $dll) Then
$bPos = MouseGetPos()
;MsgBox(4096, "鼠标坐标 X,Y:", $bPos & "," & $bPos)
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 , $aPos, $bPos, $bPos)
EndFunc
Func xianshi()
Sleep(200)
GUICreate( "22.jpg" , $bPos-$aPos , $bPos-$aPos , $aPos , $aPos , -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-$aPos , $bPos-$aPos)
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 本帖最后由 mikezunya 于 2013-10-25 18:23 编辑
如果想点击窗口的X来关闭,以及隐藏的话,下午测试了 能力有限没实现,可以用HotKeySet弄个热键到AButton1Click()下,是可以实现你的要求。希望能对你有所帮助 ## 鼠标左右键同时按下开始截图,向右下角划出适当区域松开任意键指定范围
#include <Misc.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>
Opt('GUIOneventMode', 1)
Global $dll = DllOpen('user32.dll'), $bPos, $aPos, $hWnd
GUICreate('截图 V1.0', 55, 20, 88, 728, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_WINDOWEDGE));,$WS_POPUP无边框 ;创建主窗口
GUISetOnEvent(-3, '_Exit') ;当一个系统按钮被点击时调用一个用户自定义函数(UDF).
GUICtrlCreateButton('开始', 0, 0, 55, 20)
GUICtrlSetOnEvent(-1, 'AButton1Click');为指定控件的点击行为定义一个用户函数.
GUISetState() ;显示当前窗口
While 1
Sleep(100)
WEnd
Func AButton1Click()
AdlibRegister('_CKIsPressed')
EndFunc ;==>AButton1Click
Func _CKIsPressed()
If Not _IsPressed('01', $dll) Or Not _IsPressed('02', $dll) Then Return
AForm2Close()
$aPos = MouseGetPos()
While _IsPressed('01', $dll) And _IsPressed('02', $dll)
Sleep(1)
WEnd
$bPos = MouseGetPos()
If ($bPos - $aPos) <= 4 Or ($bPos - $aPos) <= 4 Then Return ;小于5*5不截图
Local $hpath = 'tmp.jpg'
_ScreenCapture_Capture($hpath, $aPos, $aPos, $bPos, $bPos)
If Not FileExists($hpath) Then Return MsgBox(48, '失败', '未成功截图')
$hWnd = GUICreate('', $bPos - $aPos, $bPos - $aPos, $aPos - 3, $aPos - 21, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_WINDOWEDGE));,$WS_POPUP无边框
GUISetOnEvent(-3, 'AForm2Close')
GUICtrlCreatePic($hpath, 0, 0, $bPos - $aPos + 1, $bPos - $aPos + 1)
GUISetState(@SW_SHOW)
FileDelete($hpath)
EndFunc ;==>_CKIsPressed
Func AForm2Close()
If IsHWnd($hWnd) Then GUIDelete($hWnd)
EndFunc ;==>AForm2Close
Func _Exit()
DllClose($dll)
Exit
EndFunc ;==>_Exit
本帖最后由 ainizm 于 2013-10-25 23:59 编辑
回复 3# afan
还是高手厉害,谢了,不过为什么对角中间老是出一条绿线,能解决吗
页:
[1]