Sign in to follow this  
Followers 0
lilx

excluding some window classes in my program.

5 posts in this topic

hello,

i made a little while a ago this program where all windows would be made little bit transparent. it works good and i am very happy with it, but now i can't watch videoclips on windows media player because it is making my windows media player transparant,

so now i found the class names of the programs i wan't exclude. but i am now stuck. i went in the help looking for it but couln't find it so hopefully i can find my answer here.

here is my source

HotKeySet("{ESC}", "Quit")
HotKeySet("{F2}", "Change")
HotKeySet("{F3}", "Normaal")
 
 Dim $vraag, $trans
 
If RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Wintrans") = ("") Then
$vraag = MsgBox ( 4, "Wintrans", "Wil je dat WinTrans Automatisch opstart bij aanmelden?" )
EndIf

If $vraag = 6 Then
    RegWrite ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Wintrans", "REG_SZ", @ScriptFullPath )
EndIf

TrayTip ( "WinTrans", "Druk ESC om Aftesluiten"& @CRLF & "F2 Om The Transparant level te veranderen" & @CRLF & "F3 Terug naar normaal", 10 )
If Not ProcessExists ("sidebar.exe" ) Then
    Do
        while 1
            sleep(10)
        WEnd
    Until ProcessExists ("sidebar.exe")
EndIf
    sleep (20000)

While 1
;$trans = InputBox ( "Wintrans", "Insert A number in the range 0 - 255. The lower the number the more transparent the window will become", "235", "", 150, 160 )
$trans = 230
If @error = 1 Then
    Exit
EndIf
If $trans > 255 Then
    MsgBox(16, "Error", "The Value You Enterd Is Not Correct")
Else
    Trans()
EndIf
WEnd

Func Trans()
$aWin = WinList("")
If $aWin[0][0] = 0 Then

EndIf

For $i = 1 to $aWin[0][0]
    WinSetTrans($aWin[$i][1], "", $trans)
Next

While 1
    Dim $aNewWindows = WinList("")
    For $i = 1 to $aNewWindows[0][0]
        For $j = 1 To $aWin[0][0]
            If $aNewWindows[$i][1] <> $aWin[$j][1] Then WinSetTrans($aNewWindows[$i][1], "", $trans)
        Next
    Next
    Sleep(1000)
WEnd
EndFunc

Func Change()
    While 1
$trans = InputBox ( "Pippo de Clown", "Insert A number in the range 0 - 255. The lower the number the more transparent the window will become", "235", "", 150, 160 )
If @error = 1 Then
    Exit
EndIf
If $trans > 255 Then
    MsgBox(16, "Error", "The Value You Enterd Is Not Correct")
Else
    Trans()
EndIf
WEnd    
EndFunc

Func Normaal()
$trans = 255
Trans()
EndFunc

Func Quit()
    $aWin = WinList("")
If $aWin[0][0] = 0 Then
    Exit
EndIf

For $i = 1 to $aWin[0][0]
    WinSetTrans($aWin[$i][1], "", 255)
Next

    $aWin = 0
    $aNewWindows = 0
    Exit
EndFunc

Share this post


Link to post
Share on other sites



Hi, hope this gives some insight on how to filter out class name windows..

This example won't set the win trans , look in the scite console to see the windows it would set trans to...

