qt4c.util

其他共用类模块

Module Contents

Classes

Point 坐标点类
Rectangle 矩形区域类
ProcessMem 跨进程数据读写
MsgSyncer Thread Post Message 同步
Process 提供系统进程的操作类
MetisView 各端实现的MetisView

Functions

getEncoding(s) 获取字符串的编码
myEncode(s, ec=’unicode’, sc=None) 将字符串转换为指定的编码的字符串
getToolTips(className=’tooltips_class32’, retry=10) 获取系统的浮动tips
remote_inject_dll(process_id, dll_path) 在process_id进程中远程注入dll_path的DLL
is_system_locked() 检测系统是否处于锁屏界面
getDpi(hwnd=None)
qt4c.util.unicode
qt4c.util._DEFAULT_BUFFER_SIZE = 255
qt4c.util.SIZEOF
class qt4c.util.Point(x_y)

Bases: object

坐标点类

X
Y
All
__eq__(self, pt)

Return self==value.

class qt4c.util.Rectangle(left_top_right_bottom)

Bases: object

矩形区域类

All
Bottom
Center
Left
Right
Top
Width
Height
__str__(self)

Return str(self).

isInRect(self, rc)

判断此区域是否在参数rc的范围内

参数:rc (Rectangle) – 包含的区域
highLight(self)

高亮此区域

__eq__(self, rc)

Return self==value.

__ne__(self, rc)

Return self!=value.

class qt4c.util.ProcessMem(processId, buffer_size=None, remote_buffer=None)

Bases: object

跨进程数据读写

Buffer

返回远程进程中内存buffer地址

__del__(self)
write(self, local_buffer, buffer_size)

将local_buffer中的数据写入远程内存中。

参数:
  • local_buffer (buffer) – A pointer to the buffer that contains data to be written in the address space of the specified process
  • buffer_size (unsigned long) – The number of bytes to be written to the specified process
read(self, local_buffer, buffer_size)

将远程数据读到本地buffer

参数:
  • local_buffer (buffer) – A pointer to a buffer that receives the contents from the address space of the specified process
  • buffer_size (unsigned long) – The number of bytes to be read from the specified process
qt4c.util.getEncoding(s)

获取字符串的编码

返回类型:string
返回:‘GBK’,’UNICODE’,’UTF-8’,’UNKNOWN’
qt4c.util.myEncode(s, ec='unicode', sc=None)

将字符串转换为指定的编码的字符串

参数:
  • s (string) – 待转换的字符串
  • ec (string) – 待转换的编码. [‘GBK’,’UNICODE’,’UTF-8’]
  • sc (string) – 待转换的字符串的编码
Attention:

sc默认值为None,此时函数会自动判断s的编码(有一定概率会判断错误)

返回:

转换后的字符串

qt4c.util.getToolTips(className='tooltips_class32', retry=10)

获取系统的浮动tips

参数:
  • className (字符串) – 类名,默认值为”tooltips_class32”
  • retry (整数) – 尝试次数,每个0.5秒尝试一次
class qt4c.util.MsgSyncer(hwnd)

Bases: object

Thread Post Message 同步

pid_event_map
wait(self, timeout=60)

等待消息同步

qt4c.util.remote_inject_dll(process_id, dll_path)

在process_id进程中远程注入dll_path的DLL

class qt4c.util.Process(pid)

Bases: object

提供系统进程的操作类 使用例子: for proc in Process.GetProcessesByName(‘iexplore.exe’):

print proc.ProcessId
ProcessName

返回进程名字。失败返回None

Live
ProcessId
ProcessPath

获取进程可执行文件的全路径

static GetProcessesByName(process_name)

返回进程名为process_name的Process类实例列表

waitForQuit(self, timeout=10, interval=0.5)

在指定的时间内等待退出

返回:如果在指定的时间内退出,返回True;否则返回False
_adjustProcessPrivileges(self)

提升权限

terminate(self)

终止进程

qt4c.util.is_system_locked()

检测系统是否处于锁屏界面

@return: bool 如果处于锁屏,返回True

class qt4c.util.MetisView(control)

Bases: object

各端实现的MetisView

rect

元素相对坐标(x, y, w, h)

os_type

系统类型,例如”android”,”ios”,”pc”

screenshot(self)

当前容器的区域截图

click(self, offset_x=None, offset_y=None)

点击

参数:
  • offset_x (float|None) – 相对于该控件的坐标offset_x,百分比( 0 -> 1 ),不传入则默认该控件的中央
  • offset_y (float|None) – 相对于该控件的坐标offset_y,百分比( 0 -> 1 ),不传入则默认该控件的中央
send_keys(self, text)
double_click(self, offset_x=None, offset_y=None)
long_click(self, offset_x=None, offset_y=None)
qt4c.util.getDpi(hwnd=None)