Process loading and script loading - who wins?

Get help with using AutoHotkey and its commands and hotkeys

Process loading and script loading - who wins?

24 Sep 2018, 08:45


Have a strange issue, tried looping the whole thing, rearranging etc, but no luck. I have this script:

Code: Select all

Loop {

CoordMode, ToolTip, Screen

Process, Exist, skype.exe
PID := errorLevel
; IfEqual, PID, 0, ExitApp
SetTimer, ShowToolTip 

PrLoad := Round( GetProcessTimes(PID),2)
ToolTip %PrLoad%`%, 100,100
If (PrLoad > 9)
	Process, Close, skype.exe

GetProcessTimes( PID )    { 
   Static oldKrnlTime, oldUserTime 
   Static newKrnlTime, newUserTime 

   oldKrnlTime := newKrnlTime 
   oldUserTime := newUserTime 

   hProc := DllCall("OpenProcess", "Uint", 0x400, "int", 0, "Uint", pid) 
   DllCall("GetProcessTimes", "Uint", hProc, "int64P", CreationTime, "int64P"
           , ExitTime, "int64P", newKrnlTime, "int64P", newUserTime) 

   DllCall("CloseHandle", "Uint", hProc) 
Return (newKrnlTime-oldKrnlTime + newUserTime-oldUserTime)/10000000 * 100   

I borrowed parts of this code from around the net and modded a bit since my Skype (old version on Win10) starts to eat processor for some reason when I'm connected to VPN. Everything in this works when script is loaded after Skype is loaded, but not the other way around - if Skype is loaded after script, it just won't work and the load isn't shown on the ToolTip either. I'm sure there's a perfectly reasonable explanation for this but I just can't see it, so I'd really appreciate it if someone stuck my nose in it. Thanks!

Oh there's another small issue - the ToolTip shows twice the load that Process Explorer shows. I can cheat with the output but I'd also like to understand why it's like that, so if there's any guru outthere with couple of minutes of time, I'd appreciate that too, thanks!

All the best,

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], flyingDman, noscopermlg, Ortorin and 209 guests