1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] SetForegroundWindow error 'The handle is invalid.'

Discussão em 'Python' iniciado por Stack, Setembro 21, 2021.

  1. Stack

    Stack Membro Participativo

    hi I have some error code from SetForegroundWindow need some help normally this code work

    user32 = ctypes.windll.user32
    handle = user32.FindWindowW(None, r'*Untitled - Notepad')
    win32gui.SetForegroundWindow(handle)


    but its not work when loop continue

    ps.its work at first time code running before continue loop

    user32 = ctypes.windll.user32
    handle = user32.FindWindowW(None, r'*Untitled - Notepad')

    while True:
    win32gui.SetForegroundWindow(handle)
    a = input(' ')
    if int(a) == 0:
    continue
    else:
    break


    I got some erroe like this

    win32gui.SetForegroundWindow(handle)
    pywintypes.error: (6, 'SetForegroundWindow', 'The handle is invalid.')


    please help thank you

    Continue reading...

Compartilhe esta Página