Last active
August 19, 2024 00:44
-
-
Save universato/84f494566f24c69b1f6f7ffbd687a40a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pynput.mouse import Listener | |
def on_click(x, y, button, pressed): | |
if pressed: | |
on_click.start_point = (x, y) | |
else: | |
left, top = on_click.start_point | |
width = x - left | |
height = y - top | |
if width >= 32 or height >= 32: | |
print(f"left = {left}") | |
print(f"top = {top}") | |
print(f"width = {width}") | |
print(f"height = {height}") | |
print(f"region=({left},{top},{width},{height})") | |
return False | |
with Listener(on_click=on_click) as click_listener: | |
click_listener.join() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import win32gui | |
import win32con | |
def enum_windows_callback(hwnd, window_titles): | |
# ウィンドウタイトルを取得 | |
title = win32gui.GetWindowText(hwnd) | |
if title == "Windows セキュリティ": | |
window_titles.append(hwnd) | |
def find_and_focus_windows_security(): | |
window_titles = [] | |
win32gui.EnumWindows(enum_windows_callback, window_titles) | |
if window_titles: | |
print("Windows セキュリティが見つかりました。フォーカスを当てます。") | |
for hwnd in window_titles: | |
win32gui.ShowWindow(hwnd, win32con.SW_RESTORE) # ウィンドウを元のサイズに戻す | |
win32gui.SetForegroundWindow(hwnd) # ウィンドウをアクティブにする | |
return True | |
else: | |
print("Windows セキュリティは見つかりませんでした。") | |
return False | |
# 使用例 | |
find_and_focus_windows_security() | |
import win32gui | |
import win32con | |
def enum_windows_callback(hwnd, dialog_titles): | |
# ウィンドウのタイトルを取得 | |
title = win32gui.GetWindowText(hwnd) | |
if title == "デジタル署名": | |
dialog_titles.append(title) | |
def is_digital_signature_dialog_open(): | |
dialog_titles = [] | |
# すべてのトップレベルウィンドウを列挙 | |
win32gui.EnumWindows(enum_windows_callback, dialog_titles) | |
if dialog_titles: | |
print("デジタル署名のダイアログが表示されています。") | |
return True | |
else: | |
print("デジタル署名のダイアログは表示されていません。") | |
return False | |
# 使用例 | |
is_digital_signature_dialog_open() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment