funcs_any_win.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:petronia 作者: groboclown 项目源码 文件源码
def _attach_message_queue_to_thread(current_hwnd):
    current_thread_id = windll.kernel32.GetCurrentThreadId()
    thread_process_id = windll.user32.GetWindowThreadProcessId(current_hwnd, None)
    if thread_process_id != current_thread_id:
        res = windll.user32.AttachThreadInput(thread_process_id, current_thread_id, True)
        # ERROR_INVALID_PARAMETER means that the two threads are already attached.
        if res == 0 and GetLastError() != ERROR_INVALID_PARAMETER:
            # TODO better logging
            print("WARN: could not attach thread input to thread {0} ({1})".format(thread_process_id, GetLastError()))
            return True
    windll.user32.AttachThreadInput(thread_process_id, current_thread_id, False)
    return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号