code
stringlengths 66
870k
| docstring
stringlengths 19
26.7k
| func_name
stringlengths 1
138
| language
stringclasses 1
value | repo
stringlengths 7
68
| path
stringlengths 5
324
| url
stringlengths 46
389
| license
stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def __init__(self, typ, name=None, coercible_types=None):
"""
`typ` should be a Python type. `coercible_types` is a list of
additional accepted types. However, the final value will be
coerced to `typ`.
`name` is an optional name. By default, a name will be derived
from `typ`.
"""
self.typ = typ
self.name = name or typ.__name__.capitalize()
self.coercible_types = coercible_types
|
`typ` should be a Python type. `coercible_types` is a list of
additional accepted types. However, the final value will be
coerced to `typ`.
`name` is an optional name. By default, a name will be derived
from `typ`.
|
__init__
|
python
|
hyperdiv/hyperdiv
|
hyperdiv/prop_types/native.py
|
https://github.com/hyperdiv/hyperdiv/blob/master/hyperdiv/prop_types/native.py
|
Apache-2.0
|
def test_click_twice():
"""
Test that an update batch containing updates to the same prop
schedules those updates in different frames.
"""
button_key = None
text_key = None
def my_app():
nonlocal button_key, text_key
s = state(count=0)
b = button("Click Me")
button_key = b._key
if b.clicked:
s.count += 1
t = plaintext(s.count)
text_key = t._key
with MockRunner(my_app) as mr:
mr.process_updates(
[
(button_key, "clicked", True),
(button_key, "clicked", True),
]
)
assert mr.get_state(text_key, "content") == "2"
|
Test that an update batch containing updates to the same prop
schedules those updates in different frames.
|
test_click_twice
|
python
|
hyperdiv/hyperdiv
|
hyperdiv/tests/app_runner_tests.py
|
https://github.com/hyperdiv/hyperdiv/blob/master/hyperdiv/tests/app_runner_tests.py
|
Apache-2.0
|
def instance(cls) -> '_AutomationClient':
"""Singleton instance (this prevents com creation on import)."""
if cls._instance is None:
cls._instance = cls()
return cls._instance
|
Singleton instance (this prevents com creation on import).
|
instance
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def SetClipboardText(text: str) -> bool:
"""
Return bool, True if succeed otherwise False.
"""
if ctypes.windll.user32.OpenClipboard(0):
ctypes.windll.user32.EmptyClipboard()
textByteLen = (len(text) + 1) * 2
hClipboardData = ctypes.windll.kernel32.GlobalAlloc(0, textByteLen) # GMEM_FIXED=0
hDestText = ctypes.windll.kernel32.GlobalLock(ctypes.c_void_p(hClipboardData))
ctypes.cdll.msvcrt.wcsncpy(ctypes.c_wchar_p(hDestText), ctypes.c_wchar_p(text), ctypes.c_size_t(textByteLen // 2))
ctypes.windll.kernel32.GlobalUnlock(ctypes.c_void_p(hClipboardData))
# system owns hClipboardData after calling SetClipboardData,
# application can not write to or free the data once ownership has been transferred to the system
ctypes.windll.user32.SetClipboardData(ctypes.c_uint(13), ctypes.c_void_p(hClipboardData)) # CF_TEXT=1, CF_UNICODETEXT=13
ctypes.windll.user32.CloseClipboard()
return True
return False
|
Return bool, True if succeed otherwise False.
|
SetClipboardText
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def SetConsoleColor(color: int) -> bool:
"""
Change the text color on console window.
color: int, a value in class `ConsoleColor`.
Return bool, True if succeed otherwise False.
"""
global _ConsoleOutputHandle
global _DefaultConsoleColor
if not _DefaultConsoleColor:
if not _ConsoleOutputHandle:
_ConsoleOutputHandle = ctypes.c_void_p(ctypes.windll.kernel32.GetStdHandle(_StdOutputHandle))
bufferInfo = ConsoleScreenBufferInfo()
ctypes.windll.kernel32.GetConsoleScreenBufferInfo(_ConsoleOutputHandle, ctypes.byref(bufferInfo))
_DefaultConsoleColor = int(bufferInfo.wAttributes & 0xFF)
if sys.stdout:
sys.stdout.flush()
return bool(ctypes.windll.kernel32.SetConsoleTextAttribute(_ConsoleOutputHandle, ctypes.c_ushort(color)))
|
Change the text color on console window.
color: int, a value in class `ConsoleColor`.
Return bool, True if succeed otherwise False.
|
SetConsoleColor
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def ResetConsoleColor() -> bool:
"""
Reset to the default text color on console window.
Return bool, True if succeed otherwise False.
"""
if sys.stdout:
sys.stdout.flush()
return bool(ctypes.windll.kernel32.SetConsoleTextAttribute(_ConsoleOutputHandle, ctypes.c_ushort(_DefaultConsoleColor)))
|
Reset to the default text color on console window.
Return bool, True if succeed otherwise False.
|
ResetConsoleColor
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def GetCursorPos() -> Tuple[int, int]:
"""
GetCursorPos from Win32.
Get current mouse cursor positon.
Return Tuple[int, int], two ints tuple (x, y).
"""
point = ctypes.wintypes.POINT(0, 0)
ctypes.windll.user32.GetCursorPos(ctypes.byref(point))
return point.x, point.y
|
GetCursorPos from Win32.
Get current mouse cursor positon.
Return Tuple[int, int], two ints tuple (x, y).
|
GetCursorPos
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def Click(x: int, y: int, waitTime: float = OPERATION_WAIT_TIME) -> None:
"""
Simulate mouse click at point x, y.
x: int.
y: int.
waitTime: float.
"""
SetCursorPos(x, y)
screenWidth, screenHeight = GetScreenSize()
mouse_event(MouseEventFlag.LeftDown | MouseEventFlag.Absolute, x * 65535 // screenWidth, y * 65535 // screenHeight, 0, 0)
time.sleep(0.05)
mouse_event(MouseEventFlag.LeftUp | MouseEventFlag.Absolute, x * 65535 // screenWidth, y * 65535 // screenHeight, 0, 0)
time.sleep(waitTime)
|
Simulate mouse click at point x, y.
x: int.
y: int.
waitTime: float.
|
Click
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def MiddleClick(x: int, y: int, waitTime: float = OPERATION_WAIT_TIME) -> None:
"""
Simulate mouse middle click at point x, y.
x: int.
y: int.
waitTime: float.
"""
SetCursorPos(x, y)
screenWidth, screenHeight = GetScreenSize()
mouse_event(MouseEventFlag.MiddleDown | MouseEventFlag.Absolute, x * 65535 // screenWidth, y * 65535 // screenHeight, 0, 0)
time.sleep(0.05)
mouse_event(MouseEventFlag.MiddleUp | MouseEventFlag.Absolute, x * 65535 // screenWidth, y * 65535 // screenHeight, 0, 0)
time.sleep(waitTime)
|
Simulate mouse middle click at point x, y.
x: int.
y: int.
waitTime: float.
|
MiddleClick
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def RightClick(x: int, y: int, waitTime: float = OPERATION_WAIT_TIME) -> None:
"""
Simulate mouse right click at point x, y.
x: int.
y: int.
waitTime: float.
"""
SetCursorPos(x, y)
screenWidth, screenHeight = GetScreenSize()
mouse_event(MouseEventFlag.RightDown | MouseEventFlag.Absolute, x * 65535 // screenWidth, y * 65535 // screenHeight, 0, 0)
time.sleep(0.05)
mouse_event(MouseEventFlag.RightUp | MouseEventFlag.Absolute, x * 65535 // screenWidth, y * 65535 // screenHeight, 0, 0)
time.sleep(waitTime)
|
Simulate mouse right click at point x, y.
x: int.
y: int.
waitTime: float.
|
RightClick
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def PressMouse(x: int, y: int, waitTime: float = OPERATION_WAIT_TIME) -> None:
"""
Press left mouse.
x: int.
y: int.
waitTime: float.
"""
SetCursorPos(x, y)
screenWidth, screenHeight = GetScreenSize()
mouse_event(MouseEventFlag.LeftDown | MouseEventFlag.Absolute, x * 65535 // screenWidth, y * 65535 // screenHeight, 0, 0)
time.sleep(waitTime)
|
Press left mouse.
x: int.
y: int.
waitTime: float.
|
PressMouse
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def RightPressMouse(x: int, y: int, waitTime: float = OPERATION_WAIT_TIME) -> None:
"""
Press right mouse.
x: int.
y: int.
waitTime: float.
"""
SetCursorPos(x, y)
screenWidth, screenHeight = GetScreenSize()
mouse_event(MouseEventFlag.RightDown | MouseEventFlag.Absolute, x * 65535 // screenWidth, y * 65535 // screenHeight, 0, 0)
time.sleep(waitTime)
|
Press right mouse.
x: int.
y: int.
waitTime: float.
|
RightPressMouse
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def MiddlePressMouse(x: int, y: int, waitTime: float = OPERATION_WAIT_TIME) -> None:
"""
Press middle mouse.
x: int.
y: int.
waitTime: float.
"""
SetCursorPos(x, y)
screenWidth, screenHeight = GetScreenSize()
mouse_event(MouseEventFlag.MiddleDown | MouseEventFlag.Absolute, x * 65535 // screenWidth, y * 65535 // screenHeight, 0, 0)
time.sleep(waitTime)
|
Press middle mouse.
x: int.
y: int.
waitTime: float.
|
MiddlePressMouse
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def MoveTo(x: int, y: int, moveSpeed: float = 1, waitTime: float = OPERATION_WAIT_TIME) -> None:
"""
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.
"""
if moveSpeed <= 0:
moveTime = 0
else:
moveTime = MAX_MOVE_SECOND / moveSpeed
curX, curY = GetCursorPos()
xCount = abs(x - curX)
yCount = abs(y - curY)
maxPoint = max(xCount, yCount)
screenWidth, screenHeight = GetScreenSize()
maxSide = max(screenWidth, screenHeight)
minSide = min(screenWidth, screenHeight)
if maxPoint > minSide:
maxPoint = minSide
if maxPoint < maxSide:
maxPoint = 100 + int((maxSide - 100) / maxSide * maxPoint)
moveTime = moveTime * maxPoint * 1.0 / maxSide
stepCount = maxPoint // 20
if stepCount > 1:
xStep = (x - curX) * 1.0 / stepCount
yStep = (y - curY) * 1.0 / stepCount
interval = moveTime / stepCount
for i in range(stepCount):
cx = curX + int(xStep * i)
cy = curY + int(yStep * i)
# upper-left(0,0), lower-right(65536,65536)
# mouse_event(MouseEventFlag.Move | MouseEventFlag.Absolute, cx*65536//screenWidth, cy*65536//screenHeight, 0, 0)
SetCursorPos(cx, cy)
time.sleep(interval)
SetCursorPos(x, y)
time.sleep(waitTime)
|
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.
|
MoveTo
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def DragDrop(x1: int, y1: int, x2: int, y2: int, moveSpeed: float = 1, waitTime: float = OPERATION_WAIT_TIME) -> None:
"""
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.
"""
PressMouse(x1, y1, 0.05)
MoveTo(x2, y2, moveSpeed, 0.05)
ReleaseMouse(waitTime)
|
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.
|
DragDrop
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def RightDragDrop(x1: int, y1: int, x2: int, y2: int, moveSpeed: float = 1, waitTime: float = OPERATION_WAIT_TIME) -> None:
"""
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.
"""
RightPressMouse(x1, y1, 0.05)
MoveTo(x2, y2, moveSpeed, 0.05)
RightReleaseMouse(waitTime)
|
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.
|
RightDragDrop
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def MiddleDragDrop(x1: int, y1: int, x2: int, y2: int, moveSpeed: float = 1, waitTime: float = OPERATION_WAIT_TIME) -> None:
"""
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.
"""
MiddlePressMouse(x1, y1, 0.05)
MoveTo(x2, y2, moveSpeed, 0.05)
MiddleReleaseMouse(waitTime)
|
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.
|
MiddleDragDrop
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def WheelDown(wheelTimes: int = 1, interval: float = 0.05, waitTime: float = OPERATION_WAIT_TIME) -> None:
"""
Simulate mouse wheel down.
wheelTimes: int.
interval: float.
waitTime: float.
"""
for i in range(wheelTimes):
mouse_event(MouseEventFlag.Wheel, 0, 0, -120, 0) #WHEEL_DELTA=120
time.sleep(interval)
time.sleep(waitTime)
|
Simulate mouse wheel down.
wheelTimes: int.
interval: float.
waitTime: float.
|
WheelDown
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def WheelUp(wheelTimes: int = 1, interval: float = 0.05, waitTime: float = OPERATION_WAIT_TIME) -> None:
"""
Simulate mouse wheel up.
wheelTimes: int.
interval: float.
waitTime: float.
"""
for i in range(wheelTimes):
mouse_event(MouseEventFlag.Wheel, 0, 0, 120, 0) #WHEEL_DELTA=120
time.sleep(interval)
time.sleep(waitTime)
|
Simulate mouse wheel up.
wheelTimes: int.
interval: float.
waitTime: float.
|
WheelUp
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def SetDpiAwareness(dpiAwarenessPerMonitor: bool = True) -> int:
'''
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.
'''
try:
# https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setthreaddpiawarenesscontext
# Windows 10 1607+
ctypes.windll.user32.SetThreadDpiAwarenessContext.restype = ctypes.c_void_p
context = DpiAwarenessContext.DpiAwarenessContextPerMonitorAware if dpiAwarenessPerMonitor else DpiAwarenessContext.DpiAwarenessContextUnaware
oldContext = ctypes.windll.user32.SetThreadDpiAwarenessContext(ctypes.c_void_p(context))
return oldContext
except Exception as ex:
try:
# https://docs.microsoft.com/en-us/windows/win32/api/shellscalingapi/nf-shellscalingapi-setprocessdpiawareness
# Once SetProcessDpiAwareness is set for an app, any future calls to SetProcessDpiAwareness will fail.
# Windows 8.1+
if dpiAwarenessPerMonitor:
return ctypes.windll.shcore.SetProcessDpiAwareness(ProcessDpiAwareness.ProcessPerMonitorDpiAware)
except Exception as ex2:
pass
|
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.
|
SetDpiAwareness
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def GetScreenSize(dpiAwarenessPerMonitor: bool = True) -> Tuple[int, int]:
"""
dpiAwarenessPerMonitor: bool.
Return Tuple[int, int], two ints tuple (width, height).
"""
SetDpiAwareness(dpiAwarenessPerMonitor)
SM_CXSCREEN = 0
SM_CYSCREEN = 1
w = ctypes.windll.user32.GetSystemMetrics(SM_CXSCREEN)
h = ctypes.windll.user32.GetSystemMetrics(SM_CYSCREEN)
return w, h
|
dpiAwarenessPerMonitor: bool.
Return Tuple[int, int], two ints tuple (width, height).
|
GetScreenSize
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def GetMonitorsRect(dpiAwarenessPerMonitor: bool = False) -> List[Rect]:
"""
Get monitors' rect.
dpiAwarenessPerMonitor: bool.
Return List[Rect].
"""
SetDpiAwareness(dpiAwarenessPerMonitor)
MonitorEnumProc = ctypes.WINFUNCTYPE(ctypes.c_int, ctypes.c_size_t, ctypes.c_size_t, ctypes.POINTER(ctypes.wintypes.RECT), ctypes.c_size_t)
rects = []
def MonitorCallback(hMonitor: int, hdcMonitor: int, lprcMonitor: ctypes.POINTER(ctypes.wintypes.RECT), dwData: int):
rect = Rect(lprcMonitor.contents.left, lprcMonitor.contents.top, lprcMonitor.contents.right, lprcMonitor.contents.bottom)
rects.append(rect)
return 1
ret = ctypes.windll.user32.EnumDisplayMonitors(ctypes.c_void_p(0), ctypes.c_void_p(0), MonitorEnumProc(MonitorCallback), 0)
return rects
|
Get monitors' rect.
dpiAwarenessPerMonitor: bool.
Return List[Rect].
|
GetMonitorsRect
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def GetPixelColor(x: int, y: int, handle: int = 0) -> int:
"""
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.
"""
hdc = ctypes.windll.user32.GetWindowDC(ctypes.c_void_p(handle))
bgr = ctypes.windll.gdi32.GetPixel(hdc, x, y)
ctypes.windll.user32.ReleaseDC(ctypes.c_void_p(handle), ctypes.c_void_p(hdc))
return bgr
|
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.
|
GetPixelColor
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def SetWindowTopmost(handle: int, isTopmost: bool) -> bool:
"""
handle: int, the handle of a native window.
isTopmost: bool
Return bool, True if succeed otherwise False.
"""
topValue = SWP.HWND_Topmost if isTopmost else SWP.HWND_NoTopmost
return bool(SetWindowPos(handle, topValue, 0, 0, 0, 0, SWP.SWP_NoSize | SWP.SWP_NoMove))
|
handle: int, the handle of a native window.
isTopmost: bool
Return bool, True if succeed otherwise False.
|
SetWindowTopmost
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def GetWindowText(handle: int) -> str:
"""
GetWindowText from Win32.
handle: int, the handle of a native window.
Return str.
"""
arrayType = ctypes.c_wchar * MAX_PATH
values = arrayType()
ctypes.windll.user32.GetWindowTextW(ctypes.c_void_p(handle), values, ctypes.c_int(MAX_PATH))
return values.value
|
GetWindowText from Win32.
handle: int, the handle of a native window.
Return str.
|
GetWindowText
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def GetEditText(handle: int) -> str:
"""
Get text of a native Win32 Edit.
handle: int, the handle of a native window.
Return str.
"""
textLen = SendMessage(handle, 0x000E, 0, 0) + 1 #WM_GETTEXTLENGTH
arrayType = ctypes.c_wchar * textLen
values = arrayType()
SendMessage(handle, 0x000D, textLen, values) #WM_GETTEXT
return values.value
|
Get text of a native Win32 Edit.
handle: int, the handle of a native window.
Return str.
|
GetEditText
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def GetConsoleOriginalTitle() -> str:
"""
GetConsoleOriginalTitle from Win32.
Return str.
Only available on Windows Vista or higher.
"""
if IsNT6orHigher:
arrayType = ctypes.c_wchar * MAX_PATH
values = arrayType()
ctypes.windll.kernel32.GetConsoleOriginalTitleW(values, ctypes.c_uint(MAX_PATH))
return values.value
else:
raise RuntimeError('GetConsoleOriginalTitle is not supported on Windows XP or lower.')
|
GetConsoleOriginalTitle from Win32.
Return str.
Only available on Windows Vista or higher.
|
GetConsoleOriginalTitle
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def IsDesktopLocked() -> bool:
"""
Check if desktop is locked.
Return bool.
Desktop is locked if press Win+L, Ctrl+Alt+Del or in remote desktop mode.
"""
isLocked = False
desk = ctypes.windll.user32.OpenDesktopW(ctypes.c_wchar_p('Default'), ctypes.c_uint(0), ctypes.c_int(0), ctypes.c_uint(0x0100)) # DESKTOP_SWITCHDESKTOP = 0x0100
if desk:
isLocked = not ctypes.windll.user32.SwitchDesktop(ctypes.c_void_p(desk))
ctypes.windll.user32.CloseDesktop(ctypes.c_void_p(desk))
return isLocked
|
Check if desktop is locked.
Return bool.
Desktop is locked if press Win+L, Ctrl+Alt+Del or in remote desktop mode.
|
IsDesktopLocked
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def PlayWaveFile(filePath: str = r'C:\Windows\Media\notify.wav', isAsync: bool = False, isLoop: bool = False) -> bool:
"""
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.
"""
if filePath:
SND_ASYNC = 0x0001
SND_NODEFAULT = 0x0002
SND_LOOP = 0x0008
SND_FILENAME = 0x20000
flags = SND_NODEFAULT | SND_FILENAME
if isAsync:
flags |= SND_ASYNC
if isLoop:
flags |= SND_LOOP
flags |= SND_ASYNC
return bool(ctypes.windll.winmm.PlaySoundW(ctypes.c_wchar_p(filePath), ctypes.c_void_p(0), ctypes.c_uint(flags)))
else:
return bool(ctypes.windll.winmm.PlaySoundW(ctypes.c_wchar_p(0), ctypes.c_void_p(0), ctypes.c_uint(0)))
|
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.
|
PlayWaveFile
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def IsProcess64Bit(processId: int) -> bool:
"""
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.
"""
try:
func = ctypes.windll.ntdll.ZwWow64ReadVirtualMemory64 #only 64 bit OS has this function
except Exception as ex:
return False
try:
IsWow64Process = ctypes.windll.kernel32.IsWow64Process
except Exception as ex:
return False
hProcess = ctypes.windll.kernel32.OpenProcess(0x1000, 0, processId) #PROCESS_QUERY_INFORMATION=0x0400,PROCESS_QUERY_LIMITED_INFORMATION=0x1000
if hProcess:
is64Bit = ctypes.c_int32()
if IsWow64Process(ctypes.c_void_p(hProcess), ctypes.byref(is64Bit)):
ctypes.windll.kernel32.CloseHandle(ctypes.c_void_p(hProcess))
return False if is64Bit.value else True
else:
ctypes.windll.kernel32.CloseHandle(ctypes.c_void_p(hProcess))
|
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.
|
IsProcess64Bit
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def RunScriptAsAdmin(argv: List[str], workingDirectory: str = None, showFlag: int = SW.ShowNormal) -> bool:
"""
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.
"""
args = ' '.join('"{}"'.format(arg) for arg in argv)
return ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, args, workingDirectory, showFlag) > 32
|
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.
|
RunScriptAsAdmin
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def SendKey(key: int, waitTime: float = OPERATION_WAIT_TIME) -> None:
"""
Simulate typing a key.
key: int, a value in class `Keys`.
"""
keybd_event(key, 0, KeyboardEventFlag.KeyDown | KeyboardEventFlag.ExtendedKey, 0)
keybd_event(key, 0, KeyboardEventFlag.KeyUp | KeyboardEventFlag.ExtendedKey, 0)
time.sleep(waitTime)
|
Simulate typing a key.
key: int, a value in class `Keys`.
|
SendKey
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def IsKeyPressed(key: int) -> bool:
"""
key: int, a value in class `Keys`.
Return bool.
"""
state = ctypes.windll.user32.GetAsyncKeyState(key)
return bool(state & 0x8000)
|
key: int, a value in class `Keys`.
Return bool.
|
IsKeyPressed
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def _CreateInput(structure) -> INPUT:
"""
Create Win32 struct `INPUT` for `SendInput`.
Return `INPUT`.
"""
if isinstance(structure, MOUSEINPUT):
return INPUT(InputType.Mouse, _INPUTUnion(mi=structure))
if isinstance(structure, KEYBDINPUT):
return INPUT(InputType.Keyboard, _INPUTUnion(ki=structure))
if isinstance(structure, HARDWAREINPUT):
return INPUT(InputType.Hardware, _INPUTUnion(hi=structure))
raise TypeError('Cannot create INPUT structure!')
|
Create Win32 struct `INPUT` for `SendInput`.
Return `INPUT`.
|
_CreateInput
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def SendInput(*inputs) -> int:
"""
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.
"""
cbSize = ctypes.c_int(ctypes.sizeof(INPUT))
for ip in inputs:
ret = ctypes.windll.user32.SendInput(1, ctypes.byref(ip), cbSize)
return ret
#or one call
#nInputs = len(inputs)
#LPINPUT = INPUT * nInputs
#pInputs = LPINPUT(*inputs)
#cbSize = ctypes.c_int(ctypes.sizeof(INPUT))
#return ctypes.windll.user32.SendInput(nInputs, ctypes.byref(pInputs), cbSize)
|
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.
|
SendInput
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def SendUnicodeChar(char: str, charMode: bool = True) -> int:
"""
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.
"""
if charMode:
vk = 0
scan = ord(char)
flag = KeyboardEventFlag.KeyUnicode
else:
res = ctypes.windll.user32.VkKeyScanW(ctypes.wintypes.WCHAR(char))
if (res >> 8) & 0xFF == 0:
vk = res & 0xFF
scan = 0
flag = 0
else:
vk = 0
scan = ord(char)
flag = KeyboardEventFlag.KeyUnicode
return SendInput(KeyboardInput(vk, scan, flag | KeyboardEventFlag.KeyDown),
KeyboardInput(vk, scan, flag | KeyboardEventFlag.KeyUp))
|
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.
|
SendUnicodeChar
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def _VKtoSC(key: int) -> int:
"""
This function is only for internal use in SendKeys.
key: int, a value in class `Keys`.
Return int.
"""
if key in _SCKeys:
return _SCKeys[key]
scanCode = ctypes.windll.user32.MapVirtualKeyA(key, 0)
if not scanCode:
return 0
keyList = [Keys.VK_APPS, Keys.VK_CANCEL, Keys.VK_SNAPSHOT, Keys.VK_DIVIDE, Keys.VK_NUMLOCK]
if key in keyList:
scanCode |= 0x0100
return scanCode
|
This function is only for internal use in SendKeys.
key: int, a value in class `Keys`.
Return int.
|
_VKtoSC
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def SendKeys(text: str, interval: float = 0.01, waitTime: float = OPERATION_WAIT_TIME, charMode: bool = True, debug: bool = False) -> None:
"""
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}')
"""
holdKeys = ('WIN', 'LWIN', 'RWIN', 'SHIFT', 'LSHIFT', 'RSHIFT', 'CTRL', 'CONTROL', 'LCTRL', 'RCTRL', 'LCONTROL', 'LCONTROL', 'ALT', 'LALT', 'RALT')
keys = []
printKeys = []
i = 0
insertIndex = 0
length = len(text)
hold = False
include = False
lastKeyValue = None
while True:
if text[i] == '{':
rindex = text.find('}', i)
if rindex == i + 1:#{}}
rindex = text.find('}', i + 2)
if rindex == -1:
raise ValueError('"{" or "{}" is not valid, use "{{}" for "{", use "{}}" for "}"')
key = text[i + 1:rindex]
key = [it for it in key.split(' ') if it]
if not key:
raise ValueError('"{}" is not valid, use "{{Space}}" or " " for " "'.format(text[i:rindex + 1]))
if (len(key) == 2 and not key[1].isdigit()) or len(key) > 2:
raise ValueError('"{}" is not valid'.format(text[i:rindex + 1]))
upperKey = key[0].upper()
count = 1
if len(key) > 1:
count = int(key[1])
for j in range(count):
if hold:
if upperKey in SpecialKeyNames:
keyValue = SpecialKeyNames[upperKey]
if type(lastKeyValue) == type(keyValue) and lastKeyValue == keyValue:
insertIndex += 1
printKeys.insert(insertIndex, (key[0], 'KeyDown | ExtendedKey'))
printKeys.insert(insertIndex + 1, (key[0], 'KeyUp | ExtendedKey'))
keys.insert(insertIndex, (keyValue, KeyboardEventFlag.KeyDown | KeyboardEventFlag.ExtendedKey))
keys.insert(insertIndex + 1, (keyValue, KeyboardEventFlag.KeyUp | KeyboardEventFlag.ExtendedKey))
lastKeyValue = keyValue
elif key[0] in CharacterCodes:
keyValue = CharacterCodes[key[0]]
if type(lastKeyValue) == type(keyValue) and lastKeyValue == keyValue:
insertIndex += 1
printKeys.insert(insertIndex, (key[0], 'KeyDown | ExtendedKey'))
printKeys.insert(insertIndex + 1, (key[0], 'KeyUp | ExtendedKey'))
keys.insert(insertIndex, (keyValue, KeyboardEventFlag.KeyDown | KeyboardEventFlag.ExtendedKey))
keys.insert(insertIndex + 1, (keyValue, KeyboardEventFlag.KeyUp | KeyboardEventFlag.ExtendedKey))
lastKeyValue = keyValue
else:
printKeys.insert(insertIndex, (key[0], 'UnicodeChar'))
keys.insert(insertIndex, (key[0], 'UnicodeChar'))
lastKeyValue = key[0]
if include:
insertIndex += 1
else:
if upperKey in holdKeys:
insertIndex += 1
else:
hold = False
else:
if upperKey in SpecialKeyNames:
keyValue = SpecialKeyNames[upperKey]
printKeys.append((key[0], 'KeyDown | ExtendedKey'))
printKeys.append((key[0], 'KeyUp | ExtendedKey'))
keys.append((keyValue, KeyboardEventFlag.KeyDown | KeyboardEventFlag.ExtendedKey))
keys.append((keyValue, KeyboardEventFlag.KeyUp | KeyboardEventFlag.ExtendedKey))
lastKeyValue = keyValue
if upperKey in holdKeys:
hold = True
insertIndex = len(keys) - 1
else:
hold = False
else:
printKeys.append((key[0], 'UnicodeChar'))
keys.append((key[0], 'UnicodeChar'))
lastKeyValue = key[0]
i = rindex + 1
elif text[i] == '(':
if hold:
include = True
else:
printKeys.append((text[i], 'UnicodeChar'))
keys.append((text[i], 'UnicodeChar'))
lastKeyValue = text[i]
i += 1
elif text[i] == ')':
if hold:
include = False
hold = False
else:
printKeys.append((text[i], 'UnicodeChar'))
keys.append((text[i], 'UnicodeChar'))
lastKeyValue = text[i]
i += 1
else:
if hold:
if text[i] in CharacterCodes:
keyValue = CharacterCodes[text[i]]
if include and type(lastKeyValue) == type(keyValue) and lastKeyValue == keyValue:
insertIndex += 1
printKeys.insert(insertIndex, (text[i], 'KeyDown | ExtendedKey'))
printKeys.insert(insertIndex + 1, (text[i], 'KeyUp | ExtendedKey'))
keys.insert(insertIndex, (keyValue, KeyboardEventFlag.KeyDown | KeyboardEventFlag.ExtendedKey))
keys.insert(insertIndex + 1, (keyValue, KeyboardEventFlag.KeyUp | KeyboardEventFlag.ExtendedKey))
lastKeyValue = keyValue
else:
printKeys.append((text[i], 'UnicodeChar'))
keys.append((text[i], 'UnicodeChar'))
lastKeyValue = text[i]
if include:
insertIndex += 1
else:
hold = False
else:
printKeys.append((text[i], 'UnicodeChar'))
keys.append((text[i], 'UnicodeChar'))
lastKeyValue = text[i]
i += 1
if i >= length:
break
hotkeyInterval = 0.01
for i, key in enumerate(keys):
if key[1] == 'UnicodeChar':
SendUnicodeChar(key[0], charMode)
time.sleep(interval)
if debug:
Logger.ColorfullyWrite('<Color=DarkGreen>{}</Color>, sleep({})\n'.format(printKeys[i], interval), writeToFile=False)
else:
scanCode = _VKtoSC(key[0])
keybd_event(key[0], scanCode, key[1], 0)
if debug:
Logger.Write(printKeys[i], ConsoleColor.DarkGreen, writeToFile=False)
if i + 1 == len(keys):
time.sleep(interval)
if debug:
Logger.Write(', sleep({})\n'.format(interval), writeToFile=False)
else:
if key[1] & KeyboardEventFlag.KeyUp:
if keys[i + 1][1] == 'UnicodeChar' or keys[i + 1][1] & KeyboardEventFlag.KeyUp == 0:
time.sleep(interval)
if debug:
Logger.Write(', sleep({})\n'.format(interval), writeToFile=False)
else:
time.sleep(hotkeyInterval) #must sleep for a while, otherwise combined keys may not be caught
if debug:
Logger.Write(', sleep({})\n'.format(hotkeyInterval), writeToFile=False)
else: #KeyboardEventFlag.KeyDown
time.sleep(hotkeyInterval)
if debug:
Logger.Write(', sleep({})\n'.format(hotkeyInterval), writeToFile=False)
#make sure hold keys are not pressed
#win = ctypes.windll.user32.GetAsyncKeyState(Keys.VK_LWIN)
#ctrl = ctypes.windll.user32.GetAsyncKeyState(Keys.VK_CONTROL)
#alt = ctypes.windll.user32.GetAsyncKeyState(Keys.VK_MENU)
#shift = ctypes.windll.user32.GetAsyncKeyState(Keys.VK_SHIFT)
#if win & 0x8000:
#Logger.WriteLine('ERROR: WIN is pressed, it should not be pressed!', ConsoleColor.Red)
#keybd_event(Keys.VK_LWIN, 0, KeyboardEventFlag.KeyUp | KeyboardEventFlag.ExtendedKey, 0)
#if ctrl & 0x8000:
#Logger.WriteLine('ERROR: CTRL is pressed, it should not be pressed!', ConsoleColor.Red)
#keybd_event(Keys.VK_CONTROL, 0, KeyboardEventFlag.KeyUp | KeyboardEventFlag.ExtendedKey, 0)
#if alt & 0x8000:
#Logger.WriteLine('ERROR: ALT is pressed, it should not be pressed!', ConsoleColor.Red)
#keybd_event(Keys.VK_MENU, 0, KeyboardEventFlag.KeyUp | KeyboardEventFlag.ExtendedKey, 0)
#if shift & 0x8000:
#Logger.WriteLine('ERROR: SHIFT is pressed, it should not be pressed!', ConsoleColor.Red)
#keybd_event(Keys.VK_SHIFT, 0, KeyboardEventFlag.KeyUp | KeyboardEventFlag.ExtendedKey, 0)
time.sleep(waitTime)
|
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}')
|
SendKeys
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def Write(log: Any, consoleColor: int = ConsoleColor.Default, writeToFile: bool = True, printToStdout: bool = True, logFile: str = None, printTruncateLen: int = 0) -> None:
"""
log: any type.
consoleColor: int, a value in class `ConsoleColor`, such as `ConsoleColor.DarkGreen`.
writeToFile: bool.
printToStdout: bool.
logFile: str, log file path.
printTruncateLen: int, if <= 0, log is not truncated when print.
"""
if not isinstance(log, str):
log = str(log)
if printToStdout and sys.stdout:
isValidColor = (consoleColor >= ConsoleColor.Black and consoleColor <= ConsoleColor.White)
if isValidColor:
SetConsoleColor(consoleColor)
try:
if printTruncateLen > 0 and len(log) > printTruncateLen:
sys.stdout.write(log[:printTruncateLen] + '...')
else:
sys.stdout.write(log)
except Exception as ex:
SetConsoleColor(ConsoleColor.Red)
isValidColor = True
sys.stdout.write(ex.__class__.__name__ + ': can\'t print the log!')
if log.endswith('\n'):
sys.stdout.write('\n')
if isValidColor:
ResetConsoleColor()
sys.stdout.flush()
if not writeToFile:
return
fileName = logFile if logFile else Logger.FileName
fout = None
try:
fout = open(fileName, 'a+', encoding='utf-8')
fout.write(log)
except Exception as ex:
if sys.stdout:
sys.stdout.write(ex.__class__.__name__ + ': can\'t write the log!')
finally:
if fout:
fout.close()
|
log: any type.
consoleColor: int, a value in class `ConsoleColor`, such as `ConsoleColor.DarkGreen`.
writeToFile: bool.
printToStdout: bool.
logFile: str, log file path.
printTruncateLen: int, if <= 0, log is not truncated when print.
|
Write
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def ColorfullyWrite(log: str, consoleColor: int = -1, writeToFile: bool = True, printToStdout: bool = True, logFile: str = None) -> None:
"""
log: str.
consoleColor: int, a value in class `ConsoleColor`, such as `ConsoleColor.DarkGreen`.
writeToFile: bool.
printToStdout: bool.
logFile: str, log file path.
ColorfullyWrite('Hello <Color=Green>Green</Color> !!!'), color name must be in Logger.ColorNames.
"""
text = []
start = 0
while True:
index1 = log.find('<Color=', start)
if index1 >= 0:
if index1 > start:
text.append((log[start:index1], consoleColor))
index2 = log.find('>', index1)
colorName = log[index1+7:index2]
index3 = log.find('</Color>', index2 + 1)
text.append((log[index2 + 1:index3], Logger.ColorNames[colorName]))
start = index3 + 8
else:
if start < len(log):
text.append((log[start:], consoleColor))
break
for t, c in text:
Logger.Write(t, c, writeToFile, printToStdout, logFile)
|
log: str.
consoleColor: int, a value in class `ConsoleColor`, such as `ConsoleColor.DarkGreen`.
writeToFile: bool.
printToStdout: bool.
logFile: str, log file path.
ColorfullyWrite('Hello <Color=Green>Green</Color> !!!'), color name must be in Logger.ColorNames.
|
ColorfullyWrite
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def Log(log: Any = '', consoleColor: int = -1, writeToFile: bool = True, printToStdout: bool = True, logFile: str = None) -> None:
"""
log: any type.
consoleColor: int, a value in class `ConsoleColor`, such as `ConsoleColor.DarkGreen`.
writeToFile: bool.
printToStdout: bool.
logFile: str, log file path.
"""
frameCount = 1
while True:
frame = sys._getframe(frameCount)
_, scriptFileName = os.path.split(frame.f_code.co_filename)
if scriptFileName != Logger._SelfFileName:
break
frameCount += 1
t = datetime.datetime.now()
log = '{}-{:02}-{:02} {:02}:{:02}:{:02}.{:03} {}[{}] {} -> {}\n'.format(t.year, t.month, t.day,
t.hour, t.minute, t.second, t.microsecond // 1000, scriptFileName, frame.f_lineno, frame.f_code.co_name, log)
Logger.Write(log, consoleColor, writeToFile, printToStdout, logFile)
|
log: any type.
consoleColor: int, a value in class `ConsoleColor`, such as `ConsoleColor.DarkGreen`.
writeToFile: bool.
printToStdout: bool.
logFile: str, log file path.
|
Log
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def ColorfullyLog(log: str = '', consoleColor: int = -1, writeToFile: bool = True, printToStdout: bool = True, logFile: str = None) -> None:
"""
log: any type.
consoleColor: int, a value in class ConsoleColor, such as ConsoleColor.DarkGreen.
writeToFile: bool.
printToStdout: bool.
logFile: str, log file path.
ColorfullyLog('Hello <Color=Green>Green</Color> !!!'), color name must be in Logger.ColorNames
"""
frameCount = 1
while True:
frame = sys._getframe(frameCount)
_, scriptFileName = os.path.split(frame.f_code.co_filename)
if scriptFileName != Logger._SelfFileName:
break
frameCount += 1
t = datetime.datetime.now()
log = '{}-{:02}-{:02} {:02}:{:02}:{:02}.{:03} {}[{}] {} -> {}\n'.format(t.year, t.month, t.day,
t.hour, t.minute, t.second, t.microsecond // 1000, scriptFileName, frame.f_lineno, frame.f_code.co_name, log)
Logger.ColorfullyWrite(log, consoleColor, writeToFile, printToStdout, logFile)
|
log: any type.
consoleColor: int, a value in class ConsoleColor, such as ConsoleColor.DarkGreen.
writeToFile: bool.
printToStdout: bool.
logFile: str, log file path.
ColorfullyLog('Hello <Color=Green>Green</Color> !!!'), color name must be in Logger.ColorNames
|
ColorfullyLog
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def __init__(self, width: int = 0, height: int = 0):
"""
Create a black bimap of size(width, height).
"""
self._width = width
self._height = height
self._bitmap = 0
if width > 0 and height > 0:
self._bitmap = _DllClient.instance().dll.BitmapCreate(width, height)
|
Create a black bimap of size(width, height).
|
__init__
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def FromHandle(self, hwnd: int, left: int = 0, top: int = 0, right: int = 0, bottom: int = 0) -> bool:
"""
Capture a native window to Bitmap by its handle.
hwnd: int, the handle of a native window.
left: int.
top: int.
right: int.
bottom: int.
left, top, right and bottom are control's internal postion(from 0,0).
Return bool, True if succeed otherwise False.
"""
self.Release()
root = GetRootControl()
rect = ctypes.wintypes.RECT()
ctypes.windll.user32.GetWindowRect(hwnd, ctypes.byref(rect))
left, top, right, bottom = left + rect.left, top + rect.top, right + rect.left, bottom + rect.top
self._bitmap = _DllClient.instance().dll.BitmapFromWindow(root.NativeWindowHandle, left, top, right, bottom)
self._getsize()
return self._bitmap > 0
|
Capture a native window to Bitmap by its handle.
hwnd: int, the handle of a native window.
left: int.
top: int.
right: int.
bottom: int.
left, top, right and bottom are control's internal postion(from 0,0).
Return bool, True if succeed otherwise False.
|
FromHandle
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def FromControl(self, control: 'Control', x: int = 0, y: int = 0, width: int = 0, height: int = 0) -> bool:
"""
Capture a control to Bitmap.
control: `Control` or its subclass.
x: int.
y: int.
width: int.
height: int.
x, y: the point in control's internal position(from 0,0)
width, height: image's width and height from x, y, use 0 for entire area,
If width(or height) < 0, image size will be control's width(or height) - width(or height).
Return bool, True if succeed otherwise False.
"""
rect = control.BoundingRectangle
while rect.width() == 0 or rect.height() == 0:
#some controls maybe visible but their BoundingRectangle are all 0, capture its parent util valid
control = control.GetParentControl()
if not control:
return False
rect = control.BoundingRectangle
if width <= 0:
width = rect.width() + width
if height <= 0:
height = rect.height() + height
handle = control.NativeWindowHandle
if handle:
left = x
top = y
right = left + width
bottom = top + height
else:
while True:
control = control.GetParentControl()
handle = control.NativeWindowHandle
if handle:
pRect = control.BoundingRectangle
left = rect.left - pRect.left + x
top = rect.top - pRect.top + y
right = left + width
bottom = top + height
break
return self.FromHandle(handle, left, top, right, bottom)
|
Capture a control to Bitmap.
control: `Control` or its subclass.
x: int.
y: int.
width: int.
height: int.
x, y: the point in control's internal position(from 0,0)
width, height: image's width and height from x, y, use 0 for entire area,
If width(or height) < 0, image size will be control's width(or height) - width(or height).
Return bool, True if succeed otherwise False.
|
FromControl
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def FromFile(self, filePath: str) -> bool:
"""
Load image from a file.
filePath: str.
Return bool, True if succeed otherwise False.
"""
self.Release()
self._bitmap = _DllClient.instance().dll.BitmapFromFile(ctypes.c_wchar_p(filePath))
self._getsize()
return self._bitmap > 0
|
Load image from a file.
filePath: str.
Return bool, True if succeed otherwise False.
|
FromFile
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def ToFile(self, savePath: str) -> bool:
"""
Save to a file.
savePath: str, should end with .bmp, .jpg, .jpeg, .png, .gif, .tif, .tiff.
Return bool, True if succeed otherwise False.
"""
name, ext = os.path.splitext(savePath)
extMap = {'.bmp': 'image/bmp'
, '.jpg': 'image/jpeg'
, '.jpeg': 'image/jpeg'
, '.gif': 'image/gif'
, '.tif': 'image/tiff'
, '.tiff': 'image/tiff'
, '.png': 'image/png'
}
gdiplusImageFormat = extMap.get(ext.lower(), 'image/png')
return bool(_DllClient.instance().dll.BitmapToFile(self._bitmap, ctypes.c_wchar_p(savePath), ctypes.c_wchar_p(gdiplusImageFormat)))
|
Save to a file.
savePath: str, should end with .bmp, .jpg, .jpeg, .png, .gif, .tif, .tiff.
Return bool, True if succeed otherwise False.
|
ToFile
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def GetPixelColorsHorizontally(self, x: int, y: int, count: int) -> ctypes.Array:
"""
x: int.
y: int.
count: int.
Return `ctypes.Array`, an iterable array of int values in argb form point x,y horizontally.
"""
arrayType = ctypes.c_uint32 * count
values = arrayType()
_DllClient.instance().dll.BitmapGetPixelsHorizontally(ctypes.c_size_t(self._bitmap), x, y, values, count)
return values
|
x: int.
y: int.
count: int.
Return `ctypes.Array`, an iterable array of int values in argb form point x,y horizontally.
|
GetPixelColorsHorizontally
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def SetPixelColorsHorizontally(self, x: int, y: int, colors: Iterable[int]) -> bool:
"""
Set pixel colors form x,y horizontally.
x: int.
y: int.
colors: Iterable[int], an iterable list of int color values in argb.
Return bool, True if succeed otherwise False.
"""
count = len(colors)
arrayType = ctypes.c_uint32 * count
values = arrayType(*colors)
return _DllClient.instance().dll.BitmapSetPixelsHorizontally(ctypes.c_size_t(self._bitmap), x, y, values, count)
|
Set pixel colors form x,y horizontally.
x: int.
y: int.
colors: Iterable[int], an iterable list of int color values in argb.
Return bool, True if succeed otherwise False.
|
SetPixelColorsHorizontally
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def GetPixelColorsVertically(self, x: int, y: int, count: int) -> ctypes.Array:
"""
x: int.
y: int.
count: int.
Return `ctypes.Array`, an iterable array of int values in argb form point x,y vertically.
"""
arrayType = ctypes.c_uint32 * count
values = arrayType()
_DllClient.instance().dll.BitmapGetPixelsVertically(ctypes.c_size_t(self._bitmap), x, y, values, count)
return values
|
x: int.
y: int.
count: int.
Return `ctypes.Array`, an iterable array of int values in argb form point x,y vertically.
|
GetPixelColorsVertically
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def SetPixelColorsVertically(self, x: int, y: int, colors: Iterable[int]) -> bool:
"""
Set pixel colors form x,y vertically.
x: int.
y: int.
colors: Iterable[int], an iterable list of int color values in argb.
Return bool, True if succeed otherwise False.
"""
count = len(colors)
arrayType = ctypes.c_uint32 * count
values = arrayType(*colors)
return _DllClient.instance().dll.BitmapSetPixelsVertically(ctypes.c_size_t(self._bitmap), x, y, values, count)
|
Set pixel colors form x,y vertically.
x: int.
y: int.
colors: Iterable[int], an iterable list of int color values in argb.
Return bool, True if succeed otherwise False.
|
SetPixelColorsVertically
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def GetPixelColorsOfRect(self, x: int, y: int, width: int, height: int) -> ctypes.Array:
"""
x: int.
y: int.
width: int.
height: int.
Return `ctypes.Array`, an iterable array of int values in argb of the input rect.
"""
arrayType = ctypes.c_uint32 * (width * height)
values = arrayType()
_DllClient.instance().dll.BitmapGetPixelsOfRect(ctypes.c_size_t(self._bitmap), x, y, width, height, values)
return values
|
x: int.
y: int.
width: int.
height: int.
Return `ctypes.Array`, an iterable array of int values in argb of the input rect.
|
GetPixelColorsOfRect
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def SetPixelColorsOfRect(self, x: int, y: int, width: int, height: int, colors: Iterable[int]) -> bool:
"""
x: int.
y: int.
width: int.
height: int.
colors: Iterable[int], an iterable list of int values in argb, it's length must equal to width*height.
Return bool.
"""
arrayType = ctypes.c_uint32 * (width * height)
values = arrayType(*colors)
return bool(_DllClient.instance().dll.BitmapSetPixelsOfRect(ctypes.c_size_t(self._bitmap), x, y, width, height, values))
|
x: int.
y: int.
width: int.
height: int.
colors: Iterable[int], an iterable list of int values in argb, it's length must equal to width*height.
Return bool.
|
SetPixelColorsOfRect
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def GetPixelColorsOfRects(self, rects: List[Tuple[int, int, int, int]]) -> List[ctypes.Array]:
"""
rects: List[Tuple[int, int, int, int]], such as [(0,0,10,10), (10,10,20,20), (x,y,width,height)].
Return List[ctypes.Array], a list whose elements are ctypes.Array which is an iterable array of int values in argb.
"""
rects2 = [(x, y, x + width, y + height) for x, y, width, height in rects]
left, top, right, bottom = zip(*rects2)
left, top, right, bottom = min(left), min(top), max(right), max(bottom)
width, height = right - left, bottom - top
allColors = self.GetPixelColorsOfRect(left, top, width, height)
colorsOfRects = []
for x, y, w, h in rects:
x -= left
y -= top
colors = []
for row in range(h):
colors.extend(allColors[(y + row) * width + x:(y + row) * width + x + w])
colorsOfRects.append(colors)
return colorsOfRects
|
rects: List[Tuple[int, int, int, int]], such as [(0,0,10,10), (10,10,20,20), (x,y,width,height)].
Return List[ctypes.Array], a list whose elements are ctypes.Array which is an iterable array of int values in argb.
|
GetPixelColorsOfRects
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def GetSubBitmap(self, x: int, y: int, width: int, height: int) -> 'Bitmap':
"""
x: int.
y: int.
width: int.
height: int.
Return `Bitmap`, a sub bitmap of the input rect.
"""
colors = self.GetPixelColorsOfRect(x, y, width, height)
bitmap = Bitmap(width, height)
bitmap.SetPixelColorsOfRect(0, 0, width, height, colors)
return bitmap
|
x: int.
y: int.
width: int.
height: int.
Return `Bitmap`, a sub bitmap of the input rect.
|
GetSubBitmap
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def GetPatternIdInterface(patternId: int):
"""
Get pattern COM interface by pattern id.
patternId: int, a value in class `PatternId`.
Return comtypes._cominterface_meta.
"""
global _PatternIdInterfaces
if not _PatternIdInterfaces:
_PatternIdInterfaces = {
# PatternId.AnnotationPattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationAnnotationPattern,
# PatternId.CustomNavigationPattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationCustomNavigationPattern,
PatternId.DockPattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationDockPattern,
# PatternId.DragPattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationDragPattern,
# PatternId.DropTargetPattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationDropTargetPattern,
PatternId.ExpandCollapsePattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationExpandCollapsePattern,
PatternId.GridItemPattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationGridItemPattern,
PatternId.GridPattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationGridPattern,
PatternId.InvokePattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationInvokePattern,
PatternId.ItemContainerPattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationItemContainerPattern,
PatternId.LegacyIAccessiblePattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationLegacyIAccessiblePattern,
PatternId.MultipleViewPattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationMultipleViewPattern,
# PatternId.ObjectModelPattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationObjectModelPattern,
PatternId.RangeValuePattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationRangeValuePattern,
PatternId.ScrollItemPattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationScrollItemPattern,
PatternId.ScrollPattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationScrollPattern,
PatternId.SelectionItemPattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationSelectionItemPattern,
PatternId.SelectionPattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationSelectionPattern,
# PatternId.SpreadsheetItemPattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationSpreadsheetItemPattern,
# PatternId.SpreadsheetPattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationSpreadsheetPattern,
# PatternId.StylesPattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationStylesPattern,
PatternId.SynchronizedInputPattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationSynchronizedInputPattern,
PatternId.TableItemPattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationTableItemPattern,
PatternId.TablePattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationTablePattern,
# PatternId.TextChildPattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationTextChildPattern,
# PatternId.TextEditPattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationTextEditPattern,
PatternId.TextPattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationTextPattern,
# PatternId.TextPattern2: _AutomationClient.instance().UIAutomationCore.IUIAutomationTextPattern2,
PatternId.TogglePattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationTogglePattern,
PatternId.TransformPattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationTransformPattern,
# PatternId.TransformPattern2: _AutomationClient.instance().UIAutomationCore.IUIAutomationTransformPattern2,
PatternId.ValuePattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationValuePattern,
PatternId.VirtualizedItemPattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationVirtualizedItemPattern,
PatternId.WindowPattern: _AutomationClient.instance().UIAutomationCore.IUIAutomationWindowPattern,
}
debug = False
#the following patterns doesn't exist on Windows 7 or lower
try:
_PatternIdInterfaces[PatternId.AnnotationPattern] = _AutomationClient.instance().UIAutomationCore.IUIAutomationAnnotationPattern
except:
if debug: Logger.WriteLine('UIAutomationCore does not have AnnotationPattern.', ConsoleColor.Yellow)
try:
_PatternIdInterfaces[PatternId.CustomNavigationPattern] = _AutomationClient.instance().UIAutomationCore.IUIAutomationCustomNavigationPattern
except:
if debug: Logger.WriteLine('UIAutomationCore does not have CustomNavigationPattern.', ConsoleColor.Yellow)
try:
_PatternIdInterfaces[PatternId.DragPattern] = _AutomationClient.instance().UIAutomationCore.IUIAutomationDragPattern
except:
if debug: Logger.WriteLine('UIAutomationCore does not have DragPattern.', ConsoleColor.Yellow)
try:
_PatternIdInterfaces[PatternId.DropTargetPattern] = _AutomationClient.instance().UIAutomationCore.IUIAutomationDropTargetPattern
except:
if debug: Logger.WriteLine('UIAutomationCore does not have DropTargetPattern.', ConsoleColor.Yellow)
try:
_PatternIdInterfaces[PatternId.ObjectModelPattern] = _AutomationClient.instance().UIAutomationCore.IUIAutomationObjectModelPattern
except:
if debug: Logger.WriteLine('UIAutomationCore does not have ObjectModelPattern.', ConsoleColor.Yellow)
try:
_PatternIdInterfaces[PatternId.SpreadsheetItemPattern] = _AutomationClient.instance().UIAutomationCore.IUIAutomationSpreadsheetItemPattern
except:
if debug: Logger.WriteLine('UIAutomationCore does not have SpreadsheetItemPattern.', ConsoleColor.Yellow)
try:
_PatternIdInterfaces[PatternId.SpreadsheetPattern] = _AutomationClient.instance().UIAutomationCore.IUIAutomationSpreadsheetPattern
except:
if debug: Logger.WriteLine('UIAutomationCore does not have SpreadsheetPattern.', ConsoleColor.Yellow)
try:
_PatternIdInterfaces[PatternId.StylesPattern] = _AutomationClient.instance().UIAutomationCore.IUIAutomationStylesPattern
except:
if debug: Logger.WriteLine('UIAutomationCore does not have StylesPattern.', ConsoleColor.Yellow)
try:
_PatternIdInterfaces[PatternId.TextChildPattern] = _AutomationClient.instance().UIAutomationCore.IUIAutomationTextChildPattern
except:
if debug: Logger.WriteLine('UIAutomationCore does not have TextChildPattern.', ConsoleColor.Yellow)
try:
_PatternIdInterfaces[PatternId.TextEditPattern] = _AutomationClient.instance().UIAutomationCore.IUIAutomationTextEditPattern
except:
if debug: Logger.WriteLine('UIAutomationCore does not have TextEditPattern.', ConsoleColor.Yellow)
try:
_PatternIdInterfaces[PatternId.TextPattern2] = _AutomationClient.instance().UIAutomationCore.IUIAutomationTextPattern2
except:
if debug: Logger.WriteLine('UIAutomationCore does not have TextPattern2.', ConsoleColor.Yellow)
try:
_PatternIdInterfaces[PatternId.TransformPattern2] = _AutomationClient.instance().UIAutomationCore.IUIAutomationTransformPattern2
except:
if debug: Logger.WriteLine('UIAutomationCore does not have TransformPattern2.', ConsoleColor.Yellow)
return _PatternIdInterfaces[patternId]
|
Get pattern COM interface by pattern id.
patternId: int, a value in class `PatternId`.
Return comtypes._cominterface_meta.
|
GetPatternIdInterface
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def SetDockPosition(self, dockPosition: int, waitTime: float = OPERATION_WAIT_TIME) -> int:
"""
Call IUIAutomationDockPattern::SetDockPosition.
dockPosition: int, a value in class `DockPosition`.
waitTime: float.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationdockpattern-setdockposition
"""
ret = self.pattern.SetDockPosition(dockPosition)
time.sleep(waitTime)
return ret
|
Call IUIAutomationDockPattern::SetDockPosition.
dockPosition: int, a value in class `DockPosition`.
waitTime: float.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationdockpattern-setdockposition
|
SetDockPosition
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def GetGrabbedItems(self) -> List['Control']:
"""
Call IUIAutomationDragPattern::GetCurrentGrabbedItems.
Return List[Control], a list of `Control` subclasses that represent the full set of items
that the user is dragging as part of a drag operation.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationdragpattern-getcurrentgrabbeditems
"""
eleArray = self.pattern.GetCurrentGrabbedItems()
if eleArray:
controls = []
for i in range(eleArray.Length):
ele = eleArray.GetElement(i)
con = Control.CreateControlFromElement(element=ele)
if con:
controls.append(con)
return controls
return []
|
Call IUIAutomationDragPattern::GetCurrentGrabbedItems.
Return List[Control], a list of `Control` subclasses that represent the full set of items
that the user is dragging as part of a drag operation.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationdragpattern-getcurrentgrabbeditems
|
GetGrabbedItems
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def Collapse(self, waitTime: float = OPERATION_WAIT_TIME) -> bool:
"""
Call IUIAutomationExpandCollapsePattern::Collapse.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationexpandcollapsepattern-collapse
"""
ret = self.pattern.Collapse() == S_OK
time.sleep(waitTime)
return ret
|
Call IUIAutomationExpandCollapsePattern::Collapse.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationexpandcollapsepattern-collapse
|
Collapse
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def Expand(self, waitTime: float = OPERATION_WAIT_TIME) -> bool:
"""
Call IUIAutomationExpandCollapsePattern::Expand.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationexpandcollapsepattern-expand
"""
ret = self.pattern.Expand() == S_OK
time.sleep(waitTime)
return ret
|
Call IUIAutomationExpandCollapsePattern::Expand.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationexpandcollapsepattern-expand
|
Expand
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def Invoke(self, waitTime: float = OPERATION_WAIT_TIME) -> bool:
"""
Call IUIAutomationInvokePattern::Invoke.
Invoke the action of a control, such as a button click.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationinvokepattern-invoke
"""
ret = self.pattern.Invoke() == S_OK
time.sleep(waitTime)
return ret
|
Call IUIAutomationInvokePattern::Invoke.
Invoke the action of a control, such as a button click.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationinvokepattern-invoke
|
Invoke
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def DoDefaultAction(self, waitTime: float = OPERATION_WAIT_TIME) -> bool:
"""
Call IUIAutomationLegacyIAccessiblePattern::DoDefaultAction.
Perform the Microsoft Active Accessibility default action for the element.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationlegacyiaccessiblepattern-dodefaultaction
"""
ret = self.pattern.DoDefaultAction() == S_OK
time.sleep(waitTime)
return ret
|
Call IUIAutomationLegacyIAccessiblePattern::DoDefaultAction.
Perform the Microsoft Active Accessibility default action for the element.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationlegacyiaccessiblepattern-dodefaultaction
|
DoDefaultAction
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def GetSelection(self) -> List['Control']:
"""
Call IUIAutomationLegacyIAccessiblePattern::GetCurrentSelection.
Return List[Control], a list of `Control` subclasses,
the Microsoft Active Accessibility property that identifies the selected children of this element.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationlegacyiaccessiblepattern-getcurrentselection
"""
eleArray = self.pattern.GetCurrentSelection()
if eleArray:
controls = []
for i in range(eleArray.Length):
ele = eleArray.GetElement(i)
con = Control.CreateControlFromElement(element=ele)
if con:
controls.append(con)
return controls
return []
|
Call IUIAutomationLegacyIAccessiblePattern::GetCurrentSelection.
Return List[Control], a list of `Control` subclasses,
the Microsoft Active Accessibility property that identifies the selected children of this element.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationlegacyiaccessiblepattern-getcurrentselection
|
GetSelection
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def Select(self, flagsSelect: int, waitTime: float = OPERATION_WAIT_TIME) -> bool:
"""
Call IUIAutomationLegacyIAccessiblePattern::Select.
Perform a Microsoft Active Accessibility selection.
flagsSelect: int, a value in `AccessibleSelection`.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationlegacyiaccessiblepattern-select
"""
ret = self.pattern.Select(flagsSelect) == S_OK
time.sleep(waitTime)
return ret
|
Call IUIAutomationLegacyIAccessiblePattern::Select.
Perform a Microsoft Active Accessibility selection.
flagsSelect: int, a value in `AccessibleSelection`.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationlegacyiaccessiblepattern-select
|
Select
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def SetValue(self, value: str, waitTime: float = OPERATION_WAIT_TIME) -> bool:
"""
Call IUIAutomationLegacyIAccessiblePattern::SetValue.
Set the Microsoft Active Accessibility value property for the element.
value: str.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationlegacyiaccessiblepattern-setvalue
"""
ret = self.pattern.SetValue(value) == S_OK
time.sleep(waitTime)
return ret
|
Call IUIAutomationLegacyIAccessiblePattern::SetValue.
Set the Microsoft Active Accessibility value property for the element.
value: str.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationlegacyiaccessiblepattern-setvalue
|
SetValue
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def SetValue(self, value: float, waitTime: float = OPERATION_WAIT_TIME) -> bool:
"""
Call IUIAutomationRangeValuePattern::SetValue.
Set the value of the control.
value: int.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationrangevaluepattern-setvalue
"""
ret = self.pattern.SetValue(value) == S_OK
time.sleep(waitTime)
return ret
|
Call IUIAutomationRangeValuePattern::SetValue.
Set the value of the control.
value: int.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationrangevaluepattern-setvalue
|
SetValue
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def ScrollIntoView(self, waitTime: float = OPERATION_WAIT_TIME) -> bool:
"""
Call IUIAutomationScrollItemPattern::ScrollIntoView.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationscrollitempattern-scrollintoview
"""
ret = self.pattern.ScrollIntoView() == S_OK
time.sleep(waitTime)
return ret
|
Call IUIAutomationScrollItemPattern::ScrollIntoView.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationscrollitempattern-scrollintoview
|
ScrollIntoView
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def Scroll(self, horizontalAmount: int, verticalAmount: int, waitTime: float = OPERATION_WAIT_TIME) -> bool:
"""
Call IUIAutomationScrollPattern::Scroll.
Scroll the visible region of the content area horizontally and vertically.
horizontalAmount: int, a value in ScrollAmount.
verticalAmount: int, a value in ScrollAmount.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationscrollpattern-scroll
"""
ret = self.pattern.Scroll(horizontalAmount, verticalAmount) == S_OK
time.sleep(waitTime)
return ret
|
Call IUIAutomationScrollPattern::Scroll.
Scroll the visible region of the content area horizontally and vertically.
horizontalAmount: int, a value in ScrollAmount.
verticalAmount: int, a value in ScrollAmount.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationscrollpattern-scroll
|
Scroll
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def SetScrollPercent(self, horizontalPercent: float, verticalPercent: float, waitTime: float = OPERATION_WAIT_TIME) -> bool:
"""
Call IUIAutomationScrollPattern::SetScrollPercent.
Set the horizontal and vertical scroll positions as a percentage of the total content area within the UI Automation element.
horizontalPercent: float or int, a value in [0, 100] or ScrollPattern.NoScrollValue(-1) if no scroll.
verticalPercent: float or int, a value in [0, 100] or ScrollPattern.NoScrollValue(-1) if no scroll.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationscrollpattern-setscrollpercent
"""
ret = self.pattern.SetScrollPercent(horizontalPercent, verticalPercent) == S_OK
time.sleep(waitTime)
return ret
|
Call IUIAutomationScrollPattern::SetScrollPercent.
Set the horizontal and vertical scroll positions as a percentage of the total content area within the UI Automation element.
horizontalPercent: float or int, a value in [0, 100] or ScrollPattern.NoScrollValue(-1) if no scroll.
verticalPercent: float or int, a value in [0, 100] or ScrollPattern.NoScrollValue(-1) if no scroll.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationscrollpattern-setscrollpercent
|
SetScrollPercent
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def AddToSelection(self, waitTime: float = OPERATION_WAIT_TIME) -> bool:
"""
Call IUIAutomationSelectionItemPattern::AddToSelection.
Add the current element to the collection of selected items.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationselectionitempattern-addtoselection
"""
ret = self.pattern.AddToSelection() == S_OK
time.sleep(waitTime)
return ret
|
Call IUIAutomationSelectionItemPattern::AddToSelection.
Add the current element to the collection of selected items.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationselectionitempattern-addtoselection
|
AddToSelection
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def RemoveFromSelection(self, waitTime: float = OPERATION_WAIT_TIME) -> bool:
"""
Call IUIAutomationSelectionItemPattern::RemoveFromSelection.
Remove this element from the selection.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationselectionitempattern-removefromselection
"""
ret = self.pattern.RemoveFromSelection() == S_OK
time.sleep(waitTime)
return ret
|
Call IUIAutomationSelectionItemPattern::RemoveFromSelection.
Remove this element from the selection.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationselectionitempattern-removefromselection
|
RemoveFromSelection
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def Select(self, waitTime: float = OPERATION_WAIT_TIME) -> bool:
"""
Call IUIAutomationSelectionItemPattern::Select.
Clear any selected items and then select the current element.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationselectionitempattern-select
"""
ret = self.pattern.Select() == S_OK
time.sleep(waitTime)
return ret
|
Call IUIAutomationSelectionItemPattern::Select.
Clear any selected items and then select the current element.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationselectionitempattern-select
|
Select
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def GetSelection(self) -> List['Control']:
"""
Call IUIAutomationSelectionPattern::GetCurrentSelection.
Return List[Control], a list of `Control` subclasses, the selected elements in the container..
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationselectionpattern-getcurrentselection
"""
eleArray = self.pattern.GetCurrentSelection()
if eleArray:
controls = []
for i in range(eleArray.Length):
ele = eleArray.GetElement(i)
con = Control.CreateControlFromElement(element=ele)
if con:
controls.append(con)
return controls
return []
|
Call IUIAutomationSelectionPattern::GetCurrentSelection.
Return List[Control], a list of `Control` subclasses, the selected elements in the container..
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationselectionpattern-getcurrentselection
|
GetSelection
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def GetAnnotationObjects(self) -> List['Control']:
"""
Call IUIAutomationSelectionPattern::GetCurrentAnnotationObjects.
Return List[Control], a list of `Control` subclasses representing the annotations associated with this spreadsheet cell.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationspreadsheetitempattern-getcurrentannotationobjects
"""
eleArray = self.pattern.GetCurrentAnnotationObjects()
if eleArray:
controls = []
for i in range(eleArray.Length):
ele = eleArray.GetElement(i)
con = Control.CreateControlFromElement(element=ele)
if con:
controls.append(con)
return controls
return []
|
Call IUIAutomationSelectionPattern::GetCurrentAnnotationObjects.
Return List[Control], a list of `Control` subclasses representing the annotations associated with this spreadsheet cell.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationspreadsheetitempattern-getcurrentannotationobjects
|
GetAnnotationObjects
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def GetColumnHeaderItems(self) -> List['Control']:
"""
Call IUIAutomationTableItemPattern::GetCurrentColumnHeaderItems.
Return List[Control], a list of `Control` subclasses, the column headers associated with a table item or cell.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtableitempattern-getcurrentcolumnheaderitems
"""
eleArray = self.pattern.GetCurrentColumnHeaderItems()
if eleArray:
controls = []
for i in range(eleArray.Length):
ele = eleArray.GetElement(i)
con = Control.CreateControlFromElement(element=ele)
if con:
controls.append(con)
return controls
return []
|
Call IUIAutomationTableItemPattern::GetCurrentColumnHeaderItems.
Return List[Control], a list of `Control` subclasses, the column headers associated with a table item or cell.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtableitempattern-getcurrentcolumnheaderitems
|
GetColumnHeaderItems
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def GetRowHeaderItems(self) -> List['Control']:
"""
Call IUIAutomationTableItemPattern::GetCurrentRowHeaderItems.
Return List[Control], a list of `Control` subclasses, the row headers associated with a table item or cell.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtableitempattern-getcurrentrowheaderitems
"""
eleArray = self.pattern.GetCurrentRowHeaderItems()
if eleArray:
controls = []
for i in range(eleArray.Length):
ele = eleArray.GetElement(i)
con = Control.CreateControlFromElement(element=ele)
if con:
controls.append(con)
return controls
return []
|
Call IUIAutomationTableItemPattern::GetCurrentRowHeaderItems.
Return List[Control], a list of `Control` subclasses, the row headers associated with a table item or cell.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtableitempattern-getcurrentrowheaderitems
|
GetRowHeaderItems
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def GetColumnHeaders(self) -> List['Control']:
"""
Call IUIAutomationTablePattern::GetCurrentColumnHeaders.
Return List[Control], a list of `Control` subclasses, representing all the column headers in a table..
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtablepattern-getcurrentcolumnheaders
"""
eleArray = self.pattern.GetCurrentColumnHeaders()
if eleArray:
controls = []
for i in range(eleArray.Length):
ele = eleArray.GetElement(i)
con = Control.CreateControlFromElement(element=ele)
if con:
controls.append(con)
return controls
return []
|
Call IUIAutomationTablePattern::GetCurrentColumnHeaders.
Return List[Control], a list of `Control` subclasses, representing all the column headers in a table..
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtablepattern-getcurrentcolumnheaders
|
GetColumnHeaders
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def GetRowHeaders(self) -> List['Control']:
"""
Call IUIAutomationTablePattern::GetCurrentRowHeaders.
Return List[Control], a list of `Control` subclasses, representing all the row headers in a table.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtablepattern-getcurrentrowheaders
"""
eleArray = self.pattern.GetCurrentRowHeaders()
if eleArray:
controls = []
for i in range(eleArray.Length):
ele = eleArray.GetElement(i)
con = Control.CreateControlFromElement(element=ele)
if con:
controls.append(con)
return controls
return []
|
Call IUIAutomationTablePattern::GetCurrentRowHeaders.
Return List[Control], a list of `Control` subclasses, representing all the row headers in a table.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtablepattern-getcurrentrowheaders
|
GetRowHeaders
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def AddToSelection(self, waitTime: float = OPERATION_WAIT_TIME) -> bool:
"""
Call IUIAutomationTextRange::AddToSelection.
Add the text range to the collection of selected text ranges in a control that supports multiple, disjoint spans of selected text.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextrange-addtoselection
"""
ret = self.textRange.AddToSelection() == S_OK
time.sleep(waitTime)
return ret
|
Call IUIAutomationTextRange::AddToSelection.
Add the text range to the collection of selected text ranges in a control that supports multiple, disjoint spans of selected text.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextrange-addtoselection
|
AddToSelection
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def ExpandToEnclosingUnit(self, waitTime: float = OPERATION_WAIT_TIME) -> bool:
"""
Call IUIAutomationTextRange::ExpandToEnclosingUnit.
Normalize the text range by the specified text unit.
The range is expanded if it is smaller than the specified unit,
or shortened if it is longer than the specified unit.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextrange-expandtoenclosingunit
"""
ret = self.textRange.ExpandToEnclosingUnit() == S_OK
time.sleep(waitTime)
return ret
|
Call IUIAutomationTextRange::ExpandToEnclosingUnit.
Normalize the text range by the specified text unit.
The range is expanded if it is smaller than the specified unit,
or shortened if it is longer than the specified unit.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextrange-expandtoenclosingunit
|
ExpandToEnclosingUnit
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def FindAttribute(self, textAttributeId: int, val, backward: bool) -> 'TextRange':
"""
Call IUIAutomationTextRange::FindAttribute.
textAttributeID: int, a value in class `TextAttributeId`.
val: COM VARIANT according to textAttributeId? todo.
backward: bool, True if the last occurring text range should be returned instead of the first; otherwise False.
return `TextRange` or None, a text range subset that has the specified text attribute value.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextrange-findattribute
"""
textRange = self.textRange.FindAttribute(textAttributeId, val, int(backward))
if textRange:
return TextRange(textRange=textRange)
|
Call IUIAutomationTextRange::FindAttribute.
textAttributeID: int, a value in class `TextAttributeId`.
val: COM VARIANT according to textAttributeId? todo.
backward: bool, True if the last occurring text range should be returned instead of the first; otherwise False.
return `TextRange` or None, a text range subset that has the specified text attribute value.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextrange-findattribute
|
FindAttribute
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def FindText(self, text: str, backward: bool, ignoreCase: bool) -> 'TextRange':
"""
Call IUIAutomationTextRange::FindText.
text: str,
backward: bool, True if the last occurring text range should be returned instead of the first; otherwise False.
ignoreCase: bool, True if case should be ignored; otherwise False.
return `TextRange` or None, a text range subset that contains the specified text.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextrange-findtext
"""
textRange = self.textRange.FindText(text, int(backward), int(ignoreCase))
if textRange:
return TextRange(textRange=textRange)
|
Call IUIAutomationTextRange::FindText.
text: str,
backward: bool, True if the last occurring text range should be returned instead of the first; otherwise False.
ignoreCase: bool, True if case should be ignored; otherwise False.
return `TextRange` or None, a text range subset that contains the specified text.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextrange-findtext
|
FindText
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def GetBoundingRectangles(self) -> List[Rect]:
"""
Call IUIAutomationTextRange::GetBoundingRectangles.
textAttributeId: int, a value in class `TextAttributeId`.
Return List[Rect], a list of `Rect`.
bounding rectangles for each fully or partially visible line of text in a text range..
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextrange-getboundingrectangles
for rect in textRange.GetBoundingRectangles():
print(rect.left, rect.top, rect.right, rect.bottom, rect.width(), rect.height(), rect.xcenter(), rect.ycenter())
"""
floats = self.textRange.GetBoundingRectangles()
rects = []
for i in range(len(floats) // 4):
rect = Rect(int(floats[i * 4]), int(floats[i * 4 + 1]),
int(floats[i * 4]) + int(floats[i * 4 + 2]), int(floats[i * 4 + 1]) + int(floats[i * 4 + 3]))
rects.append(rect)
return rects
|
Call IUIAutomationTextRange::GetBoundingRectangles.
textAttributeId: int, a value in class `TextAttributeId`.
Return List[Rect], a list of `Rect`.
bounding rectangles for each fully or partially visible line of text in a text range..
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextrange-getboundingrectangles
for rect in textRange.GetBoundingRectangles():
print(rect.left, rect.top, rect.right, rect.bottom, rect.width(), rect.height(), rect.xcenter(), rect.ycenter())
|
GetBoundingRectangles
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def GetChildren(self) -> List['Control']:
"""
Call IUIAutomationTextRange::GetChildren.
textAttributeId: int, a value in class `TextAttributeId`.
Return List[Control], a list of `Control` subclasses, embedded objects that fall within the text range..
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextrange-getchildren
"""
eleArray = self.textRange.GetChildren()
if eleArray:
controls = []
for i in range(eleArray.Length):
ele = eleArray.GetElement(i)
con = Control.CreateControlFromElement(element=ele)
if con:
controls.append(con)
return controls
return []
|
Call IUIAutomationTextRange::GetChildren.
textAttributeId: int, a value in class `TextAttributeId`.
Return List[Control], a list of `Control` subclasses, embedded objects that fall within the text range..
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextrange-getchildren
|
GetChildren
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def Move(self, unit: int, count: int, waitTime: float = OPERATION_WAIT_TIME) -> int:
"""
Call IUIAutomationTextRange::Move.
Move the text range forward or backward by the specified number of text units.
unit: int, a value in class `TextUnit`.
count: int, the number of text units to move.
A positive value moves the text range forward.
A negative value moves the text range backward. Zero has no effect.
waitTime: float.
Return: int, the number of text units actually moved.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextrange-move
"""
ret = self.textRange.Move(unit, count)
time.sleep(waitTime)
return ret
|
Call IUIAutomationTextRange::Move.
Move the text range forward or backward by the specified number of text units.
unit: int, a value in class `TextUnit`.
count: int, the number of text units to move.
A positive value moves the text range forward.
A negative value moves the text range backward. Zero has no effect.
waitTime: float.
Return: int, the number of text units actually moved.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextrange-move
|
Move
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def MoveEndpointByRange(self, srcEndPoint: int, textRange: 'TextRange', targetEndPoint: int, waitTime: float = OPERATION_WAIT_TIME) -> bool:
"""
Call IUIAutomationTextRange::MoveEndpointByRange.
Move one endpoint of the current text range to the specified endpoint of a second text range.
srcEndPoint: int, a value in class `TextPatternRangeEndpoint`.
textRange: `TextRange`.
targetEndPoint: int, a value in class `TextPatternRangeEndpoint`.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextrange-moveendpointbyrange
"""
ret = self.textRange.MoveEndpointByRange(srcEndPoint, textRange.textRange, targetEndPoint) == S_OK
time.sleep(waitTime)
return ret
|
Call IUIAutomationTextRange::MoveEndpointByRange.
Move one endpoint of the current text range to the specified endpoint of a second text range.
srcEndPoint: int, a value in class `TextPatternRangeEndpoint`.
textRange: `TextRange`.
targetEndPoint: int, a value in class `TextPatternRangeEndpoint`.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextrange-moveendpointbyrange
|
MoveEndpointByRange
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def MoveEndpointByUnit(self, endPoint: int, unit: int, count: int, waitTime: float = OPERATION_WAIT_TIME) -> int:
"""
Call IUIAutomationTextRange::MoveEndpointByUnit.
Move one endpoint of the text range the specified number of text units within the document range.
endPoint: int, a value in class `TextPatternRangeEndpoint`.
unit: int, a value in class `TextUnit`.
count: int, the number of units to move.
A positive count moves the endpoint forward.
A negative count moves backward.
A count of 0 has no effect.
waitTime: float.
Return int, the count of units actually moved.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextrange-moveendpointbyunit
"""
ret = self.textRange.MoveEndpointByUnit(endPoint, unit, count)
time.sleep(waitTime)
return ret
|
Call IUIAutomationTextRange::MoveEndpointByUnit.
Move one endpoint of the text range the specified number of text units within the document range.
endPoint: int, a value in class `TextPatternRangeEndpoint`.
unit: int, a value in class `TextUnit`.
count: int, the number of units to move.
A positive count moves the endpoint forward.
A negative count moves backward.
A count of 0 has no effect.
waitTime: float.
Return int, the count of units actually moved.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextrange-moveendpointbyunit
|
MoveEndpointByUnit
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def RemoveFromSelection(self, waitTime: float = OPERATION_WAIT_TIME) -> bool:
"""
Call IUIAutomationTextRange::RemoveFromSelection.
Remove the text range from an existing collection of selected text in a text container that supports multiple, disjoint selections.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextrange-removefromselection
"""
ret = self.textRange.RemoveFromSelection() == S_OK
time.sleep(waitTime)
return ret
|
Call IUIAutomationTextRange::RemoveFromSelection.
Remove the text range from an existing collection of selected text in a text container that supports multiple, disjoint selections.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextrange-removefromselection
|
RemoveFromSelection
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def ScrollIntoView(self, alignTop: bool = True, waitTime: float = OPERATION_WAIT_TIME) -> bool:
"""
Call IUIAutomationTextRange::ScrollIntoView.
Cause the text control to scroll until the text range is visible in the viewport.
alignTop: bool, True if the text control should be scrolled so that the text range is flush with the top of the viewport;
False if it should be flush with the bottom of the viewport.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextrange-scrollintoview
"""
ret = self.textRange.ScrollIntoView(int(alignTop)) == S_OK
time.sleep(waitTime)
return ret
|
Call IUIAutomationTextRange::ScrollIntoView.
Cause the text control to scroll until the text range is visible in the viewport.
alignTop: bool, True if the text control should be scrolled so that the text range is flush with the top of the viewport;
False if it should be flush with the bottom of the viewport.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextrange-scrollintoview
|
ScrollIntoView
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def Select(self, waitTime: float = OPERATION_WAIT_TIME) -> bool:
"""
Call IUIAutomationTextRange::Select.
Select the span of text that corresponds to this text range, and remove any previous selection.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextrange-select
"""
ret = self.textRange.Select() == S_OK
time.sleep(waitTime)
return ret
|
Call IUIAutomationTextRange::Select.
Select the span of text that corresponds to this text range, and remove any previous selection.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextrange-select
|
Select
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def GetActiveComposition(self) -> TextRange:
"""
Call IUIAutomationTextEditPattern::GetActiveComposition.
Return `TextRange` or None, the active composition.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtexteditpattern-getactivecomposition
"""
textRange = self.pattern.GetActiveComposition()
if textRange:
return TextRange(textRange=textRange)
|
Call IUIAutomationTextEditPattern::GetActiveComposition.
Return `TextRange` or None, the active composition.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtexteditpattern-getactivecomposition
|
GetActiveComposition
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def GetConversionTarget(self) -> TextRange:
"""
Call IUIAutomationTextEditPattern::GetConversionTarget.
Return `TextRange` or None, the current conversion target range..
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtexteditpattern-getconversiontarget
"""
textRange = self.pattern.GetConversionTarget()
if textRange:
return TextRange(textRange=textRange)
|
Call IUIAutomationTextEditPattern::GetConversionTarget.
Return `TextRange` or None, the current conversion target range..
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtexteditpattern-getconversiontarget
|
GetConversionTarget
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def GetSelection(self) -> List[TextRange]:
"""
Call IUIAutomationTextPattern::GetSelection.
Return List[TextRange], a list of `TextRange`, represents the currently selected text in a text-based control.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextpattern-getselection
"""
eleArray = self.pattern.GetSelection()
if eleArray:
textRanges = []
for i in range(eleArray.Length):
ele = eleArray.GetElement(i)
textRanges.append(TextRange(textRange=ele))
return textRanges
return []
|
Call IUIAutomationTextPattern::GetSelection.
Return List[TextRange], a list of `TextRange`, represents the currently selected text in a text-based control.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextpattern-getselection
|
GetSelection
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def GetVisibleRanges(self) -> List[TextRange]:
"""
Call IUIAutomationTextPattern::GetVisibleRanges.
Return List[TextRange], a list of `TextRange`, disjoint text ranges from a text-based control
where each text range represents a contiguous span of visible text.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextpattern-getvisibleranges
"""
eleArray = self.pattern.GetVisibleRanges()
if eleArray:
textRanges = []
for i in range(eleArray.Length):
ele = eleArray.GetElement(i)
textRanges.append(TextRange(textRange=ele))
return textRanges
return []
|
Call IUIAutomationTextPattern::GetVisibleRanges.
Return List[TextRange], a list of `TextRange`, disjoint text ranges from a text-based control
where each text range represents a contiguous span of visible text.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextpattern-getvisibleranges
|
GetVisibleRanges
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def RangeFromChild(self, child) -> TextRange:
"""
Call IUIAutomationTextPattern::RangeFromChild.
child: `Control` or its subclass.
Return `TextRange` or None, a text range enclosing a child element such as an image,
hyperlink, Microsoft Excel spreadsheet, or other embedded object.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextpattern-rangefromchild
"""
textRange = self.pattern.RangeFromChild(Control.Element)
if textRange:
return TextRange(textRange=textRange)
|
Call IUIAutomationTextPattern::RangeFromChild.
child: `Control` or its subclass.
Return `TextRange` or None, a text range enclosing a child element such as an image,
hyperlink, Microsoft Excel spreadsheet, or other embedded object.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextpattern-rangefromchild
|
RangeFromChild
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def RangeFromPoint(self, x: int, y: int) -> TextRange:
"""
Call IUIAutomationTextPattern::RangeFromPoint.
child: `Control` or its subclass.
Return `TextRange` or None, the degenerate (empty) text range nearest to the specified screen coordinates.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextpattern-rangefrompoint
"""
textRange = self.pattern.RangeFromPoint(ctypes.wintypes.POINT(x, y))
if textRange:
return TextRange(textRange=textRange)
|
Call IUIAutomationTextPattern::RangeFromPoint.
child: `Control` or its subclass.
Return `TextRange` or None, the degenerate (empty) text range nearest to the specified screen coordinates.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextpattern-rangefrompoint
|
RangeFromPoint
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def Toggle(self, waitTime: float = OPERATION_WAIT_TIME) -> bool:
"""
Call IUIAutomationTogglePattern::Toggle.
Cycle through the toggle states of the control.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtogglepattern-toggle
"""
ret = self.pattern.Toggle() == S_OK
time.sleep(waitTime)
return ret
|
Call IUIAutomationTogglePattern::Toggle.
Cycle through the toggle states of the control.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtogglepattern-toggle
|
Toggle
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def Move(self, x: int, y: int, waitTime: float = OPERATION_WAIT_TIME) -> bool:
"""
Call IUIAutomationTransformPattern::Move.
Move the UI Automation element.
x: int.
y: int.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtransformpattern-move
"""
ret = self.pattern.Move(x, y) == S_OK
time.sleep(waitTime)
return ret
|
Call IUIAutomationTransformPattern::Move.
Move the UI Automation element.
x: int.
y: int.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtransformpattern-move
|
Move
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def Resize(self, width: int, height: int, waitTime: float = OPERATION_WAIT_TIME) -> bool:
"""
Call IUIAutomationTransformPattern::Resize.
Resize the UI Automation element.
width: int.
height: int.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtransformpattern-resize
"""
ret = self.pattern.Resize(width, height) == S_OK
time.sleep(waitTime)
return ret
|
Call IUIAutomationTransformPattern::Resize.
Resize the UI Automation element.
width: int.
height: int.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtransformpattern-resize
|
Resize
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
def Rotate(self, degrees: int, waitTime: float = OPERATION_WAIT_TIME) -> bool:
"""
Call IUIAutomationTransformPattern::Rotate.
Rotates the UI Automation element.
degrees: int.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtransformpattern-rotate
"""
ret = self.pattern.Rotate(degrees) == S_OK
time.sleep(waitTime)
return ret
|
Call IUIAutomationTransformPattern::Rotate.
Rotates the UI Automation element.
degrees: int.
waitTime: float.
Return bool, True if succeed otherwise False.
Refer https://docs.microsoft.com/en-us/windows/desktop/api/uiautomationclient/nf-uiautomationclient-iuiautomationtransformpattern-rotate
|
Rotate
|
python
|
cluic/wxauto
|
wxauto/uiautomation.py
|
https://github.com/cluic/wxauto/blob/master/wxauto/uiautomation.py
|
Apache-2.0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.