Testing pyauto python

0 thích 0 không thích
1 lượt xem
đã hỏi 1 Tháng 6, 2023 trong Python bởi nguyenthao (9,000 điểm)
from pywinauto.application import Application

from pywinauto import mouse

from pywinauto.keyboard import send_keys

app = Application(backend='uia').start('C:\\Users\\it101\\AppData\\Local\\Programs\\Zalo\\zalo.exe').connect(title ='Zalo', timeout =30)

# app.Zalo.print_control_identifiers(depth= 5)

left = 112

top = 46

right = 169

bottom = 66

# Calculate the click position within the rectangle

x = left + (right - left) // 2

y = top + (bottom - top) // 2

# Perform the click at the specified position

mouse.click(button='left', coords=(x, y))

findTextBox = app.Zalo.child_window(auto_id="contact-search-input", control_type="Edit").wrapper_object()

findTextBox.type_keys("Cloud của tôi", with_spaces= True)

left = 237

top = 181

right = 202

bottom = 202

x = left + (right - left) // 2

y = top + (bottom - top) // 2

# Perform the click at the specified position

mouse.click(button='left', coords=(x, y))

# findTextBox.type_keys("Chiều nay mình gặp nhau ở đâu?", with_spaces= True)  (L393, T992, R658, B1013)

# element_list = txtMessage.children()

# element_to_click = element_list[1]

# element_to_click.click_input()

for num in range(5):

    txtMessage = app.Zalo.child_window(auto_id="richInput", control_type="Group", top_level_only = False).wrapper_object()

    txtMessage.click_input()

    txtMessage.type_keys("Anh Thảo đẹp trai nhất thế giới...", with_spaces= True)

    send_keys("{ENTER}")

# findTextBox.click()

# app.Zalo.print_control_identifiers(depth= 8)  # (L453, T35, R604, B59)
    
...