uiautomation
|
関数 | |
str | GetClipboardText () |
bool | SetClipboardText (str text) |
bool | SetConsoleColor (int color) |
bool | ResetConsoleColor () |
int | WindowFromPoint (int x, int y) |
Tuple[int, int] | GetCursorPos () |
bool | SetCursorPos (int x, int y) |
int | GetDoubleClickTime () |
None | mouse_event (int dwFlags, int dx, int dy, int dwData, int dwExtraInfo) |
None | keybd_event (int bVk, int bScan, int dwFlags, int dwExtraInfo) |
bool | PostMessage (int handle, int msg, int wParam, int lParam) |
int | SendMessage (int handle, int msg, int wParam, int lParam) |
None | Click (int x, int y, float waitTime=OPERATION_WAIT_TIME) |
None | MiddleClick (int x, int y, float waitTime=OPERATION_WAIT_TIME) |
None | RightClick (int x, int y, float waitTime=OPERATION_WAIT_TIME) |
None | PressMouse (int x, int y, float waitTime=OPERATION_WAIT_TIME) |
None | ReleaseMouse (float waitTime=OPERATION_WAIT_TIME) |
None | RightPressMouse (int x, int y, float waitTime=OPERATION_WAIT_TIME) |
None | RightReleaseMouse (float waitTime=OPERATION_WAIT_TIME) |
None | MiddlePressMouse (int x, int y, float waitTime=OPERATION_WAIT_TIME) |
None | MiddleReleaseMouse (float waitTime=OPERATION_WAIT_TIME) |
None | MoveTo (int x, int y, float moveSpeed=1, float waitTime=OPERATION_WAIT_TIME) |
None | DragDrop (int x1, int y1, int x2, int y2, float moveSpeed=1, float waitTime=OPERATION_WAIT_TIME) |
None | RightDragDrop (int x1, int y1, int x2, int y2, float moveSpeed=1, float waitTime=OPERATION_WAIT_TIME) |
None | MiddleDragDrop (int x1, int y1, int x2, int y2, float moveSpeed=1, float waitTime=OPERATION_WAIT_TIME) |
None | WheelDown (int wheelTimes=1, float interval=0.05, float waitTime=OPERATION_WAIT_TIME) |
None | WheelUp (int wheelTimes=1, float interval=0.05, float waitTime=OPERATION_WAIT_TIME) |
int | SetDpiAwareness (bool dpiAwarenessPerMonitor=True) |
Tuple[int, int] | GetScreenSize (bool dpiAwarenessPerMonitor=True) |
Tuple[int, int] | GetVirtualScreenSize (bool dpiAwarenessPerMonitor=True) |
List[Rect] | GetMonitorsRect (bool dpiAwarenessPerMonitor=False) |
int | GetPixelColor (int x, int y, int handle=0) |
int | MessageBox (str content, str title, int flags=MB.Ok) |
bool | SetForegroundWindow (int handle) |
bool | BringWindowToTop (int handle) |
None | SwitchToThisWindow (int handle) |
int | GetAncestor (int handle, int flag) |
bool | IsTopLevelWindow (int handle) |
int | GetWindowLong (int handle, int index) |
int | SetWindowLong (int handle, int index, int value) |
bool | IsIconic (int handle) |
bool | IsZoomed (int handle) |
bool | IsWindowVisible (int handle) |
bool | ShowWindow (int handle, int cmdShow) |
bool | MoveWindow (int handle, int x, int y, int width, int height, int repaint=1) |
bool | SetWindowPos (int handle, int hWndInsertAfter, int x, int y, int width, int height, int flags) |
bool | SetWindowTopmost (int handle, bool isTopmost) |
str | GetWindowText (int handle) |
bool | SetWindowText (int handle, str text) |
str | GetEditText (int handle) |
str | GetConsoleOriginalTitle () |
str | GetConsoleTitle () |
bool | SetConsoleTitle (str text) |
int | GetForegroundWindow () |
bool | IsDesktopLocked () |
bool | PlayWaveFile (str filePath=r 'C:\Windows\Media\notify.wav', bool isAsync=False, bool isLoop=False) |
bool | IsProcess64Bit (int processId) |
bool | IsUserAnAdmin () |
bool | RunScriptAsAdmin (List[str] argv, str workingDirectory=None, int showFlag=SW.ShowNormal) |
None | SendKey (int key, float waitTime=OPERATION_WAIT_TIME) |
None | PressKey (int key, float waitTime=OPERATION_WAIT_TIME) |
None | ReleaseKey (int key, float waitTime=OPERATION_WAIT_TIME) |
bool | IsKeyPressed (int key) |
INPUT | MouseInput (int dx, int dy, int mouseData=0, int dwFlags=MouseEventFlag.LeftDown, int time_=0) |
INPUT | KeyboardInput (int wVk, int wScan, int dwFlags=KeyboardEventFlag.KeyDown, int time_=0) |
INPUT | HardwareInput (int uMsg, int param=0) |
int | SendInput (*inputs) |
int | SendUnicodeChar (str char, bool charMode=True) |
None | SendKeys (str text, float interval=0.01, float waitTime=OPERATION_WAIT_TIME, bool charMode=True, bool debug=False) |
def | GetPatternIdInterface (int patternId) |
def | CreatePattern (int patternId, ctypes.POINTER(comtypes.IUnknown) pattern) |
None | InitializeUIAutomationInCurrentThread () |
None | UninitializeUIAutomationInCurrentThread () |
None | SetGlobalSearchTimeout (float seconds) |
bool | WaitForExist (Control control, float timeout) |
bool | WaitForDisappear (Control control, float timeout) |
def | WalkTree (top, Callable[[TreeNode], List[TreeNode]] getChildren=None, Callable[[TreeNode], TreeNode] getFirstChild=None, Callable[[TreeNode], TreeNode] getNextSibling=None, Callable[[TreeNode, int], bool] yieldCondition=None, bool includeTop=False, int maxDepth=0xFFFFFFFF) |
PaneControl | GetRootControl () |
Control | GetFocusedControl () |
Control | GetForegroundControl () |
WindowControl | GetConsoleWindow () |
Control | ControlFromPoint (int x, int y) |
Control | ControlFromPoint2 (int x, int y) |
Control | ControlFromCursor () |
Control | ControlFromCursor2 () |
Control | ControlFromHandle (int handle) |
bool | ControlsAreSame (Control control1, Control control2) |
def | WalkControl (Control control, bool includeTop=False, int maxDepth=0xFFFFFFFF) |
None | LogControl (Control control, int depth=0, bool showAllName=True, bool showPid=False) |
None | EnumAndLogControl (Control control, int maxDepth=0xFFFFFFFF, bool showAllName=True, bool showPid=False, int startDepth=0) |
None | EnumAndLogControlAncestors (Control control, bool showAllName=True, bool showPid=False) |
Control | FindControl (Control control, Callable[[Control, int], bool] compare, int maxDepth=0xFFFFFFFF, bool findFromSelf=False, int foundIndex=1) |
None | ShowDesktop (float waitTime=1) |
None | WaitHotKeyReleased (Tuple[int, int] hotkey) |
None | RunByHotKey (Dict[Tuple[int, int], Callable] keyFunctions, Tuple[int, int] stopHotKey=None, Tuple[int, int] exitHotKey=(ModifierKey.Control, Keys.VK_D), bool waitHotKeyReleased=True) |
変数 | |
TreeNode = Any | |
string | AUTHOR_MAIL = 'yinkaisheng@live.com' |
string | METRO_WINDOW_CLASS_NAME = 'Windows.UI.Core.CoreWindow' |
float | SEARCH_INTERVAL = 0.5 |
int | MAX_MOVE_SECOND = 1 |
int | TIME_OUT_SECOND = 10 |
float | OPERATION_WAIT_TIME = 0.5 |
int | MAX_PATH = 260 |
bool | DEBUG_SEARCH_TIME = False |
bool | DEBUG_EXIST_DISAPPEAR = False |
int | S_OK = 0 |
int | IsNT6orHigher = 6 |
ProcessTime = time.perf_counter | |
dictionary | ControlTypeNames |
dictionary | PatternIdNames |
dictionary | PropertyIdNames |
dictionary | SpecialKeyNames |
dictionary | CharacterCodes |
dictionary | PatternConstructors |
dictionary | ControlConstructors |
c = ctor() | |
notepad = WindowControl(searchDepth=1, ClassName='Notepad') | |
lp = notepad.GetLegacyIAccessiblePattern() | |
value = notepad.GetPropertyValue(k) | |
children = notepad.GetChildren() | |
string | hello = '{Ctrl}{End}{Enter}Hello World! 你好世界!' |
bool uiautomation.uiautomation.BringWindowToTop | ( | int | handle | ) |
BringWindowToTop from Win32. handle: int, the handle of a native window. Return bool, True if succeed otherwise False.
None uiautomation.uiautomation.Click | ( | int | x, |
int | y, | ||
float | waitTime = OPERATION_WAIT_TIME |
||
) |
Simulate mouse click at point x, y. x: int. y: int. waitTime: float.
Control uiautomation.uiautomation.ControlFromCursor | ( | ) |
Call ControlFromPoint with current cursor point. Return `Control` subclass.
Control uiautomation.uiautomation.ControlFromCursor2 | ( | ) |
Call ControlFromPoint2 with current cursor point. Return `Control` subclass.
Control uiautomation.uiautomation.ControlFromHandle | ( | int | handle | ) |
Call IUIAutomation.ElementFromHandle with a native handle. handle: int, a native window handle. Return `Control` subclass or None.
Control uiautomation.uiautomation.ControlFromPoint | ( | int | x, |
int | y | ||
) |
Call IUIAutomation ElementFromPoint x,y. May return None if mouse is over cmd's title bar icon. Return `Control` subclass or None.
Control uiautomation.uiautomation.ControlFromPoint2 | ( | int | x, |
int | y | ||
) |
Get a native handle from point x,y and call IUIAutomation.ElementFromHandle. Return `Control` subclass.
control1: `Control` or its subclass. control2: `Control` or its subclass. Return bool, True if control1 and control2 represent the same control otherwise False.
def uiautomation.uiautomation.CreatePattern | ( | int | patternId, |
ctypes.POINTER(comtypes.IUnknown) | pattern | ||
) |
Create a concreate pattern by pattern id and pattern(POINTER(IUnknown)).
None uiautomation.uiautomation.DragDrop | ( | int | x1, |
int | y1, | ||
int | x2, | ||
int | y2, | ||
float | moveSpeed = 1 , |
||
float | waitTime = OPERATION_WAIT_TIME |
||
) |
Simulate mouse left button drag from point x1, y1 drop to point x2, y2. x1: int. y1: int. x2: int. y2: int. moveSpeed: float, 1 normal speed, < 1 move slower, > 1 move faster. waitTime: float.
None uiautomation.uiautomation.EnumAndLogControl | ( | Control | control, |
int | maxDepth = 0xFFFFFFFF , |
||
bool | showAllName = True , |
||
bool | showPid = False , |
||
int | startDepth = 0 |
||
) |
Print and log control and its descendants' propertyies. control: `Control` or its subclass. maxDepth: int, enum depth. showAllName: bool, if False, print the first 30 characters of control.Name. startDepth: int, control's current depth.
None uiautomation.uiautomation.EnumAndLogControlAncestors | ( | Control | control, |
bool | showAllName = True , |
||
bool | showPid = False |
||
) |
Print and log control and its ancestors' propertyies. control: `Control` or its subclass. showAllName: bool, if False, print the first 30 characters of control.Name.
Control uiautomation.uiautomation.FindControl | ( | Control | control, |
Callable[[Control, int], bool] | compare, | ||
int | maxDepth = 0xFFFFFFFF , |
||
bool | findFromSelf = False , |
||
int | foundIndex = 1 |
||
) |
control: `Control` or its subclass. compare: Callable[[Control, int], bool], function(control: Control, depth: int) -> bool. maxDepth: int, enum depth. findFromSelf: bool, if False, do not compare self. foundIndex: int, starts with 1, >= 1. Return `Control` subclass or None if not find.
int uiautomation.uiautomation.GetAncestor | ( | int | handle, |
int | flag | ||
) |
GetAncestor from Win32. handle: int, the handle of a native window. index: int, a value in class `GAFlag`. Return int, a native window handle.
str uiautomation.uiautomation.GetClipboardText | ( | ) |
str uiautomation.uiautomation.GetConsoleOriginalTitle | ( | ) |
GetConsoleOriginalTitle from Win32. Return str. Only available on Windows Vista or higher.
str uiautomation.uiautomation.GetConsoleTitle | ( | ) |
GetConsoleTitle from Win32. Return str.
WindowControl uiautomation.uiautomation.GetConsoleWindow | ( | ) |
Return `WindowControl` or None, a console window that runs python.
Tuple[int, int] uiautomation.uiautomation.GetCursorPos | ( | ) |
GetCursorPos from Win32. Get current mouse cursor positon. Return Tuple[int, int], two ints tuple (x, y).
int uiautomation.uiautomation.GetDoubleClickTime | ( | ) |
GetDoubleClickTime from Win32. Return int, in milliseconds.
str uiautomation.uiautomation.GetEditText | ( | int | handle | ) |
Get text of a native Win32 Edit. handle: int, the handle of a native window. Return str.
Control uiautomation.uiautomation.GetFocusedControl | ( | ) |
Return `Control` subclass.
Control uiautomation.uiautomation.GetForegroundControl | ( | ) |
Return `Control` subclass.
int uiautomation.uiautomation.GetForegroundWindow | ( | ) |
GetForegroundWindow from Win32. Return int, the native handle of the foreground window.
List[Rect] uiautomation.uiautomation.GetMonitorsRect | ( | bool | dpiAwarenessPerMonitor = False | ) |
Get monitors' rect. dpiAwarenessPerMonitor: bool. Return List[Rect].
def uiautomation.uiautomation.GetPatternIdInterface | ( | int | patternId | ) |
Get pattern COM interface by pattern id. patternId: int, a value in class `PatternId`. Return comtypes._cominterface_meta.
int uiautomation.uiautomation.GetPixelColor | ( | int | x, |
int | y, | ||
int | handle = 0 |
||
) |
Get pixel color of a native window. x: int. y: int. handle: int, the handle of a native window. Return int, the bgr value of point (x,y). r = bgr & 0x0000FF g = (bgr & 0x00FF00) >> 8 b = (bgr & 0xFF0000) >> 16 If handle is 0, get pixel from Desktop window(root control). Note: Not all devices support GetPixel. An application should call GetDeviceCaps to determine whether a specified device supports this function. For example, console window doesn't support.
PaneControl uiautomation.uiautomation.GetRootControl | ( | ) |
Get root control, the Desktop window. Return `PaneControl`.
Tuple[int, int] uiautomation.uiautomation.GetScreenSize | ( | bool | dpiAwarenessPerMonitor = True | ) |
dpiAwarenessPerMonitor: bool. Return Tuple[int, int], two ints tuple (width, height).
Tuple[int, int] uiautomation.uiautomation.GetVirtualScreenSize | ( | bool | dpiAwarenessPerMonitor = True | ) |
dpiAwarenessPerMonitor: bool. Return Tuple[int, int], two ints tuple (width, height).
int uiautomation.uiautomation.GetWindowLong | ( | int | handle, |
int | index | ||
) |
GetWindowLong from Win32. handle: int, the handle of a native window. index: int.
str uiautomation.uiautomation.GetWindowText | ( | int | handle | ) |
GetWindowText from Win32. handle: int, the handle of a native window. Return str.
INPUT uiautomation.uiautomation.HardwareInput | ( | int | uMsg, |
int | param = 0 |
||
) |
Create Win32 struct `HARDWAREINPUT` for `SendInput`.
None uiautomation.uiautomation.InitializeUIAutomationInCurrentThread | ( | ) |
Initialize UIAutomation in a new thread. If you want to use functionalities related to Controls and Patterns in a new thread. You must call this function first in the new thread. But you can't use use a Control or a Pattern created in a different thread. So you can't create a Control or a Pattern in main thread and then pass it to a new thread and use it.
bool uiautomation.uiautomation.IsDesktopLocked | ( | ) |
Check if desktop is locked. Return bool. Desktop is locked if press Win+L, Ctrl+Alt+Del or in remote desktop mode.
bool uiautomation.uiautomation.IsIconic | ( | int | handle | ) |
IsIconic from Win32. Determine whether a native window is minimized. handle: int, the handle of a native window. Return bool.
bool uiautomation.uiautomation.IsKeyPressed | ( | int | key | ) |
key: int, a value in class `Keys`. Return bool.
bool uiautomation.uiautomation.IsProcess64Bit | ( | int | processId | ) |
Return True if process is 64 bit. Return False if process is 32 bit. Return None if unknown, maybe caused by having no acess right to the process.
bool uiautomation.uiautomation.IsTopLevelWindow | ( | int | handle | ) |
IsTopLevelWindow from Win32. handle: int, the handle of a native window. Return bool. Only available on Windows 7 or Higher.
bool uiautomation.uiautomation.IsUserAnAdmin | ( | ) |
IsUserAnAdmin from Win32. Return bool. Minimum supported OS: Windows XP, Windows Server 2003
bool uiautomation.uiautomation.IsWindowVisible | ( | int | handle | ) |
IsWindowVisible from Win32. handle: int, the handle of a native window. Return bool.
bool uiautomation.uiautomation.IsZoomed | ( | int | handle | ) |
IsZoomed from Win32. Determine whether a native window is maximized. handle: int, the handle of a native window. Return bool.
None uiautomation.uiautomation.keybd_event | ( | int | bVk, |
int | bScan, | ||
int | dwFlags, | ||
int | dwExtraInfo | ||
) |
keybd_event from Win32.
INPUT uiautomation.uiautomation.KeyboardInput | ( | int | wVk, |
int | wScan, | ||
int | dwFlags = KeyboardEventFlag.KeyDown , |
||
int | time_ = 0 |
||
) |
Create Win32 struct `KEYBDINPUT` for `SendInput`.
None uiautomation.uiautomation.LogControl | ( | Control | control, |
int | depth = 0 , |
||
bool | showAllName = True , |
||
bool | showPid = False |
||
) |
Print and log control's properties. control: `Control` or its subclass. depth: int, current depth. showAllName: bool, if False, print the first 30 characters of control.Name.
int uiautomation.uiautomation.MessageBox | ( | str | content, |
str | title, | ||
int | flags = MB.Ok |
||
) |
MessageBox from Win32. content: str. title: str. flags: int, a value or some combined values in class `MB`. Return int, a value in MB whose name starts with Id, such as MB.IdOk
None uiautomation.uiautomation.MiddleClick | ( | int | x, |
int | y, | ||
float | waitTime = OPERATION_WAIT_TIME |
||
) |
Simulate mouse middle click at point x, y. x: int. y: int. waitTime: float.
None uiautomation.uiautomation.MiddleDragDrop | ( | int | x1, |
int | y1, | ||
int | x2, | ||
int | y2, | ||
float | moveSpeed = 1 , |
||
float | waitTime = OPERATION_WAIT_TIME |
||
) |
Simulate mouse middle button drag from point x1, y1 drop to point x2, y2. x1: int. y1: int. x2: int. y2: int. moveSpeed: float, 1 normal speed, < 1 move slower, > 1 move faster. waitTime: float.
None uiautomation.uiautomation.MiddlePressMouse | ( | int | x, |
int | y, | ||
float | waitTime = OPERATION_WAIT_TIME |
||
) |
Press middle mouse. x: int. y: int. waitTime: float.
None uiautomation.uiautomation.MiddleReleaseMouse | ( | float | waitTime = OPERATION_WAIT_TIME | ) |
Release middle mouse. waitTime: float.
None uiautomation.uiautomation.mouse_event | ( | int | dwFlags, |
int | dx, | ||
int | dy, | ||
int | dwData, | ||
int | dwExtraInfo | ||
) |
mouse_event from Win32.
INPUT uiautomation.uiautomation.MouseInput | ( | int | dx, |
int | dy, | ||
int | mouseData = 0 , |
||
int | dwFlags = MouseEventFlag.LeftDown , |
||
int | time_ = 0 |
||
) |
Create Win32 struct `MOUSEINPUT` for `SendInput`. Return `INPUT`.
None uiautomation.uiautomation.MoveTo | ( | int | x, |
int | y, | ||
float | moveSpeed = 1 , |
||
float | waitTime = OPERATION_WAIT_TIME |
||
) |
Simulate mouse move to point x, y from current cursor. x: int. y: int. moveSpeed: float, 1 normal speed, < 1 move slower, > 1 move faster. waitTime: float.
bool uiautomation.uiautomation.MoveWindow | ( | int | handle, |
int | x, | ||
int | y, | ||
int | width, | ||
int | height, | ||
int | repaint = 1 |
||
) |
MoveWindow from Win32. handle: int, the handle of a native window. x: int. y: int. width: int. height: int. repaint: int, use 1 or 0. Return bool, True if succeed otherwise False.
bool uiautomation.uiautomation.PlayWaveFile | ( | str | filePath = r'C:\Windows\Media\notify.wav' , |
bool | isAsync = False , |
||
bool | isLoop = False |
||
) |
Call PlaySound from Win32. filePath: str, if emtpy, stop playing the current sound. isAsync: bool, if True, the sound is played asynchronously and returns immediately. isLoop: bool, if True, the sound plays repeatedly until PlayWaveFile(None) is called again, must also set isAsync to True. Return bool, True if succeed otherwise False.
bool uiautomation.uiautomation.PostMessage | ( | int | handle, |
int | msg, | ||
int | wParam, | ||
int | lParam | ||
) |
PostMessage from Win32. Return bool, True if succeed otherwise False.
None uiautomation.uiautomation.PressKey | ( | int | key, |
float | waitTime = OPERATION_WAIT_TIME |
||
) |
Simulate a key down for key. key: int, a value in class `Keys`. waitTime: float.
None uiautomation.uiautomation.PressMouse | ( | int | x, |
int | y, | ||
float | waitTime = OPERATION_WAIT_TIME |
||
) |
Press left mouse. x: int. y: int. waitTime: float.
None uiautomation.uiautomation.ReleaseKey | ( | int | key, |
float | waitTime = OPERATION_WAIT_TIME |
||
) |
Simulate a key up for key. key: int, a value in class `Keys`. waitTime: float.
None uiautomation.uiautomation.ReleaseMouse | ( | float | waitTime = OPERATION_WAIT_TIME | ) |
Release left mouse. waitTime: float.
bool uiautomation.uiautomation.ResetConsoleColor | ( | ) |
Reset to the default text color on console window. Return bool, True if succeed otherwise False.
None uiautomation.uiautomation.RightClick | ( | int | x, |
int | y, | ||
float | waitTime = OPERATION_WAIT_TIME |
||
) |
Simulate mouse right click at point x, y. x: int. y: int. waitTime: float.
None uiautomation.uiautomation.RightDragDrop | ( | int | x1, |
int | y1, | ||
int | x2, | ||
int | y2, | ||
float | moveSpeed = 1 , |
||
float | waitTime = OPERATION_WAIT_TIME |
||
) |
Simulate mouse right button drag from point x1, y1 drop to point x2, y2. x1: int. y1: int. x2: int. y2: int. moveSpeed: float, 1 normal speed, < 1 move slower, > 1 move faster. waitTime: float.
None uiautomation.uiautomation.RightPressMouse | ( | int | x, |
int | y, | ||
float | waitTime = OPERATION_WAIT_TIME |
||
) |
Press right mouse. x: int. y: int. waitTime: float.
None uiautomation.uiautomation.RightReleaseMouse | ( | float | waitTime = OPERATION_WAIT_TIME | ) |
Release right mouse. waitTime: float.
None uiautomation.uiautomation.RunByHotKey | ( | Dict[Tuple[int, int], Callable] | keyFunctions, |
Tuple[int, int] | stopHotKey = None , |
||
Tuple[int, int] | exitHotKey = (ModifierKey.Control, Keys.VK_D) , |
||
bool | waitHotKeyReleased = True |
||
) |
Bind functions with hotkeys, the function will be run or stopped in another thread when the hotkey is pressed. keyFunctions: Dict[Tuple[int, int], Callable], such as {(uiautomation.ModifierKey.Control, uiautomation.Keys.VK_1) : function} stopHotKey: hotkey tuple exitHotKey: hotkey tuple waitHotKeyReleased: bool, if True, hotkey function will be triggered after the hotkey is released def main(stopEvent): while True: if stopEvent.is_set(): # must check stopEvent.is_set() if you want to stop when stop hotkey is pressed break print(n) n += 1 stopEvent.wait(1) print('main exit') uiautomation.RunByHotKey({(uiautomation.ModifierKey.Control, uiautomation.Keys.VK_1) : main} , (uiautomation.ModifierKey.Control | uiautomation.ModifierKey.Shift, uiautomation.Keys.VK_2))
bool uiautomation.uiautomation.RunScriptAsAdmin | ( | List[str] | argv, |
str | workingDirectory = None , |
||
int | showFlag = SW.ShowNormal |
||
) |
Run a python script as administrator. System will show a popup dialog askes you whether to elevate as administrator if UAC is enabled. argv: List[str], a str list like sys.argv, argv[0] is the script file, argv[1:] are other arguments. workingDirectory: str, the working directory for the script file. showFlag: int, a value in class `SW`. Return bool, True if succeed.
int uiautomation.uiautomation.SendInput | ( | * | inputs | ) |
SendInput from Win32. input: `INPUT`. Return int, the number of events that it successfully inserted into the keyboard or mouse input stream. If the function returns zero, the input was already blocked by another thread.
None uiautomation.uiautomation.SendKey | ( | int | key, |
float | waitTime = OPERATION_WAIT_TIME |
||
) |
Simulate typing a key. key: int, a value in class `Keys`.
None uiautomation.uiautomation.SendKeys | ( | str | text, |
float | interval = 0.01 , |
||
float | waitTime = OPERATION_WAIT_TIME , |
||
bool | charMode = True , |
||
bool | debug = False |
||
) |
Simulate typing keys on keyboard. text: str, keys to type. interval: float, seconds between keys. waitTime: float. charMode: bool, if False, the text typied is depend on the input method if a input method is on. debug: bool, if True, print the keys. Examples: {Ctrl}, {Delete} ... are special keys' name in SpecialKeyNames. SendKeys('{Ctrl}a{Delete}{Ctrl}v{Ctrl}s{Ctrl}{Shift}s{Win}e{PageDown}') #press Ctrl+a, Delete, Ctrl+v, Ctrl+s, Ctrl+Shift+s, Win+e, PageDown SendKeys('{Ctrl}(AB)({Shift}(123))') #press Ctrl+A+B, type (, press Shift+1+2+3, type ), if () follows a hold key, hold key won't release util ) SendKeys('{Ctrl}{a 3}') #press Ctrl+a at the same time, release Ctrl+a, then type a 2 times SendKeys('{a 3}{B 5}') #type a 3 times, type B 5 times SendKeys('{{}Hello{}}abc {a}{b}{c} test{} 3}{!}{a} (){(}{)}') #type: {Hello}abc abc test}}}!a ()() SendKeys('0123456789{Enter}') SendKeys('ABCDEFGHIJKLMNOPQRSTUVWXYZ{Enter}') SendKeys('abcdefghijklmnopqrstuvwxyz{Enter}') SendKeys('`~!@#$%^&*()-_=+{Enter}') SendKeys('[]{{}{}}\\|;:\'\",<.>/?{Enter}')
int uiautomation.uiautomation.SendMessage | ( | int | handle, |
int | msg, | ||
int | wParam, | ||
int | lParam | ||
) |
SendMessage from Win32. Return int, the return value specifies the result of the message processing; it depends on the message sent.
int uiautomation.uiautomation.SendUnicodeChar | ( | str | char, |
bool | charMode = True |
||
) |
Type a single unicode char. char: str, len(char) must equal to 1. charMode: bool, if False, the char typied is depend on the input method if a input method is on. Return int, the number of events that it successfully inserted into the keyboard or mouse input stream. If the function returns zero, the input was already blocked by another thread.
bool uiautomation.uiautomation.SetClipboardText | ( | str | text | ) |
Return bool, True if succeed otherwise False.
bool uiautomation.uiautomation.SetConsoleColor | ( | int | color | ) |
Change the text color on console window. color: int, a value in class `ConsoleColor`. Return bool, True if succeed otherwise False.
bool uiautomation.uiautomation.SetConsoleTitle | ( | str | text | ) |
SetConsoleTitle from Win32. text: str. Return bool, True if succeed otherwise False.
bool uiautomation.uiautomation.SetCursorPos | ( | int | x, |
int | y | ||
) |
SetCursorPos from Win32. Set mouse cursor to point x, y. x: int. y: int. Return bool, True if succeed otherwise False.
int uiautomation.uiautomation.SetDpiAwareness | ( | bool | dpiAwarenessPerMonitor = True | ) |
Call SetThreadDpiAwarenessContext(Windows 10 version 1607+) or SetProcessDpiAwareness(Windows 8.1+). You should call this function with True if you enable DPI scaling. uiautomation calls this function when it initializes. dpiAwarenessPerMonitor: bool. Return int.
bool uiautomation.uiautomation.SetForegroundWindow | ( | int | handle | ) |
SetForegroundWindow from Win32. handle: int, the handle of a native window. Return bool, True if succeed otherwise False.
None uiautomation.uiautomation.SetGlobalSearchTimeout | ( | float | seconds | ) |
seconds: float. To make this available, you need explicitly import uiautomation: from uiautomation import uiautomation as auto auto.SetGlobalSearchTimeout(10)
int uiautomation.uiautomation.SetWindowLong | ( | int | handle, |
int | index, | ||
int | value | ||
) |
SetWindowLong from Win32. handle: int, the handle of a native window. index: int. value: int. Return int, the previous value before set.
bool uiautomation.uiautomation.SetWindowPos | ( | int | handle, |
int | hWndInsertAfter, | ||
int | x, | ||
int | y, | ||
int | width, | ||
int | height, | ||
int | flags | ||
) |
SetWindowPos from Win32. handle: int, the handle of a native window. hWndInsertAfter: int, a value whose name starts with 'HWND' in class SWP. x: int. y: int. width: int. height: int. flags: int, values whose name starts with 'SWP' in class `SWP`. Return bool, True if succeed otherwise False.
bool uiautomation.uiautomation.SetWindowText | ( | int | handle, |
str | text | ||
) |
SetWindowText from Win32. handle: int, the handle of a native window. text: str. Return bool, True if succeed otherwise False.
bool uiautomation.uiautomation.SetWindowTopmost | ( | int | handle, |
bool | isTopmost | ||
) |
handle: int, the handle of a native window. isTopmost: bool Return bool, True if succeed otherwise False.
None uiautomation.uiautomation.ShowDesktop | ( | float | waitTime = 1 | ) |
Show Desktop by pressing win + d
bool uiautomation.uiautomation.ShowWindow | ( | int | handle, |
int | cmdShow | ||
) |
ShowWindow from Win32. handle: int, the handle of a native window. cmdShow: int, a value in clas `SW`. Return bool, True if succeed otherwise False.
None uiautomation.uiautomation.SwitchToThisWindow | ( | int | handle | ) |
SwitchToThisWindow from Win32. handle: int, the handle of a native window.
None uiautomation.uiautomation.UninitializeUIAutomationInCurrentThread | ( | ) |
Uninitialize UIAutomation in a new thread after calling InitializeUIAutomationInCurrentThread. You must call this function when the new thread exits if you have called InitializeUIAutomationInCurrentThread in the same thread.
bool uiautomation.uiautomation.WaitForDisappear | ( | Control | control, |
float | timeout | ||
) |
Check if control disappears in timeout seconds. control: `Control` or its subclass. timeout: float. Return bool.
bool uiautomation.uiautomation.WaitForExist | ( | Control | control, |
float | timeout | ||
) |
Check if control exists in timeout seconds. control: `Control` or its subclass. timeout: float. Return bool.
None uiautomation.uiautomation.WaitHotKeyReleased | ( | Tuple[int, int] | hotkey | ) |
hotkey: Tuple[int, int], two ints tuple (modifierKey, key)
def uiautomation.uiautomation.WalkControl | ( | Control | control, |
bool | includeTop = False , |
||
int | maxDepth = 0xFFFFFFFF |
||
) |
control: `Control` or its subclass. includeTop: bool, if True, yield (control, 0) first. maxDepth: int, enum depth. Yield 2 items tuple (control: Control, depth: int).
def uiautomation.uiautomation.WalkTree | ( | top, | |
Callable[[TreeNode], List[TreeNode]] | getChildren = None , |
||
Callable[[TreeNode], TreeNode] | getFirstChild = None , |
||
Callable[[TreeNode], TreeNode] | getNextSibling = None , |
||
Callable[[TreeNode, int], bool] | yieldCondition = None , |
||
bool | includeTop = False , |
||
int | maxDepth = 0xFFFFFFFF |
||
) |
Walk a tree not using recursive algorithm. top: a tree node. getChildren: Callable[[TreeNode], List[TreeNode]], function(treeNode: TreeNode) -> List[TreeNode]. getNextSibling: Callable[[TreeNode], TreeNode], function(treeNode: TreeNode) -> TreeNode. getNextSibling: Callable[[TreeNode], TreeNode], function(treeNode: TreeNode) -> TreeNode. yieldCondition: Callable[[TreeNode, int], bool], function(treeNode: TreeNode, depth: int) -> bool. includeTop: bool, if True yield top first. maxDepth: int, enum depth. If getChildren is valid, ignore getFirstChild and getNextSibling, yield 3 items tuple: (treeNode, depth, remain children count in current depth). If getChildren is not valid, using getFirstChild and getNextSibling, yield 2 items tuple: (treeNode, depth). If yieldCondition is not None, only yield tree nodes that yieldCondition(treeNode: TreeNode, depth: int)->bool returns True. For example: def GetDirChildren(dir_): if os.path.isdir(dir_): return [os.path.join(dir_, it) for it in os.listdir(dir_)] for it, depth, leftCount in WalkTree('D:\\', getChildren= GetDirChildren): print(it, depth, leftCount)
None uiautomation.uiautomation.WheelDown | ( | int | wheelTimes = 1 , |
float | interval = 0.05 , |
||
float | waitTime = OPERATION_WAIT_TIME |
||
) |
Simulate mouse wheel down. wheelTimes: int. interval: float. waitTime: float.
None uiautomation.uiautomation.WheelUp | ( | int | wheelTimes = 1 , |
float | interval = 0.05 , |
||
float | waitTime = OPERATION_WAIT_TIME |
||
) |
Simulate mouse wheel up. wheelTimes: int. interval: float. waitTime: float.
int uiautomation.uiautomation.WindowFromPoint | ( | int | x, |
int | y | ||
) |
WindowFromPoint from Win32. Return int, a native window handle.
string uiautomation.uiautomation.AUTHOR_MAIL = 'yinkaisheng@live.com' |
uiautomation.uiautomation.c = ctor() |
dictionary uiautomation.uiautomation.CharacterCodes |
uiautomation.uiautomation.children = notepad.GetChildren() |
dictionary uiautomation.uiautomation.ControlConstructors |
dictionary uiautomation.uiautomation.ControlTypeNames |
bool uiautomation.uiautomation.DEBUG_EXIST_DISAPPEAR = False |
bool uiautomation.uiautomation.DEBUG_SEARCH_TIME = False |
string uiautomation.uiautomation.hello = '{Ctrl}{End}{Enter}Hello World! 你好世界!' |
int uiautomation.uiautomation.IsNT6orHigher = 6 |
uiautomation.uiautomation.lp = notepad.GetLegacyIAccessiblePattern() |
int uiautomation.uiautomation.MAX_MOVE_SECOND = 1 |
int uiautomation.uiautomation.MAX_PATH = 260 |
string uiautomation.uiautomation.METRO_WINDOW_CLASS_NAME = 'Windows.UI.Core.CoreWindow' |
uiautomation.uiautomation.notepad = WindowControl(searchDepth=1, ClassName='Notepad') |
float uiautomation.uiautomation.OPERATION_WAIT_TIME = 0.5 |
dictionary uiautomation.uiautomation.PatternConstructors |
dictionary uiautomation.uiautomation.PatternIdNames |
uiautomation.uiautomation.ProcessTime = time.perf_counter |
dictionary uiautomation.uiautomation.PropertyIdNames |
int uiautomation.uiautomation.S_OK = 0 |
float uiautomation.uiautomation.SEARCH_INTERVAL = 0.5 |
dictionary uiautomation.uiautomation.SpecialKeyNames |
int uiautomation.uiautomation.TIME_OUT_SECOND = 10 |
uiautomation.uiautomation.TreeNode = Any |
uiautomation.uiautomation.value = notepad.GetPropertyValue(k) |