def Menu():
try:
#??
pdhk=win32gui.GetWindowRect(win32gui.FindWindowEx(win32gui.FindWindow('TdxW_MainFrame_Class','???????V7.35 - [???-?????]'),None,'#32770',None))
win32api.SetCursorPos([pdhk[0]+330,pdhk[1]+10])
time.sleep(1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0,0,0)
time.sleep(1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0,0,0)
time.sleep(1)
#?????
win32api.SetCursorPos([pdhk[0]+380,pdhk[1]+20+480])
time.sleep(1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0,0,0)
time.sleep(1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0,0,0)
time.sleep(1)
except Exception as e:
ReadEBK.wx_msg(corp_id, secret,agentid,sys._getframe().f_code.co_name+'\t'+str(e))
#???????->?????
python类mouse_event()的实例源码
def Free_quotation():
time.sleep(3)
try:
Tab_handle = win32gui.FindWindowEx(win32gui.FindWindow('#32770','???????V7.35'),None,'SysTabControl32','Tab1')
#print(hex(Tab_handle))
#time.sleep(1)
p=win32gui.GetWindowRect(Tab_handle)
#print(p)
#print(p[2])
#print(p[3])
win32api.SetCursorPos([p[0]+170,p[1]+7])
time.sleep(1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0,0,0)
time.sleep(1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0,0,0)
time.sleep(1)
win32gui.PostMessage(win32gui.FindWindowEx(win32gui.FindWindow('#32770','???????V7.35'),None,'Button','??'),win32con.BM_CLICK,0,0)
time.sleep(3)
except Exception as e:
ReadEBK.wx_msg(corp_id, secret,agentid,sys._getframe().f_code.co_name+'\t'+str(e))
#?????
ctrl_waveQoE.py 文件源码
项目:Automation-Framework-for-devices
作者: tok-gogogo
项目源码
文件源码
阅读 25
收藏 0
点赞 0
评论 0
def click_CurrentPlace(self,lb_dx,lb_dy):
tmp=(string.atoi(lb_dx),string.atoi(lb_dy))
win32api.SetCursorPos(tmp)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,tmp[0], tmp[1])
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,tmp[0], tmp[1])
#-----------------------------------------------------------------------------
# Name: select_ssid
# purpose: select ssid.
# explain:
# Author: yuanwen
#
# Created: 2013/07/5
#-----------------------------------------------------------------------------
def selectComboboxItemThird(hwnd, item):
try: # item is an index Use this to select
0 + item
win32gui.SendMessage(hwnd, win32con.CB_SHOWDROPDOWN, 1, 0)
win32gui.SendMessage(hwnd, win32con.CB_SETCURSEL, item, 0)
win32gui.SendMessage(hwnd, win32con.WM_SETFOCUS, 0, 0 )
time.sleep(1)
tmp=win32gui.GetWindowRect(hwnd)
#print 'selectComboboxItemThird',tmp
'''
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,tmp[0]+1, tmp[1]+1)
time.sleep(0.1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,tmp[0]+1, tmp[1]+1)
'''
win32gui.SendMessage(hwnd, win32con.WM_KEYDOWN, 13, 0 )
time.sleep(0.1)
win32gui.SendMessage(hwnd, win32con.WM_KEYUP, 13, 0 )
time.sleep(0.1)
#_sendNotifyMessage(hwnd, win32con.CBN_SELCHANGE)
except TypeError: # Item is a string - find the index, and use that
items = getComboboxItems(hwnd)
itemIndex = items.index(item)
selectComboboxItem(hwnd, itemIndex)
def Mouse_LB_Double(self,str_app,lb_dx,lb_dy,Flag='1'):
time.sleep(1)
tmp=(string.atoi(lb_dx),string.atoi(lb_dy))
hwnd = win32gui.FindWindow(None, str_app)
print 'Mouse_RB str_app,hwnd ',str_app,hwnd
if hwnd < 1:
hwnd = self.find_main_window(str_app)
win32api.SetCursorPos(tmp)
time.sleep(1)
#win32api.SetDoubleCIckTime()
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,tmp[0], tmp[1])
time.sleep(0.005)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,tmp[0], tmp[1])
time.sleep(0.005)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,tmp[0], tmp[1])
time.sleep(0.005)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,tmp[0], tmp[1])
time.sleep(0.005)
return True
def Mouse_LB_D(self,str_app,lb_dx,lb_dy,Flag='1'):
time.sleep(1)
tmp=(string.atoi(lb_dx),string.atoi(lb_dy))
hwnd = win32gui.FindWindow(None, str_app)
print 'Mouse_RB str_app,hwnd ',str_app,hwnd
if hwnd < 1:
hwnd = self.find_main_window(str_app)
win32api.SetCursorPos(tmp)
time.sleep(1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,tmp[0], tmp[1])
time.sleep(0.05)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,tmp[0], tmp[1])
time.sleep(0.05)
return True
def Mouse_LB(self,str_app,lb_dx,lb_dy,Flag='1'):
print "*********Mouse_LB function**********"
time.sleep(1)
tmp=(string.atoi(lb_dx),string.atoi(lb_dy))
hwnd = win32gui.FindWindow(None, str_app)
if hwnd < 1:
hwnd = self.find_main_window(str_app)
#win32gui.ShowWindow(hwnd, 0)
win32api.SetCursorPos(tmp)
print 'Mouse_LB tmp =',tmp
if Flag == '1':
time.sleep(1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,tmp[0], tmp[1])
time.sleep(0.05)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,tmp[0], tmp[1])
time.sleep(0.05)
return True
ctrl_waveApps.py 文件源码
项目:Automation-Framework-for-devices
作者: tok-gogogo
项目源码
文件源码
阅读 23
收藏 0
点赞 0
评论 0
def click_CurrentPlace(self,lb_dx,lb_dy):
tmp=(string.atoi(lb_dx),string.atoi(lb_dy))
win32api.SetCursorPos(tmp)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,tmp[0], tmp[1])
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,tmp[0], tmp[1])
#-----------------------------------------------------------------------------
# Name: select_ssid
# purpose: select ssid.
# explain:
# Author: yuanwen
#
# Created: 2013/07/5
#-----------------------------------------------------------------------------
def CFQS():
try:
e = win32gui.GetWindowRect (win32gui.FindWindowEx(win32gui.FindWindowEx(win32gui.FindWindow('#32770','???????'),None,'#32770','???????'),None,'SysListView32','CFQS'))
win32api.SetCursorPos([e[0]+50,e[1]+25])
time.sleep(1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0,0,0)
time.sleep(1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0,0,0)
time.sleep(1)
except Exception as e:
ReadEBK.wx_msg(corp_id, secret,agentid,sys._getframe().f_code.co_name+'\t'+str(e))
#????
def button_event(content):
key_table = {'BACKSPACE':8, 'TAB':9, 'TABLE':9, 'CLEAR':12, 'ENTER':13, 'SHIFT':16, 'CTRL':17,
'CONTROL':17, 'ALT':18, 'ALTER':18, 'PAUSE':19, 'BREAK':19, 'CAPSLK':20, 'CAPSLOCK':20, 'ESC':27,
'SPACE':32, 'SPACEBAR':32, 'PGUP':33, 'PAGEUP':33, 'PGDN':34, 'PAGEDOWN':34, 'END':35, 'HOME':36,
'LEFT':37, 'UP':38, 'RIGHT':39, 'DOWN':40, 'SELECT':41, 'PRTSC':42, 'PRINTSCREEN':42, 'SYSRQ':42,
'SYSTEMREQUEST':42, 'EXECUTE':43, 'SNAPSHOT':44, 'INSERT':45, 'DELETE':46, 'HELP':47, 'WIN':91,
'WINDOWS':91, 'F1':112, 'F2':113, 'F3':114, 'F4':115, 'F5':116, 'F6':117, 'F7':118, 'F8':119,
'F9':120, 'F10':121, 'F11':122, 'F12':123, 'F13':124, 'F14':125, 'F15':126, 'F16':127, 'NMLK':144,
'NUMLK':144, 'NUMLOCK':144, 'SCRLK':145, 'SCROLLLOCK':145, 'LEFTCLICK':999, 'RIGHTCLICK':1000}
unrecognized = ''
key_values = []
keys = content.split('+')
for key in keys:
raw_key = key
key = key.strip().replace(' ','').upper()
if key in key_table:
key_values.append(key_table.get(key))
elif len(key) == 1:
key_values.append(ord(key))
else:
if key != '':
unrecognized = raw_key
for key_value in key_values:
if key_value == 999:
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
elif key_value == 1000:
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
else:
win32api.keybd_event(key_value, 0, 0, 0)
time.sleep(1)
for i in range(len(key_values)-1, -1, -1):
if key_value == 999:
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
elif key_value == 1000:
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
else:
win32api.keybd_event(key_values[i], 0, win32con.KEYEVENTF_KEYUP, 0)
time.sleep(1)
return unrecognized
#??????????
def stop_marking(self):
if self.__is_marking:
self.__is_marking = False
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
return True
return False
def __toggle_marking(self):
if self.__is_marking:
self.stop_marking()
else:
self.__is_marking = True
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
def _input_left_mouse(self, x, y):
left, top, right, bottom = self.rect
width, height = right - left, bottom - top
if x < 0 or x > width or y < 0 or y > height:
return
win32gui.SetForegroundWindow(self.hwnd)
pos = win32gui.GetCursorPos()
win32api.SetCursorPos((left+x, top+y))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0)
win32api.Sleep(100) #ms
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0)
win32api.Sleep(100) #ms
# win32api.SetCursorPos(pos)
def _input_left_mouse(self, x, y):
left, top, right, bottom = self.rect
width, height = right - left, bottom - top
if x < 0 or x > width or y < 0 or y > height:
return
win32gui.SetForegroundWindow(self.hwnd)
pos = win32gui.GetCursorPos()
win32api.SetCursorPos((left+x, top+y))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0)
win32api.Sleep(100) #ms
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0)
win32api.Sleep(100) #ms
# win32api.SetCursorPos(pos)
def mouse_click():
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
def clickWindow(hwnd, offset):
left, top, right, bottom = win32gui.GetWindowRect(hwnd)
# print('left, top, right, bottom', left, top, right, bottom)
win32api.SetCursorPos([left + offset, (bottom - top) // 2 + top])
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
time.sleep(0.2)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
time.sleep(0.2)
def MouseLDown(cls):
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
time.sleep(GLB_SLEEP_TIME)
def MouseLUp(cls):
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
time.sleep(GLB_SLEEP_TIME)
def MouseRDown(cls):
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
time.sleep(GLB_SLEEP_TIME)
def MouseRUp(cls):
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
time.sleep(GLB_SLEEP_TIME)
def MouseMove(cls, x, y):
sw = win32api.GetSystemMetrics(win32con.SM_CXSCREEN)
sh = win32api.GetSystemMetrics(win32con.SM_CYSCREEN)
nx = int(x * 65535 / sw)
ny = int(y * 65535 / sh)
win32api.mouse_event(win32con.MOUSEEVENTF_ABSOLUTE|win32con.MOUSEEVENTF_MOVE, nx, ny, 0, 0)
time.sleep(GLB_SLEEP_TIME)
def RClick(cls):
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN|win32con.MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
time.sleep(GLB_SLEEP_TIME)
def _mouse_click(x, y):
win32api.SetCursorPos((x, y))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)
def click(self, x, y):
win32api.SetCursorPos((x, y))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
def click(self, x, y):
win32api.SetCursorPos((x, y))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
def click(self, x, y):
win32api.SetCursorPos((x, y))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
def Mouseclick_lb(self,tmp=(220,230)):
win32api.SetCursorPos(tmp)
print 'Mouseclick_lb tmp:',tmp
time.sleep(1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,tmp[0], tmp[1])
time.sleep(0.1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,tmp[0], tmp[1])
time.sleep(0.1)
return True
ctrl_omnipeek.py 文件源码
项目:Automation-Framework-for-devices
作者: tok-gogogo
项目源码
文件源码
阅读 24
收藏 0
点赞 0
评论 0
def click_CurrentPlace(self,tmp=(259, 178)):
win32api.SetCursorPos(tmp)
self.sleep('1')
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,tmp[0], tmp[1])
self.sleep('0.05')
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,tmp[0], tmp[1])
self.sleep('0.05')
def Mouse_LB_D(self,str_app,lb_dx,lb_dy,Flag='1'):
time.sleep(1)
tmp=(string.atoi(lb_dx),string.atoi(lb_dy))
hwnd = win32gui.FindWindow(None, str_app)
#msg = 'Mouse_LB str_app,hwnd '+str_app+' '+ str(hwnd)
#log_print(msg)
if hwnd > 0:
win32api.SetCursorPos(tmp)
time.sleep(1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,tmp[0], tmp[1])
time.sleep(0.05)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,tmp[0], tmp[1])
time.sleep(0.05)
return True
return False
def FX_MouseLClick(x, y):
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)