This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ctypes | |
from ctypes import wintypes | |
#imports | |
GetWindowLong=ctypes.windll.user32.GetWindowLongW | |
SetWindowLong=ctypes.windll.user32.SetWindowLongW | |
SetLayeredWindowAttributes=ctypes.windll.user32.SetLayeredWindowAttributes | |
GetShell=ctypes.windll.user32.GetShellWindow | |
EnumChildren = ctypes.windll.user32.EnumChildWindows | |
EnumWindows=ctypes.windll.user32.EnumWindows | |
GetWindowText = ctypes.windll.user32.GetWindowTextW | |
IsWindowVisible = ctypes.windll.user32.IsWindowVisible | |
GetWindowTextLength = ctypes.windll.user32.GetWindowTextLengthW | |
GetClassName=ctypes.windll.user32.GetClassNameW | |
EnumWindowsProc = ctypes.WINFUNCTYPE(ctypes.c_bool, ctypes.POINTER(ctypes.c_int), | |
ctypes.POINTER(ctypes.c_int)) | |
#handy class for all my functions | |
class Main: | |
def __init__(self): | |
self.all=[] | |
self.allnames=[] | |
self.titles=[] | |
shell=GetShell() | |
self.EnumWindows = ctypes.windll.user32.EnumWindows | |
self.EnumWindowsProc = ctypes.WINFUNCTYPE(ctypes.c_bool, ctypes.POINTER(ctypes.c_int), | |
ctypes.POINTER(ctypes.c_int)) | |
self.titles = [] | |
self.all = [] | |
self.allnames = [] | |
def GetHandles(self): | |
self.EnumWindows(self.EnumWindowsProc(self.GetHWND), 0) | |
for item in self.titles: | |
EnumChildren(item, self.EnumWindowsProc(self.GetHWND), 0) | |
self.EnumWindows(self.EnumWindowsProc(self.GetHWND), 0) | |
return self.titles | |
def GetHWND(self, hwnd, lParam): | |
if IsWindowVisible(hwnd): | |
length = GetWindowTextLength(hwnd) | |
buff = ctypes.create_unicode_buffer(length + 1) | |
GetWindowText(hwnd, buff, length + 1) | |
self.titles.append(hwnd) | |
return True | |
def classname(self,handle): | |
class_name = (ctypes.c_wchar * 257)() | |
GetClassName(handle, ctypes.byref(class_name), 256) | |
return class_name.value | |
if __name__=="__main__": | |
m=Main() | |
hwnds= m.GetHandles() | |
for h in hwnds: | |
if m.classname(h)==u"WorkerW": | |
SetWindowLong(h, -20, GetWindowLong(h, -20)) | |
SetLayeredWindowAttributes(h,0,0,0x00000002) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment