Sign in to follow this  
Followers 0
Psibernetic

Detecting a new window

3 posts in this topic

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

Share this post


Link to post
Share on other sites



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)
WEnd

that's barely tested at all, but it raises the cpu usage on my work computer about 2%


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

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%.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0