def move(self, pos, hwnd=None):
"""
:param pos: A tuple describing the (X,Y,Width,Height) of the window OR
A tuple describing the (X,Y) coordinates of the top right windows position
:param hwnd: Move supplied window. If not supplied, then the default window is moved
:return: The window handle
"""
if hwnd is None:
hwnd = self.get_hwnd()
if len(pos) == 4:
win32gui.MoveWindow(hwnd, pos[0], pos[1], pos[2], pos[3], 1)
if len(pos) == 2:
win_size = self.get_bbox_size()
win32gui.MoveWindow(hwnd,pos[0],pos[1],win_size[0],win_size[1], 1)
python类MoveWindow()的实例源码
def _DoSize(self, cx, cy, repaint = 1):
# right-justify the textbox.
ctrl = win32gui.GetDlgItem(self.hwnd, IDC_SEARCHTEXT)
l, t, r, b = win32gui.GetWindowRect(ctrl)
l, t = win32gui.ScreenToClient(self.hwnd, (l,t) )
r, b = win32gui.ScreenToClient(self.hwnd, (r,b) )
win32gui.MoveWindow(ctrl, l, t, cx-l-5, b-t, repaint)
# The button.
ctrl = win32gui.GetDlgItem(self.hwnd, IDC_BUTTON_DISPLAY)
l, t, r, b = win32gui.GetWindowRect(ctrl)
l, t = win32gui.ScreenToClient(self.hwnd, (l,t) )
r, b = win32gui.ScreenToClient(self.hwnd, (r,b) )
list_y = b + 10
w = r - l
win32gui.MoveWindow(ctrl, cx - 5 - w, t, w, b-t, repaint)
# The list control
win32gui.MoveWindow(self.hwndList, 0, list_y, cx, cy-list_y, repaint)
# The last column of the list control.
new_width = cx - win32gui.SendMessage(self.hwndList, commctrl.LVM_GETCOLUMNWIDTH, 0)
win32gui.SendMessage(self.hwndList, commctrl.LVM_SETCOLUMNWIDTH, 1, new_width)
def _DoSize(self, cx, cy, repaint = 1):
# right-justify the textbox.
ctrl = win32gui.GetDlgItem(self.hwnd, IDC_SEARCHTEXT)
l, t, r, b = win32gui.GetWindowRect(ctrl)
l, t = win32gui.ScreenToClient(self.hwnd, (l,t) )
r, b = win32gui.ScreenToClient(self.hwnd, (r,b) )
win32gui.MoveWindow(ctrl, l, t, cx-l-5, b-t, repaint)
# The button.
ctrl = win32gui.GetDlgItem(self.hwnd, IDC_BUTTON_DISPLAY)
l, t, r, b = win32gui.GetWindowRect(ctrl)
l, t = win32gui.ScreenToClient(self.hwnd, (l,t) )
r, b = win32gui.ScreenToClient(self.hwnd, (r,b) )
list_y = b + 10
w = r - l
win32gui.MoveWindow(ctrl, cx - 5 - w, t, w, b-t, repaint)
# The list control
win32gui.MoveWindow(self.hwndList, 0, list_y, cx, cy-list_y, repaint)
# The last column of the list control.
new_width = cx - win32gui.SendMessage(self.hwndList, commctrl.LVM_GETCOLUMNWIDTH, 0)
win32gui.SendMessage(self.hwndList, commctrl.LVM_SETCOLUMNWIDTH, 1, new_width)
def move_window(hwnd, rect, gap=0, border=True):
"""
Moves window.
Args:
hwnd (int): The window handler.
rect: Rect(x, y, w, h) of new location.
Kwargs:
gap (int): Number of pixels between each window.
border (bool): Should invisible border should be accounted for.
"""
BORDER_WIDTH = 7 if border else 0 # Windows 10 has an invisible 8px border
x = int(rect.x) - BORDER_WIDTH + gap // 2
y = int(rect.y) + gap // 2
w = int(rect.w) + 2 * BORDER_WIDTH - gap
h = int(rect.h) + BORDER_WIDTH - gap # No hidden border on top
wg.MoveWindow(hwnd, x, y, w, h, True)
def OnSize(self, hwnd, msg, wparam, lparam):
#print "OnSize", self.hwnd_child, win32api.LOWORD(lparam), win32api.HIWORD(lparam)
if self.hwnd_child is not None:
x = win32api.LOWORD(lparam)
y = win32api.HIWORD(lparam)
win32gui.MoveWindow(self.hwnd_child, 0, 0, x, y, False)
# This uses scintilla to display a filename, and optionally jump to a line
# number.
def OnSize(self, hwnd, msg, wparam, lparam):
x = win32api.LOWORD(lparam)
y = win32api.HIWORD(lparam)
win32gui.MoveWindow(self.hwnd, 0, 0, x, y, False)
def OnSize(self, hwnd, msg, wparam, lparam):
#print "OnSize", self.hwnd_child, win32api.LOWORD(lparam), win32api.HIWORD(lparam)
if self.hwnd_child is not None:
x = win32api.LOWORD(lparam)
y = win32api.HIWORD(lparam)
win32gui.MoveWindow(self.hwnd_child, 0, 0, x, y, False)
# This uses scintilla to display a filename, and optionally jump to a line
# number.
def OnSize(self, hwnd, msg, wparam, lparam):
x = win32api.LOWORD(lparam)
y = win32api.HIWORD(lparam)
win32gui.MoveWindow(self.hwnd, 0, 0, x, y, False)
def OnInitDialog(self, hwnd, msg, wparam, lparam):
self.hwnd = hwnd
# centre the dialog
desktop = win32gui.GetDesktopWindow()
l,t,r,b = win32gui.GetWindowRect(self.hwnd)
dt_l, dt_t, dt_r, dt_b = win32gui.GetWindowRect(desktop)
centre_x, centre_y = win32gui.ClientToScreen( desktop, ( (dt_r-dt_l)//2, (dt_b-dt_t)//2) )
win32gui.MoveWindow(hwnd, centre_x-(r//2), centre_y-(b//2), r-l, b-t, 0)
self._SetupList()
l,t,r,b = win32gui.GetClientRect(self.hwnd)
self._DoSize(r-l,b-t, 1)
def OnSize(self, hwnd, msg, wparam, lparam):
#print "OnSize", self.hwnd_child, win32api.LOWORD(lparam), win32api.HIWORD(lparam)
if self.hwnd_child is not None:
x = win32api.LOWORD(lparam)
y = win32api.HIWORD(lparam)
win32gui.MoveWindow(self.hwnd_child, 0, 0, x, y, False)
# This uses scintilla to display a filename, and optionally jump to a line
# number.
def OnSize(self, hwnd, msg, wparam, lparam):
x = win32api.LOWORD(lparam)
y = win32api.HIWORD(lparam)
win32gui.MoveWindow(self.hwnd, 0, 0, x, y, False)
def OnInitDialog(self, hwnd, msg, wparam, lparam):
self.hwnd = hwnd
# centre the dialog
desktop = win32gui.GetDesktopWindow()
l,t,r,b = win32gui.GetWindowRect(self.hwnd)
dt_l, dt_t, dt_r, dt_b = win32gui.GetWindowRect(desktop)
centre_x, centre_y = win32gui.ClientToScreen( desktop, ( (dt_r-dt_l)//2, (dt_b-dt_t)//2) )
win32gui.MoveWindow(hwnd, centre_x-(r//2), centre_y-(b//2), r-l, b-t, 0)
self._SetupList()
l,t,r,b = win32gui.GetClientRect(self.hwnd)
self._DoSize(r-l,b-t, 1)
def enumHandler(hwnd, lParam):
if win32gui.IsWindowVisible(hwnd):
if 'WinGuake - Guake For Windows' in win32gui.GetWindowText(hwnd):
m_width = win32api.GetSystemMetrics(0)
m_length = win32api.GetSystemMetrics(1)
w_width = int(m_width)
w_length = int(m_length/2)
win32gui.MoveWindow(hwnd, 0, 0, w_width, w_length, True)
def enumHandler(hwnd, lParam):
if win32gui.IsWindowVisible(hwnd):
if 'WinGuake' in win32gui.GetWindowText(hwnd):
m_width = win32api.GetSystemMetrics(0)
m_length = win32api.GetSystemMetrics(1)
w_width = int(m_width)
w_length = int(m_length/2)
win32gui.MoveWindow(hwnd, 0, 0, w_width, w_length, True)
def enumHandler(hwnd, lParam):
if win32gui.IsWindowVisible(hwnd):
if 'WinGuake - Guake For Windows' in win32gui.GetWindowText(hwnd):
m_width = GetSystemMetrics(0)
m_length = GetSystemMetrics(1)
w_width = int(m_width)
w_length = int(m_length/2)
win32gui.MoveWindow(hwnd, 0, 0, w_width, w_length, True)
ctrl_waveQoE.py 文件源码
项目:Automation-Framework-for-devices
作者: tok-gogogo
项目源码
文件源码
阅读 24
收藏 0
点赞 0
评论 0
def open_waveQoE(self):
#open waveQoE,wait for 3 seconds
try:
win32api.ShellExecute(0,'open',WAVEQOE_EXE_PATH,'','',1)
print "open waveQoE"
time.sleep(3)
except:
print 'open waveQoE error'
log_public(ERR_NO_0005)
self.m_ERROR_MSG = ERR_NO_0005
return False
#find handle for the waveQoE window
hwnd2 = win32gui.FindWindow(WAVEQOE_CLASS,'IxVeriwave WaveQoE Main Page')
print 'hwnd2',hwnd2
#move window of 'IxVeriwave WaveQoE Main Page' to top left corner
win32gui.MoveWindow(hwnd2,0,0,626,270,1)
time.sleep(0.5)
#click button -- 'wired and wireless testing'
self.myobj.Mouse_LB_D(str_app = WAVEQOE_CLASS,lb_dx = '238',lb_dy = '165',Flag = '1')
time.sleep(0.5)
#click button -- 'wired only testing'
#self.myobj.Mouse_LB_D(str_app='QWidget',lb_dx='426',lb_dy='166',Flag='1')
#click button -- 'apply'
self.myobj.Mouse_LB_D(str_app = WAVEQOE_CLASS,lb_dx = '305',lb_dy = '240',Flag = '1')
return True
#-----------------------------------------------------------------------------
# Name: choose_conf_file
# purpose: choose config file which has saved config infomation for test.
# explain:
# Author: gongke
#
# Created: 2013/05/20
#-----------------------------------------------------------------------------
def app_Move(self,str_app):
#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)
if hwnd>1:
win32gui.MoveWindow(hwnd,0,0,self.wdx,self.wdy,1)
else:
return False
return True
def findTopWindow(self,wantedText=None, wantedClass=None, selectionFunction=None):
'''Find the hwnd of a top level window.
You can identify windows using captions, classes, a custom selection
function, or any combination of these. (Multiple selection criteria are
ANDed. If this isn't what's wanted, use a selection function.)
Arguments:
wantedText Text which the required window's captions must contain.
wantedClass Class to which the required window must belong.
selectionFunction Window selection function. Reference to a function
should be passed here. The function should take hwnd as
an argument, and should return True when passed the
hwnd of a desired window.
Raises:
WinGuiAutoError When no window found.
Usage example: optDialog = findTopWindow(wantedText="Options")
'''
topWindows = self.findTopWindows(wantedText, wantedClass, selectionFunction)
if topWindows:
win32gui.MoveWindow(topWindows[0],0,0,self.wdx,self.wdy,1)
return topWindows[0]
else:
raise WinGuiAutoError("No top level window found for wantedText=" +
repr(wantedText) +
", wantedClass=" +
repr(wantedClass) +
", selectionFunction=" +
repr(selectionFunction))
ctrl_waveApps.py 文件源码
项目:Automation-Framework-for-devices
作者: tok-gogogo
项目源码
文件源码
阅读 19
收藏 0
点赞 0
评论 0
def open_waveApps(self):
#open waveApps,wait for 3 seconds
try:
win32api.ShellExecute(0,'open',WAVEApps_EXE_PATH,'','',1)
print "open waveApps"
time.sleep(3)
except:
print 'open waveApps error'
log_public(ERR_NO_0005)
self.m_ERROR_MSG = ERR_NO_0005
return False
'''
#find handle for the waveApps window
hwnd2 = win32gui.FindWindow(WAVEApps_CLASS,'IxVeriwave WaveApps Main Page')
print 'hwnd2',hwnd2
#move window of 'IxVeriwave WaveApps Main Page' to top left corner
win32gui.MoveWindow(hwnd2,0,0,626,270,1)
time.sleep(0.5)
#click button -- 'wired and wireless testing'
self.myobj.Mouse_LB_D(str_app = WAVEApps_CLASS,lb_dx = '238',lb_dy = '165',Flag = '1')
time.sleep(0.5)
#click button -- 'wired only testing'
#self.myobj.Mouse_LB_D(str_app='QWidget',lb_dx='426',lb_dy='166',Flag='1')
#click button -- 'apply'
self.myobj.Mouse_LB_D(str_app = WAVEApps_CLASS,lb_dx = '305',lb_dy = '240',Flag = '1')
'''
return True
#-----------------------------------------------------------------------------
# Name: choose_conf_file
# purpose: choose config file which has saved config infomation for test.
# explain:
# Author: gongke
#
# Created: 2013/05/20
#-----------------------------------------------------------------------------
def find_wind(self,str_app):
hwnd = win32gui.FindWindow(None, str_app)
log_print(hwnd)
if hwnd>0:
#win32gui.SetForegroundWindow(hwnd)
win32gui.MoveWindow(hwnd,40,40,840,640,1)
time.sleep(1)
win32gui.MoveWindow(hwnd,0,0,800,600,1)
#win32gui.ShowWindow(hwnd,win32con.SW_SHOWMAXIMIZED)
#win_GUI.win_gui().Mousepos_print('20')
time.sleep(1)
return True
return False
def _CreateChildWindow(self, prev):
# Creates the list view window.
assert self.hwnd_child is None, "already have a window"
assert self.cur_foldersettings is not None, "no settings"
style = win32con.WS_CHILD | win32con.WS_VISIBLE | win32con.WS_BORDER | \
commctrl.LVS_SHAREIMAGELISTS | commctrl.LVS_EDITLABELS
view_mode, view_flags = self.cur_foldersettings
if view_mode==shellcon.FVM_ICON:
style |= commctrl.LVS_ICON | commctrl.LVS_AUTOARRANGE
elif view_mode==shellcon.FVM_SMALLICON:
style |= commctrl.LVS_SMALLICON | commctrl.LVS_AUTOARRANGE
elif view_mode==shellcon.FVM_LIST:
style |= commctrl.LVS_LIST | commctrl.LVS_AUTOARRANGE
elif view_mode==shellcon.FVM_DETAILS:
style |= commctrl.LVS_REPORT | commctrl.LVS_AUTOARRANGE
else:
# XP 'thumbnails' etc
view_mode = shellcon.FVM_DETAILS
# Default to 'report'
style |= commctrl.LVS_REPORT | commctrl.LVS_AUTOARRANGE
for f_flag, l_flag in [
(shellcon.FWF_SINGLESEL, commctrl.LVS_SINGLESEL),
(shellcon.FWF_ALIGNLEFT, commctrl.LVS_ALIGNLEFT),
(shellcon.FWF_SHOWSELALWAYS, commctrl.LVS_SHOWSELALWAYS),
]:
if view_flags & f_flag:
style |= l_flag
self.hwnd_child = win32gui.CreateWindowEx(
win32con.WS_EX_CLIENTEDGE,
"SysListView32", None, style,
0, 0, 0, 0,
self.hwnd, 1000, 0, None)
cr = win32gui.GetClientRect(self.hwnd)
win32gui.MoveWindow(self.hwnd_child,
0, 0, cr[2]-cr[0], cr[3]-cr[1],
True)
# Setup the columns for the view.
lvc, extras = win32gui_struct.PackLVCOLUMN(fmt=commctrl.LVCFMT_LEFT,
subItem=1,
text='Name',
cx=300)
win32gui.SendMessage(self.hwnd_child, commctrl.LVM_INSERTCOLUMN,
0, lvc)
lvc, extras = win32gui_struct.PackLVCOLUMN(fmt=commctrl.LVCFMT_RIGHT,
subItem=1,
text='Exists',
cx=50)
win32gui.SendMessage(self.hwnd_child, commctrl.LVM_INSERTCOLUMN,
1, lvc)
# and fill it with the content
self.Refresh()
def _CreateChildWindow(self, prev):
# Creates the list view window.
assert self.hwnd_child is None, "already have a window"
assert self.cur_foldersettings is not None, "no settings"
style = win32con.WS_CHILD | win32con.WS_VISIBLE | win32con.WS_BORDER | \
commctrl.LVS_SHAREIMAGELISTS | commctrl.LVS_EDITLABELS
view_mode, view_flags = self.cur_foldersettings
if view_mode==shellcon.FVM_ICON:
style |= commctrl.LVS_ICON | commctrl.LVS_AUTOARRANGE
elif view_mode==shellcon.FVM_SMALLICON:
style |= commctrl.LVS_SMALLICON | commctrl.LVS_AUTOARRANGE
elif view_mode==shellcon.FVM_LIST:
style |= commctrl.LVS_LIST | commctrl.LVS_AUTOARRANGE
elif view_mode==shellcon.FVM_DETAILS:
style |= commctrl.LVS_REPORT | commctrl.LVS_AUTOARRANGE
else:
# XP 'thumbnails' etc
view_mode = shellcon.FVM_DETAILS
# Default to 'report'
style |= commctrl.LVS_REPORT | commctrl.LVS_AUTOARRANGE
for f_flag, l_flag in [
(shellcon.FWF_SINGLESEL, commctrl.LVS_SINGLESEL),
(shellcon.FWF_ALIGNLEFT, commctrl.LVS_ALIGNLEFT),
(shellcon.FWF_SHOWSELALWAYS, commctrl.LVS_SHOWSELALWAYS),
]:
if view_flags & f_flag:
style |= l_flag
self.hwnd_child = win32gui.CreateWindowEx(
win32con.WS_EX_CLIENTEDGE,
"SysListView32", None, style,
0, 0, 0, 0,
self.hwnd, 1000, 0, None)
cr = win32gui.GetClientRect(self.hwnd)
win32gui.MoveWindow(self.hwnd_child,
0, 0, cr[2]-cr[0], cr[3]-cr[1],
True)
# Setup the columns for the view.
lvc, extras = win32gui_struct.PackLVCOLUMN(fmt=commctrl.LVCFMT_LEFT,
subItem=1,
text='Name',
cx=300)
win32gui.SendMessage(self.hwnd_child, commctrl.LVM_INSERTCOLUMN,
0, lvc)
lvc, extras = win32gui_struct.PackLVCOLUMN(fmt=commctrl.LVCFMT_RIGHT,
subItem=1,
text='Exists',
cx=50)
win32gui.SendMessage(self.hwnd_child, commctrl.LVM_INSERTCOLUMN,
1, lvc)
# and fill it with the content
self.Refresh()
def _CreateChildWindow(self, prev):
# Creates the list view window.
assert self.hwnd_child is None, "already have a window"
assert self.cur_foldersettings is not None, "no settings"
style = win32con.WS_CHILD | win32con.WS_VISIBLE | win32con.WS_BORDER | \
commctrl.LVS_SHAREIMAGELISTS | commctrl.LVS_EDITLABELS
view_mode, view_flags = self.cur_foldersettings
if view_mode==shellcon.FVM_ICON:
style |= commctrl.LVS_ICON | commctrl.LVS_AUTOARRANGE
elif view_mode==shellcon.FVM_SMALLICON:
style |= commctrl.LVS_SMALLICON | commctrl.LVS_AUTOARRANGE
elif view_mode==shellcon.FVM_LIST:
style |= commctrl.LVS_LIST | commctrl.LVS_AUTOARRANGE
elif view_mode==shellcon.FVM_DETAILS:
style |= commctrl.LVS_REPORT | commctrl.LVS_AUTOARRANGE
else:
# XP 'thumbnails' etc
view_mode = shellcon.FVM_DETAILS
# Default to 'report'
style |= commctrl.LVS_REPORT | commctrl.LVS_AUTOARRANGE
for f_flag, l_flag in [
(shellcon.FWF_SINGLESEL, commctrl.LVS_SINGLESEL),
(shellcon.FWF_ALIGNLEFT, commctrl.LVS_ALIGNLEFT),
(shellcon.FWF_SHOWSELALWAYS, commctrl.LVS_SHOWSELALWAYS),
]:
if view_flags & f_flag:
style |= l_flag
self.hwnd_child = win32gui.CreateWindowEx(
win32con.WS_EX_CLIENTEDGE,
"SysListView32", None, style,
0, 0, 0, 0,
self.hwnd, 1000, 0, None)
cr = win32gui.GetClientRect(self.hwnd)
win32gui.MoveWindow(self.hwnd_child,
0, 0, cr[2]-cr[0], cr[3]-cr[1],
True)
# Setup the columns for the view.
lvc, extras = win32gui_struct.PackLVCOLUMN(fmt=commctrl.LVCFMT_LEFT,
subItem=1,
text='Name',
cx=300)
win32gui.SendMessage(self.hwnd_child, commctrl.LVM_INSERTCOLUMN,
0, lvc)
lvc, extras = win32gui_struct.PackLVCOLUMN(fmt=commctrl.LVCFMT_RIGHT,
subItem=1,
text='Exists',
cx=50)
win32gui.SendMessage(self.hwnd_child, commctrl.LVM_INSERTCOLUMN,
1, lvc)
# and fill it with the content
self.Refresh()
ctrl_waveQoE.py 文件源码
项目:Automation-Framework-for-devices
作者: tok-gogogo
项目源码
文件源码
阅读 18
收藏 0
点赞 0
评论 0
def choose_conf_file(self):
#get control of waveQoE window.
hwnd3 = win32gui.FindWindow(WAVEQOE_CLASS,None)
print 'hwnd3',hwnd3
time.sleep(0.5)
#set waveQoE window to top.
win32gui.SetForegroundWindow(hwnd3)
time.sleep(0.5)
#move waveQoE window to top left corner.
win32gui.MoveWindow(hwnd3,0,0,1448,878,1)
#send Alt+F to open 'File' in menu bar.
win32api.Sleep(1000)
win32api.keybd_event(18,0,0,0); #18Alt?
win32api.keybd_event(70,0,0,0); #70F?
win32api.Sleep(1000)
win32api.keybd_event(70,0,win32con.KEYEVENTF_KEYUP,0);
win32api.keybd_event(18,0,win32con.KEYEVENTF_KEYUP,0);
win32api.Sleep(1000)
#send O to open 'open' window.
win32api.keybd_event(79,0,0,0); #79O?
win32api.Sleep(1000)
win32api.keybd_event(79,0,win32con.KEYEVENTF_KEYUP,0);
win32api.Sleep(1000)
#choose config file and open it.
self.myobj.Find_Gui_edit(str_app = 'Open',control_class = 'ComboBox',filename = self.conf_file_dir,control_name = '',stop_flag = '0')
self.myobj.Find_Gui_button(str_app = 'Open',control_class = 'Button',control_name = '(&O)')
time.sleep(0.5)
hwnd4 = win32gui.FindWindow('#32770','Open')
print 'hwnd4: ',hwnd4
if hwnd4 > 0:
log_public(ERR_NO_0006)
self.m_ERROR_MSG = ERR_NO_0006
self.myobj.Find_Gui_button(str_app = 'Open',control_class = 'Button',control_name = '?')
time.sleep(0.5)
self.myobj.Find_Gui_button(str_app = 'Open',control_class = 'Button',control_name = '?')
time.sleep(0.5)
self.close_waveQoE()
print 'close_waveqoe'
return False
else:
print 'conf_file is correct.'
return True
#-----------------------------------------------------------------------------
# Name: Mouse_LB_click
# purpose: click the mouse's left butten.
# explain:
# Author: yuanwen
#
# Created: 2013/07/5
#-----------------------------------------------------------------------------
ctrl_waveApps.py 文件源码
项目:Automation-Framework-for-devices
作者: tok-gogogo
项目源码
文件源码
阅读 23
收藏 0
点赞 0
评论 0
def choose_conf_file(self):
#get control of waveApps window.
hwnd3 = win32gui.FindWindow(WAVEApps_CLASS,None)
print 'hwnd3',hwnd3
time.sleep(0.5)
#set waveApps window to top.
win32gui.SetForegroundWindow(hwnd3)
time.sleep(0.5)
#move waveApps window to top left corner.
win32gui.MoveWindow(hwnd3,0,0,1448,878,1)
#send Alt+F to open 'File' in menu bar.
win32api.Sleep(1000)
win32api.keybd_event(18,0,0,0); #18Alt?
win32api.keybd_event(70,0,0,0); #70F?
win32api.Sleep(1000)
win32api.keybd_event(70,0,win32con.KEYEVENTF_KEYUP,0);
win32api.keybd_event(18,0,win32con.KEYEVENTF_KEYUP,0);
win32api.Sleep(1000)
#send O to open 'open' window.
win32api.keybd_event(79,0,0,0); #79O?
win32api.Sleep(1000)
win32api.keybd_event(79,0,win32con.KEYEVENTF_KEYUP,0);
win32api.Sleep(1000)
#choose config file and open it.
self.myobj.Find_Gui_edit(str_app = 'Open',control_class = 'ComboBox',filename = self.conf_file_dir,control_name = '',stop_flag = '0')
self.myobj.Find_Gui_button(str_app = 'Open',control_class = 'Button',control_name = '(&O)')
time.sleep(0.5)
hwnd4 = win32gui.FindWindow('#32770','Open')
print 'hwnd4: ',hwnd4
if hwnd4 > 0:
log_public(ERR_NO_0006)
self.m_ERROR_MSG = ERR_NO_0006
self.myobj.Find_Gui_button(str_app = 'Open',control_class = 'Button',control_name = '?')
time.sleep(0.5)
self.myobj.Find_Gui_button(str_app = 'Open',control_class = 'Button',control_name = '?')
time.sleep(0.5)
self.close_waveApps()
print 'close_waveApps'
return False
else:
print 'conf_file is correct.'
return True
#-----------------------------------------------------------------------------
# Name: Mouse_LB_click
# purpose: click the mouse's left butten.
# explain:
# Author: yuanwen
#
# Created: 2013/07/5
#-----------------------------------------------------------------------------
new_selenium.py 文件源码
项目:Automation-Framework-for-devices
作者: tok-gogogo
项目源码
文件源码
阅读 17
收藏 0
点赞 0
评论 0
def op_web(self,total=4):
run_total = 0
while True:
run_total = run_total + 1
print 'run_total:',run_total
app_f = findwindows.find_windows(class_name_re = "MainForm")
print 'app_f:',app_f
self.driver = webdriver.Firefox()
try:
for hwnd in app_f:
win32gui.MoveWindow(hwnd,0,0,1228,664,1)
win32gui.MoveWindow(hwnd,20,20,1248,684,1)
win32gui.SetWindowPos(hwnd,win32con.HWND_TOP,0,0,1228,664,win32con.HWND_TOP|win32con.SWP_SHOWWINDOW)
break
self.driver.delete_all_cookies()
self.driver.get(self.base_url)
time.sleep(20)
js="var q=document.documentElement.scrollTop=1500"
self.driver.execute_script(js)
self.main_win = self.driver.current_window_handle
self.tmp_list=[]
num_l = self.tmp_list_num(BABY_TOTAL)
random.shuffle(num_l)
self.tmp_list.append(self.main_win)
tmpnum = 0
while True:
num = random.randrange(0,len(num_l)-1)
tmpnum = num_l[num]
del num_l[num]
print 'num:',num ,' tmpnum:',tmpnum
self.caozuo(self.driver,str(tmpnum))
self.driver.switch_to_window(self.main_win)
tmpnum = tmpnum +1
if tmpnum >total:
break
self.driver.quit()
except Exception,e:
print 'except:',e
time.sleep(60)
self.driver.quit()
pass
time.sleep(20)