changing from Win7 to WIn10 i noted that the CPU Usage of my tool is greatly increasing (about <1% to 10-15%).
I use a timer function which repeatly calls WinExist() or IfWinExist.
Below a demo code (cant show the whole code).
I know that there a a lot of If-then-else clause combined partially with regex and detecthiddenwindows, but as it works really fine on Win7, why there is such a CPU Usage on Win10?
Has anyone same experiences with Win10 (or a solution)?
Code: Select all
SetTimer, timerevent, 1000
return
timerevent:
SetTimer, timerevent, OFF
IfWinExist, MyWindowtoCheck
{
} else if WinExist("AnotherWindowtoCheck1")
{
} else if WinExist_Mode("AnotherWindowtoCheck2",,,,"RegEx","on")
{}
; ... and so on
; ... and so on
; ... and so on
SetTimer, timerevent, ON
return
WinExist_Mode(WinTitle, WinText="", ExcludeTitle="", ExcludeText="", Using_TitleMatchmode="", Using_DetectHiddenwindows="")
{
local
old_mode := A_TitleMatchMode
old_speed := A_TitleMatchModeSpeed
old_detect := A_DetectHiddenWindows
if Strlen(Using_TitleMatchmode)
SetTitleMatchMode, %Using_TitleMatchmode%
if Strlen(Using_DetectHiddenwindows)
DetectHiddenWindows, %Using_DetectHiddenwindows%
res := WinExist(WinTitle, WinText, ExcludeTitle, ExcludeText)
SetTitleMatchMode, %old_mode%
SetTitleMatchMode, %old_speed%
DetectHiddenWindows, %old_detect%
return res
}