Apr-14-2019, 06:22 PM
I have a sort of specific question today. I want to know how, in the specific case of my code, how I can pass a function's local variable outside the function?
Code:
Code:
def folder_exists(folder): enum_func = ctypes.WINFUNCTYPE(wintypes.BOOL, wintypes.HWND, wintypes.LPARAM) def query(hwnd, lParam): found = 0 length = ctypes.WinDLL('User32').GetWindowTextLengthW(hwnd) + 1 buf = ctypes.create_unicode_buffer(length) ctypes.WinDLL('User32').GetWindowTextW(hwnd, buf, length) if buf.value == folder: found += 1 return True worker = enum_func(query) ctypes.WinDLL('User32').EnumWindows(worker, None) print(found) folder_exists('Downloads')The
query
function needs to return true in order for the C function call "EnumWindows" to work. Basically what I'm trying to do here is 'do something' (don't worry about what) once a certain folder title is found. So how can I or what can I pass as some sort of indicator that the correct folder was found from the query
function? Is there some way I can pass the found
local variable outside the function? I needs to be whatever it's set to when the function is called.