TShopping
標題:
python 如何抓取視窗位址及在視窗輸入文字
[打印本頁]
作者:
woff
時間:
2024-1-15 23:47
標題:
python 如何抓取視窗位址及在視窗輸入文字
import ctypes
import time
import keyboard
import win32gui
def click_left(x,y,click_s):
ctypes.windll.user32.SetCursorPos(x, y)
ctypes.windll.user32.mouse_event(2,0,0,0,0)
#滑鼠點擊間隔時間
#print(x,y)
time.sleep(click_s)
ctypes.windll.user32.mouse_event(4,0,0,0,0)
def callback(hwnd, extra):
rect = win32gui.GetWindowRect(hwnd)
x = rect[0] # 視窗起始位置x
y = rect[1] # 視窗起始位置y
w = rect[2] - x # 視窗大小x
h = rect[3] - y # 視窗大小y
if "xxxx" in win32gui.GetWindowText(hwnd):
# print("Window %s:" % win32gui.GetWindowText(hwnd))
# print("\tLocation: (%d, %d)" % (x, y))
# print("\t Size: (%d, %d)" % (w, h))
click_left(x + 1, y + 1, 1)
win32gui.EnumWindows(callback, None)
time.sleep(2)
keyboard.press_and_release('y') #輸入y
keyboard.press_and_release('e') #輸入e
keyboard.press_and_release('s') #輸入s
keyboard.press_and_release('enter') #壓enter
複製代碼
新竹網頁設計,竹北網頁設計,竹南網頁設計,中壢網頁設計,網頁設計,免費模板,免費網頁套件,架設網站,網站架設 ,修改模板,主機代管,Android App
歡迎光臨 TShopping (http://www.tshopping.com.tw/)
Powered by Discuz! X3.2