CPU 使用 AutoHotKey 观看和发送电子邮件
CPU watch and email with AutoHotKey
我正在尝试设置满足条件时的自动电子邮件。我正在尝试观察我的 cpu 负荷。如果通过或掉落了一个号码,请发送电子邮件。
CheckCPULoad:
CoordMode, ToolTip, Screen
SetFormat, float, 0.0
CPULoad := GetCPULoad_Short()
ToolTip, CPULoad = %CPULoad%
%,0,%A_ScreenHeight%
return
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.
}
但我尝试了一个简单的
如果(CPULoad = 0)
消息框测试
而且它不会给我消息。为什么我可以显示一个消息框。或电子邮件发送?
这 post 让我很好奇以前是否有人这样做过,我立即在 ahkscript 论坛上 post 找到了解决方案:
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
}
我正在尝试设置满足条件时的自动电子邮件。我正在尝试观察我的 cpu 负荷。如果通过或掉落了一个号码,请发送电子邮件。
CheckCPULoad:
CoordMode, ToolTip, Screen
SetFormat, float, 0.0
CPULoad := GetCPULoad_Short()
ToolTip, CPULoad = %CPULoad%
%,0,%A_ScreenHeight%
return
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.
}
但我尝试了一个简单的
如果(CPULoad = 0) 消息框测试
而且它不会给我消息。为什么我可以显示一个消息框。或电子邮件发送?
这 post 让我很好奇以前是否有人这样做过,我立即在 ahkscript 论坛上 post 找到了解决方案:
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
}