import ctypes msgbox = ctypes.windll.user32.MessageBoxW mode = 0 # ボタン形式=OK(0)|OKキャンセル(1) res = msgbox(0, 'メッセージ', 'タイトル', mode | 0x40000) # 最前面表示(0x40000) if res == 1: # ボタン受付結果=OK(1)|キャンセル(2) pass # ここにOKの場合の処理を記述する