Other things you might want to consider is set the min trans to 15 or higher (much below 15 and you can't see the window in most cases).

Also there's no need to set hidden windows trans, the way your script is atm it's setting trans on every window listed..Alot of those windows are never to be shown to the general user (eg: IME, DDE, etc..).

Also filter out the "Program Manager" ([Class:Progman], aka Desktop) window as it can cause problems when you try and set trans on it.

#include <misc.au3>

HotKeySet("{ESC}", "HotKeyEvent")
HotKeySet("{F2}", "HotKeyEvent")
HotKeySet("{F3}", "HotKeyEvent")

Global $SSEC = StringSplit("MediaPlayerClassicW|WMPlayerApp|Progman", "|");Add Class names to filter..

While 1
    Sleep(100)
WEnd

Func HotKeyEvent()
    Switch @HotKeyPressed
        Case "{ESC}"
            ConsoleWrite(@HotKeyPressed & @LF)
            Exit
        Case "{F2}"
            $Trans = InputBox("Pippo de Clown", "Insert a number in the range 15 - 255." & _
                                @LF & "(15 = transparent, 255 = Solid)", "235", "", 220, 140)
            If @error Or $Trans < 15 Or $Trans > 255 Then Return ConsoleWrite("Invalid Input" & @LF)
            Local $aWin = WinList()
            For $i = 1 To $aWin[0][0]
                If $aWin[$i][0] <> "" And WinFilter($aWin[$i][1]) Then ConsoleWrite($aWin[$i][0] & @LF)
            Next
            ConsoleWrite("|-------------------------------------------------------------------|" & @LF)
        Case "{F3}"
            ConsoleWrite(@HotKeyPressed & @LF)
    EndSwitch   
EndFunc

Func WinFilter($handle)
    If Not BitAnd(WinGetState($handle), 2) Then Return 0 ; only visable windows need to get trans set.
    For $j = 1 To $SSEC[0]
        If (WinGetTitle($handle) == WinGetTitle("[CLASS:" & $SSEC[$j] & "]")) Then Return 0 ;filter class names
    Next
    Return 1 ; means window is ok to set trans.
EndFunc

Cheers

Share this post


Link to post
Share on other sites

Hi, hope this gives some insight on how to filter out class name windows..

This example won't set the win trans , look in the scite console to see the windows it would set trans to...

Other things you might want to consider is set the min trans to 15 or higher (much below 15 and you can't see the window in most cases).

Also there's no need to set hidden windows trans, the way your script is atm it's setting trans on every window listed..Alot of those windows are never to be shown to the general user (eg: IME, DDE, etc..).

Also filter out the "Program Manager" ([Class:Progman], aka Desktop) window as it can cause problems when you try and set trans on it.

#include <misc.au3>

HotKeySet("{ESC}", "HotKeyEvent")
HotKeySet("{F2}", "HotKeyEvent")
HotKeySet("{F3}", "HotKeyEvent")

Global $SSEC = StringSplit("MediaPlayerClassicW|WMPlayerApp|Progman", "|");Add Class names to filter..

While 1
    Sleep(100)
WEnd

Func HotKeyEvent()
    Switch @HotKeyPressed
        Case "{ESC}"
            ConsoleWrite(@HotKeyPressed & @LF)
            Exit
        Case "{F2}"
            $Trans = InputBox("Pippo de Clown", "Insert a number in the range 15 - 255." & _
                                @LF & "(15 = transparent, 255 = Solid)", "235", "", 220, 140)
            If @error Or $Trans < 15 Or $Trans > 255 Then Return ConsoleWrite("Invalid Input" & @LF)
            Local $aWin = WinList()
            For $i = 1 To $aWin[0][0]
                If $aWin[$i][0] <> "" And WinFilter($aWin[$i][1]) Then ConsoleWrite($aWin[$i][0] & @LF)
            Next
            ConsoleWrite("|-------------------------------------------------------------------|" & @LF)
        Case "{F3}"
            ConsoleWrite(@HotKeyPressed & @LF)
    EndSwitch   
EndFunc

Func WinFilter($handle)
    If Not BitAnd(WinGetState($handle), 2) Then Return 0 ; only visable windows need to get trans set.
    For $j = 1 To $SSEC[0]
        If (WinGetTitle($handle) == WinGetTitle("[CLASS:" & $SSEC[$j] & "]")) Then Return 0 ;filter class names
    Next
    Return 1 ; means window is ok to set trans.
EndFunc

Cheers

thx for the reply smashly, and this a way more advance way of programming :D, very nice to see. will go tru the code and hope i can learn from this :D

Share this post


Link to post
Share on other sites

hello,

i made already alot of progress and it is getting close to the program that i wanted to create, now i have a other problem and maybe and hopefully my last.

i manage to trans the windows that i wanted but now it is not putting trans when a new window is created like i had before. and because they way smashly typed hes code is totally new to me i am getting confused and is not working. so hopefully you guys can help me out with this one again.

this is what i have so far

#include <misc.au3>
HotKeySet("{ESC}", "HotKeyEvent")
HotKeySet("{F2}", "HotKeyEvent")
HotKeySet("{F3}", "HotKeyEvent")

If RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Wintrans") = ("") Then
$vraag = MsgBox ( 4, "Wintrans", "Wil je dat WinTrans Automatisch opstart bij aanmelden?" )
    If $vraag = 6 Then
        RegWrite ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Wintrans", "REG_SZ", @ScriptFullPath )
    EndIf
EndIf

Global $SSEC = StringSplit("MediaPlayerClassicW|WMPlayerApp|Progman|SWT_Window0|SysListView32", "|");Add Class names to filter..
TrayTip ( "WinTrans", "Druk ESC om Aftesluiten"& @CRLF & "F2 Om The Transparant level te veranderen" & @CRLF & "F3 Terug naar normaal", 10 )

While 1
    Sleep(100)
WEnd

Func HotKeyEvent()
    Switch @HotKeyPressed
        Case "{ESC}" ;shut down program
            ConsoleWrite(@HotKeyPressed & @LF)
            $trans = 255
            Local $aWin = WinList()
            For $i = 1 To $aWin[0][0]
                If $aWin[$i][0] <> "" And WinFilter($aWin[$i][1]) Then 
                WinSetTrans($aWin[$i][0], "", $trans)   
                EndIf
            Next
            Exit



        Case "{F2}" ; change tranparent level
            $Trans = InputBox("WinTrans", "Insert a number in the range 15 - 255." & _
                                @LF & "(15 = transparent, 255 = Solid)", "235", "", 220, 140)
            If @error Or $Trans < 15 Or $Trans > 255 Then Return ConsoleWrite("Invalid Input" & @LF)
            Local $aWin = WinList()
            
            For $i = 1 To $aWin[0][0]
                If $aWin[$i][0] <> "" And WinFilter($aWin[$i][1]) Then 
                WinSetTrans($aWin[$i][0], "", $trans)
                ConsoleWrite($aWin[$i][0] & @LF)    
                EndIf
            Next
            ConsoleWrite("|End----------------------------------------------------------------|" & @LF)
            
            
            ;For If A New Window is Created
            ;this is the part i was messing with, but i don't now if i am doing it correctly...
            While 1
            Dim $aNewWindows = WinList("")
                For $j = 1 to $aNewWindows[0][0]
                    For $i = 1 To $aWin[0][0]
                        If $aNewWindows[$j][1] <> $aWin[$i][1] Then 
                        
                                If $aWin[$i][0] <> "" And WinFilter($aWin[$i][1]) Then 
                                    WinSetTrans($aWin[$i][0], "", $trans)
                                EndIf
                        
                        EndIf
                    Next
                Next
            Sleep(1000)
            WEnd
            
            
        Case "{F3}" ; change back to normaal
            ConsoleWrite(@HotKeyPressed & @LF)
            $trans = 255
            Local $aWin = WinList()
            For $i = 1 To $aWin[0][0]
                If $aWin[$i][0] <> "" And WinFilter($aWin[$i][1]) Then 
                WinSetTrans($aWin[$i][0], "", $trans)   
                EndIf
            Next
    EndSwitch   
EndFunc

Func WinFilter($handle)
    If Not BitAnd(WinGetState($handle), 2) Then Return 0 ; only visable windows need to get trans set.
    For $j = 1 To $SSEC[0]
        If (WinGetTitle($handle) == WinGetTitle("[CLASS:" & $SSEC[$j] & "]")) Then Return 0 ;filter class names
    Next
    Return 1 ; means window is ok to set trans.
EndFunc

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hi, I had a chance to look at your problem.

The updated code chews less cpu time then your first original code.

Added 2 new hotkey combinations so you can use them to step up or down the transparency without having to pull up the input box.

Also set the input box to show the current transparency value when it's activated.

HotKeySet("{ESC}", "HotKeyEvent");Esc to restore transparent windows to solid and exit
HotKeySet("{F2}", "HotKeyEvent");F2 to input a transparent value
HotKeySet("{F3}", "HotKeyEvent");F3 to Set no transparency
HotKeySet("^{F2}", "HotKeyEvent");Ctrl + F2 to step more transparent
HotKeySet("^{F3}", "HotKeyEvent");Ctrl + F3 to step less transparent

Global $SSEC = StringSplit("MediaPlayerClassicW|WMPlayerApp|Progman|SWT_Window0|SysListView32", "|")
Global $aGlobalWin[1], $trans = 255

AdlibEnable("WinCheck", 250)

While 1
    Sleep(100)
WEnd

Func HotKeyEvent()
    Switch @HotKeyPressed
        Case "{ESC}"
            AdlibDisable()
            If $trans <> 255 Then
                For $i = 1 To $aGlobalWin[0]
                    WinSetTrans(HWnd(StringLeft($aGlobalWin[$i], 10)), "", 255)
                Next
            EndIf   
            Exit
        Case "{F2}"
            Local $Input = InputBox("Pippo de Clown", "Insert a number in the range 15 - 255." & _
                                        @LF & "(15 = transparent, 255 = Solid)", $trans, "", 220, 140)
            If Not @error And $Input >= 15 And $Input <= 255 Then $trans = $Input
        Case "{F3}"
            $trans = 255
        Case "^{F2}"
            If $trans > 15 Then $trans -= 1
        Case "^{F3}"
            If $trans < 255 Then $trans += 1
    EndSwitch
EndFunc

Func WinCheck()
    AdlibDisable()
    Local $oTemp
    If $aGlobalWin[0] > 0 Then
        For $x = 1 To $aGlobalWin[0]
            Local $SSO = StringSplit($aGlobalWin[$x], ",")
            If WinExists(HWnd($SSO[1])) Then $oTemp &= $aGlobalWin[$x] & "|"
        Next
    EndIf
    If StringTrimRight($oTemp, 1) <> "" Then
        Local $SSP = StringSplit(StringTrimRight($oTemp, 1), "|")
        Dim $aGlobalWin[$SSP[0] + 1]
        $aGlobalWin[0] = $SSP[0]
        For $y = 1 To $SSP[0]
            $aGlobalWin[$y] = $SSP[$y]
        Next
    EndIf   
    Local $aWin = WinList(), $cTemp
    For $w = 1 To $aWin[0][0]
        If $aWin[$w][0] <> "" And WinFilter($aWin[$w][1]) And (Not StringInStr($oTemp, $aWin[$w][1] )) Then 
            ReDim $aGlobalWin[$aGlobalWin[0] + 2]
            $aGlobalWin[0] += 1
            $aGlobalWin[$aGlobalWin[0]] = $aWin[$w][1] & ",255"
        EndIf   
    Next
    For $i = 1 To $aGlobalWin[0]
        If StringTrimLeft($aGlobalWin[$i], 11) <> $trans Then
            WinSetTrans(HWnd(StringLeft($aGlobalWin[$i], 10)), "", $trans)
            $aGlobalWin[$i] = StringLeft($aGlobalWin[$i], 11) & $trans
        EndIf
    Next
    AdlibEnable("WinCheck", 250)
EndFunc

Func WinFilter($iHandle)
    If Not BitAnd(WinGetState($iHandle), 2) Then Return 0
    For $j = 1 To $SSEC[0]
        If (WinGetTitle($iHandle) == WinGetTitle("[CLASS:" & $SSEC[$j] & "]")) Then Return 0
    Next
    Return 1
EndFunc

Cheers

Edited by smashly

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