Autohotkey 使用自动热键监视CPU和发送电子邮件
我正在尝试设置一个自动电子邮件,如果条件满足。我试着观察我的cpu负载。如果通过或放弃一个号码,发送电子邮件Autohotkey 使用自动热键监视CPU和发送电子邮件,autohotkey,Autohotkey,我正在尝试设置一个自动电子邮件,如果条件满足。我试着观察我的cpu负载。如果通过或放弃一个号码,发送电子邮件 CheckCPULoad: 协作模式、工具提示、屏幕 SetFormat,浮点,0.0 CPULoad:=GetCPULoad_Short() 工具提示,CPULoad=%CPULoad%%,0,%A\u屏幕高度% 返回 GetCPULoad_Short() { Static IdleTime, Tick global ProcessorCount SetBatchLines, -1
CheckCPULoad:
协作模式、工具提示、屏幕
SetFormat,浮点,0.0
CPULoad:=GetCPULoad_Short()
工具提示,CPULoad=%CPULoad%
%,0,%A\u屏幕高度%
返回
GetCPULoad_Short()
{
Static IdleTime, Tick
global ProcessorCount
SetBatchLines, -1
OldIdleTime = %IdleTime%
OldTick = %Tick%
VarSetCapacity( IdleTicks,8,0)
DllCall("kernel32.dll\GetSystemTimes", "uint",&IdleTicks, "uint",0, "uint",0)
IdleTime := *(&IdleTicks)
Loop 7
IdleTime += *( &IdleTicks + A_Index ) << ( 8 * A_Index )
Tick := A_TickCount
Return 100 - 0.01*(IdleTime - OldIdleTime)/(Tick - OldTick) / ProcessorCount
}
#############
#IfEqual, CPUload, 0,
#or
if (CPUload = 0)
{
IfWinNotExist Inbox - Email@Email.com - Outlook
return ; Outlook isn't open to the right section, so do nothing.
WinActivate ; Activate the window found by the above command.
Send ^n ; Create new/blank e-mail via Control+N.
WinWaitActive Untitled - Message (HTML)
Send, sentEmailto@help.com
Send {Tab 3} computer has stopped ; Set the subject line.
Send {Tab} more txt. ; etc.
return ; This line serves to finish the hotkey.
}
GetCPULoad_Short()
{
静态空闲时间
全球处理器计数
设置行,-1
OldIdleTime=%IdleTime%
OldTick=%Tick%
可变容量(怠速,8,0)
DllCall(“kernel32.dll\GetSystemTimes”、“uint”和IdleTicks、“uint”、0、“uint”、0)
空闲时间:=*(&IdleTicks)
环路7
IdleTime+=*(&IdleTicks+A_Index)这篇文章让我好奇,想看看以前是否做过这件事,我立即在ahkscript论坛上找到了一个解决方案:
Loop {
If (CPULoad() > 25) ; Assign the Number you want.
; Your EMAIL Code here! If MultiLine Use {...code...}
Sleep 250
}
CPULoad() { ; By SKAN, CD:22-Apr-2014 / MD:05-May-2014. Thanks to ejor, Codeproject: http://goo.gl/epYnkO
Static PIT, PKT, PUT ; http://ahkscript.org/boards/viewtopic.php?p=17166#p17166
IfEqual, PIT,, Return 0, DllCall( "GetSystemTimes", "Int64P",PIT, "Int64P",PKT, "Int64P",PUT )
DllCall( "GetSystemTimes", "Int64P",CIT, "Int64P",CKT, "Int64P",CUT )
, IdleTime := PIT - CIT, KernelTime := PKT - CKT, UserTime := PUT - CUT
, SystemTime := KernelTime + UserTime
Return ( ( SystemTime - IdleTime ) * 100 ) // SystemTime, PIT := CIT, PKT := CKT, PUT := CUT
}
您正在这台计算机上使用Outlook,它已启动并运行?请注意,AutoHotKey可能不是管理性能警报的最佳方式…是的,它已启动并运行..这只是一个测试,看看它是否对我们有帮助。我们一定会研究其他选项..有什么建议?关于开源,可以查看cpu并在条件允许时发送警报metWe使用datadoghq.com的付费版本,尽管有一个免费版本可能适合您。嘿,我会使用一个内置的批处理文件,它可以测量指定时间段内的CPU负载,以及一些命令行电子邮件实用程序,如BLAT.BTW。您的语法很时髦:什么是#IfEqual
和#或
?您是否使用了一些NonSa是的,这确实允许我给CPUload分配一个号码。谢谢你找到这个