Psibernetic Posted January 22, 2007 Posted January 22, 2007 I was wondering if there was a way to detect if a new window has opened, it may not always be an active window, I am attempting to provide transsparency to every application in Windows XP...I kno of WinList(), I could use that command every few secinds and compare data, but that would use far more cpu then wanted...any ideas? [sup]Psibernetic[/sup]My Creations:X-HideSecuracy
seandisanti Posted January 23, 2007 Posted January 23, 2007 I was wondering if there was a way to detect if a new window has opened, it may not always be an active window, I am attempting to provide transsparency to every application in Windows XP...I kno of WinList(), I could use that command every few secinds and compare data, but that would use far more cpu then wanted...any ideas?WinList itself doesn't take up much cpu, you're just going to eat up time while you're looping through checking everything, BUT, you don't really need to loop through everything every time do you? I mean if you check the count, and only loop through when the count changes, you should be able to check more frequently with less impact. example:#include<array.au3> $thelist = WinList() $count = $thelist[0][0] While 1 $tmp = WinList() $newCount = $tmp[0][0] If $newCount > $count Then For $i = 1 to $newCount $found = 0 For $j = 1 to $count If $thelist[$j][0] = $tmp[$i][0] Then $found = 1 ExitLoop EndIf Next If Not $found Then MsgBox(0,"New Window",$tmp[$i][0] & @CRLF & "is a new window") ExitLoop EndIf Next $thelist = $tmp $count = $newCount EndIf If $newCount < $count Then $thelist = $tmp $count = $newCount EndIf Sleep(250) ConsoleWrite(@CRLF & $count & " :: " & $newCount & @CRLF) WEndthat's barely tested at all, but it raises the cpu usage on my work computer about 2%
Uten Posted January 23, 2007 Posted January 23, 2007 WinWaitNotActive(WinActive("")) Obviously you can compare against a stored WinList array every time there is a change in the active window. That should pretty much reduce the CPU load towards 0%. Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now