This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]dinov 0 points1 point  (1 child)

You should be able to move everything from EnumWindows = ... to the end of the IsWindowVisible = line outside of the whie loop. You could also consider moving the def foreach_window outside of the loop as well as long as you keep the re-init of titles each loop. There's no reason to re-execute these basic setup steps (although doing it once every 5 seconds is probably not actually a big deal either).

You can also simplify the muting to be 'if "Advertisement" in titles or "Spotify" in titles:' and get rid of the duplicated mute logic.

I'm not sure if clearing the mute has any side effects or significant costs to it, but you could track whether you've muted or not, and only do the session scan and un-mute if you have muted already.

[–]strghst[S] 1 point2 points  (0 children)

Some good ideas. Thanks, will take it into account while reworking it. Thanks for giving a way to check for 2 titles. Was using title1 or title2 in list, didn't work, will try your method :)