Ctypes kitaplığını kullanabilirsiniz.
bu kodu göz önünde bulundurun: Her açık pencerenin üzerinde
import ctypes
EnumWindows = ctypes.windll.user32.EnumWindows
EnumWindowsProc = ctypes.WINFUNCTYPE(ctypes.c_bool, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int))
GetWindowText = ctypes.windll.user32.GetWindowTextW
GetWindowTextLength = ctypes.windll.user32.GetWindowTextLengthW
SendMessage = ctypes.windll.user32.SendMessageW
IsWindowVisible = ctypes.windll.user32.IsWindowVisible
def foreach_window(hwnd, lParam):
if IsWindowVisible(hwnd):
length = GetWindowTextLength(hwnd)
buff = ctypes.create_unicode_buffer(length + 1)
GetWindowText(hwnd, buff, length + 1)
if(buff.value == "Choose File to Upload"): #This is the window label
SendMessage(hwnd, 0x0100, 0x09, 0x00000001)
return True
EnumWindows(EnumWindowsProc(foreach_window), 0)
Sen döngü ve seçtiğiniz birinin anahtarı vuruş gönderebilir. - WM_KEYDOWN (0x0100), tab
(0x09
) ait virtual-key code ve 4. argüman repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag
pencere Hendler (hwnd
), BEDEN anahtar göndermek için:
SendMessage fonksiyon 4 params alır.
Ayrıca, tuş, anahtar, chars, döner vb. Gönderebilirsiniz ... Yardım için belgeleri kullanın. Win32 Python: Getting all window titles
İyi şanslar:
Bir referans olarak kullandı!
[basit Diyaloğu ile Python bir dosyayı seçme] Olası yinelenen (http://stackoverflow.com/questions/3579568/python-with-simple-dialog ile dosya-dosyası seçerek) –
@Alvin Lütfen nota bakınız. – kame
Selenium size yardımcı olmayacaktır. [Tag: AutoIt], [tag: Sikuli], [tag: RobotFramework] 'ı düşündünüz mü? – SiKing