4

I'm using the win32gui library to get a handle to the Windows Security popup and use win32con to click the "Install" button within but without success. Has anyone done this before successfully in Python?

I know I can always install the certificate of the publisher and be done with it for good but I need to account for all security warnings that might pop up.

This can be done because I have done it successfully in VBScript but I need Python now.

enter image description here.

def window_handle(Title):
    handle = win32gui.FindWindowEx(0, 0, 0, Title)
    return handle


def click_btn(hWnd, Button):
    hbutton = win32gui.FindWindowEx(hWnd, 0, "Button", Button)
    if hbutton != 0:
        win32api.PostMessage(hbutton, win32con.WM_LBUTTONDOWN, 0, 0)
        win32api.PostMessage(hbutton, win32con.WM_LBUTTONUP, 0, 0)
        return True
    return None

hWnd = window_handle("Windows Security")
click_btn(hWnd, "&Install")
user_noname_00
  • 269
  • 3
  • 8
  • 2
    I *though* that the whole point of those security confirmation dialogs is that they can't be bypassed by software. – Anton Kovalenko Jan 24 '13 at 18:46
  • 2
    @Anton, this can be bypassed. I wrote some code in VBScript that gets rid of the Security Window but I need it in Python now. – user_noname_00 Jan 24 '13 at 18:50
  • This is a horrible idea. And even if it were a good idea, you're doing it wrong by assuming all Windows versions you'll encounter are English versions. –  Jan 24 '13 at 18:56
  • 4
    I don't see how trying to automate something I have already done successfully in another language is a bad idea. If you can't contribute with a answer then please keep the rants to yourself. – user_noname_00 Jan 24 '13 at 19:00

0 Answers0