Monitor cpu

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
conjure
Pro Scripter
Posts: 64
Joined: Thu Jan 12, 2012 3:05 pm

Monitor cpu

Post by conjure » Wed Jun 08, 2016 8:25 pm

Hi.i have several programs running on my PC, and i want to make a script that reads the CPU and if it stays 100% for 30 or more seconds, to stop some programs.I searched the forum but i didn't find a script that can show the CPU usage.
Is there a way to get the CPU percentage?

User avatar
JRL
Automation Wizard
Posts: 3531
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Monitor cpu

Post by JRL » Thu Jun 09, 2016 4:43 am


conjure
Pro Scripter
Posts: 64
Joined: Thu Jan 12, 2012 3:05 pm

Re: Monitor cpu

Post by conjure » Thu Jun 09, 2016 11:53 am

i Think this is easiest

Code: Select all


label>start
IfWindowOpen>Windows Task Manager
GetWindowText>Windows Task Manager,strText
Let>tmp0=(?m-s)^.*CPU.*%
RegEx>tmp0,strText,0,m,nm,0
If>nm>0
msg>m_1
endif
else
ExecuteFile>C:\Windows\System32\taskmgr.exe
wait>1
endif
wait>0.05
goto>start

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts