关于捕获鼠标右键动作的问题请教
我在论坛搜到一段代码,用于实现鼠标右键点击时截屏并保存。但运行时CPU耗用基本是50%,有点吃力,我的CPU是intel 3.00Ghz的。请大家看看怎么改代码降低资源占用,谢谢#include <Misc.au3>
#include <ScreenCapture.au3>
#include <Misc.au3>
#Include <Date.au3>
HotKeySet("{f2}", "Terminate")
HotKeySet("{PRINTSCREEN}","CaptureR") ;截图热键"PRINTSCREEN"
Dim $i
Dim $str
dim $dateStr
$datestr=@year &@mon & @mday & "-"&@hour & @min& @sec
$dll = DllOpen("user32.dll")
DirCreate(@ScriptDir &"\cap\" & $datestr & "\右键")
While 1
If _IsPressed("02", $dll) Then
$i+=1
Call ("captureR")
sleep(100)
endif
WEnd
DllClose($dll)
Func CaptureR() ;全屏截图
Local $hpath=@ScriptDir &"\cap\" & $datestr & "\右键\" & $i & ".jpg" ;
$hBmp=_ScreenCapture_Capture("")
_ScreenCapture_SaveImage($hpath,$hBmp)
EndFunc
Func Terminate()
Exit 0
EndFunc 用 GUIRegisterMsg 注册 鼠标右键消息 我记得我做过一个的,要翻翻才知道了... #include <Misc.au3>
#include <ScreenCapture.au3>
HotKeySet('{f2}', '_Exit')
Local $i = 0, $dll = DllOpen('user32.dll')
Local $dateStr = @ScriptDir & '\cap\右键\' & @YEAR & @MON & @MDAY & '\'
DirCreate($dateStr)
While 1
Sleep(10)
If _IsPressed('02', $dll) Then _ScreenCapture_Capture($dateStr & @HOUR & @MIN & @SEC & '.jpg')
WEnd
Func _Exit()
DllClose($dll)
Exit
EndFunc ;==>_Exit 收到学习一下 关键在sleep(10)?
回家试试 老兄,你的方法太好了。CPU占用立马降到0-5%,而且还没发现有漏掉的。谢谢了
页:
[1]