本文整理汇总了Python中win32gui.GetClientRect方法的典型用法代码示例。如果您正苦于以下问题:Python win32gui.GetClientRect方法的具体用法?Python win32gui.GetClientRect怎么用?Python win32gui.GetClientRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类win32gui
的用法示例。
在下文中一共展示了win32gui.GetClientRect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetClientRect [as 别名]
def __init__(self, hwnd, quit_game_enable=1):
'''
初始化
:param hwnd: 需要绑定的窗口句柄
:param quit_game_enable: 程序死掉时是否退出游戏。True为是,False为否
'''
self.run = True
self.hwnd = hwnd
self.quit_game_enable = quit_game_enable
self.debug_enable = False
l1, t1, r1, b1 = win32gui.GetWindowRect(self.hwnd)
#print(l1,t1, r1,b1)
l2, t2, r2, b2 = win32gui.GetClientRect(self.hwnd)
# print(l2,t2,r2,b2)
self._client_h = b2 - t2
self._client_w = r2 - l2
self._border_l = ((r1 - l1) - (r2 - l2)) // 2
self._border_t = ((b1 - t1) - (b2 - t2)) - self._border_l
conf = configparser.ConfigParser()
conf.read('conf.ini')
self.client = conf.getint('DEFAULT', 'client')
if self.client == 1:
os.system('adb connect 127.0.0.1:7555')
os.system('adb devices')
示例2: __call__
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetClientRect [as 别名]
def __call__( self, window, hdc, paint_struct ):
src_roi = self.src_roi or (0, 0, self.bitmap.size[0], self.bitmap.size[1])
dst_roi = self.dst_roi or win32gui.GetClientRect( window.window_handle )
blend = self.blend or (win32con.AC_SRC_OVER, 0, 255, win32con.AC_SRC_ALPHA )
hdc_mem = win32gui.CreateCompatibleDC( hdc )
prior = win32gui.SelectObject( hdc_mem, self.bitmap.handle )
# Blit with alpha channel blending
win32gui.AlphaBlend( hdc,
dst_roi[ 0 ],
dst_roi[ 1 ],
dst_roi[ 2 ] - dst_roi[ 0 ],
dst_roi[ 3 ] - dst_roi[ 1 ],
hdc_mem,
src_roi[ 0 ],
src_roi[ 1 ],
src_roi[ 2 ] - src_roi[ 0 ],
src_roi[ 3 ] - src_roi[ 1 ],
blend )
win32gui.SelectObject( hdc_mem, prior )
win32gui.DeleteDC( hdc_mem )
示例3: __init__
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetClientRect [as 别名]
def __init__( self, parent ):
super( Window.ProgressBar, self ).__init__()
rect = win32gui.GetClientRect( parent.window_handle )
yscroll = win32api.GetSystemMetrics(win32con.SM_CYVSCROLL)
self.handle = win32gui.CreateWindowEx( 0,
commctrl.PROGRESS_CLASS,
None,
win32con.WS_VISIBLE | win32con.WS_CHILD,
rect[ 0 ] + yscroll,
(rect[ 3 ]) - 2 * yscroll,
(rect[ 2 ] - rect[ 0 ]) - 2*yscroll,
yscroll,
parent.window_handle,
self.registry_id,
win32gui.GetModuleHandle(None),
None )
示例4: OnInitDialog
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetClientRect [as 别名]
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)
示例5: OnPaint_2
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetClientRect [as 别名]
def OnPaint_2(hwnd, msg, wp, lp):
dc, ps=win32gui.BeginPaint(hwnd)
win32gui.SetGraphicsMode(dc, win32con.GM_ADVANCED)
l,t,r,b=win32gui.GetClientRect(hwnd)
for x in xrange(25):
vertices=(
{'x':int(random.random()*r), 'y':int(random.random()*b), 'Red':int(random.random()*0xff00), 'Green':0, 'Blue':0, 'Alpha':0},
{'x':int(random.random()*r), 'y':int(random.random()*b), 'Red':0, 'Green':int(random.random()*0xff00), 'Blue':0, 'Alpha':0},
{'x':int(random.random()*r), 'y':int(random.random()*b), 'Red':0, 'Green':0, 'Blue':int(random.random()*0xff00), 'Alpha':0},
)
mesh=((0,1,2),)
win32gui.GradientFill(dc,vertices, mesh, win32con.GRADIENT_FILL_TRIANGLE)
win32gui.EndPaint(hwnd, ps)
return 0
示例6: shot
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetClientRect [as 别名]
def shot(cls,name= 'playing.png'):
hwnd = win32gui.FindWindow(None, cls.processname)
# Change the line below depending on whether you want the whole window
# or just the client area.
left, top, right, bot = win32gui.GetClientRect(hwnd)
#left, top, right, bot = win32gui.GetWindowRect(hwnd)
w = right - left
h = bot - top
hwndDC = win32gui.GetWindowDC(hwnd)
mfcDC = win32ui.CreateDCFromHandle(hwndDC)
saveDC = mfcDC.CreateCompatibleDC()
saveBitMap = win32ui.CreateBitmap()
saveBitMap.CreateCompatibleBitmap(mfcDC, w, h)
saveDC.SelectObject(saveBitMap)
# Change the line below depending on whether you want the whole window
# or just the client area.
#result = windll.user32.PrintWindow(hwnd, saveDC.GetSafeHdc(), 1)
result = windll.user32.PrintWindow(hwnd, saveDC.GetSafeHdc(), 0)
bmpinfo = saveBitMap.GetInfo()
bmpstr = saveBitMap.GetBitmapBits(True)
im = Image.frombuffer(
'RGB',
(bmpinfo['bmWidth'], bmpinfo['bmHeight']),
bmpstr, 'raw', 'BGRX', 0, 1)
win32gui.DeleteObject(saveBitMap.GetHandle())
saveDC.DeleteDC()
mfcDC.DeleteDC()
win32gui.ReleaseDC(hwnd, hwndDC)
if result == 1:
#PrintWindow Succeeded
im.save("playing.png")
示例7: rect
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetClientRect [as 别名]
def rect(self):
hwnd = self.hwnd
if not self.exclude_border:
left, top, right, bottom = win32gui.GetWindowRect(hwnd)
else:
_left, _top, _right, _bottom = win32gui.GetClientRect(hwnd)
left, top = win32gui.ClientToScreen(hwnd, (_left, _top))
right, bottom = win32gui.ClientToScreen(hwnd, (_right, _bottom))
return Rect(left, top, right, bottom)
示例8: __init_rect_size
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetClientRect [as 别名]
def __init_rect_size(self):
hwnd = self.hwnd
left, top, right, bottom = win32gui.GetWindowRect(hwnd)
if self.exclude_border:
_left, _top, _right, _bottom = win32gui.GetClientRect(hwnd)
left, top = win32gui.ClientToScreen(hwnd, (_left, _top))
right, bottom = win32gui.ClientToScreen(hwnd, (_right, _bottom))
self._rect = Rect(left, top, right, bottom)
self._size = Size(right-left, bottom-top)
示例9: OnInitDialog
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetClientRect [as 别名]
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)
示例10: OnInitDialog
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetClientRect [as 别名]
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)
示例11: OnInitDialog
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetClientRect [as 别名]
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)
示例12: get_client_region
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetClientRect [as 别名]
def get_client_region( self ):
return win32gui.GetClientRect( self.window_handle )
示例13: __init__
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetClientRect [as 别名]
def __init__(self):
message_map = {
win32con.WM_DESTROY: self.OnDestroy,
win32con.WM_COMMAND: self.OnCommand,
win32con.WM_SIZE: self.OnSize,
}
# Register the Window class.
wc = win32gui.WNDCLASS()
hinst = wc.hInstance = win32api.GetModuleHandle(None)
wc.lpszClassName = "test_explorer_browser"
wc.lpfnWndProc = message_map # could also specify a wndproc.
classAtom = win32gui.RegisterClass(wc)
# Create the Window.
style = win32con.WS_OVERLAPPEDWINDOW | win32con.WS_VISIBLE
self.hwnd = win32gui.CreateWindow( classAtom, "Python IExplorerBrowser demo", style, \
0, 0, win32con.CW_USEDEFAULT, win32con.CW_USEDEFAULT, \
0, 0, hinst, None)
eb = pythoncom.CoCreateInstance(shellcon.CLSID_ExplorerBrowser, None, pythoncom.CLSCTX_ALL, shell.IID_IExplorerBrowser)
# as per MSDN docs, hook up events early
self.event_cookie = eb.Advise(wrap(EventHandler()))
eb.SetOptions(shellcon.EBO_SHOWFRAMES)
rect = win32gui.GetClientRect(self.hwnd)
# Set the flags such that the folders autoarrange and non web view is presented
flags = (shellcon.FVM_LIST, shellcon.FWF_AUTOARRANGE | shellcon.FWF_NOWEBVIEW)
eb.Initialize(self.hwnd, rect, (0, shellcon.FVM_DETAILS))
if len(sys.argv)==2:
# If an arg was specified, ask the desktop parse it.
# You can pass anything explorer accepts as its '/e' argument -
# eg, "::{guid}\::{guid}" etc.
# "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" is "My Computer"
pidl = shell.SHGetDesktopFolder().ParseDisplayName(0, None, sys.argv[1])[1]
else:
# And start browsing at the root of the namespace.
pidl = []
eb.BrowseToIDList(pidl, shellcon.SBSP_ABSOLUTE)
# and for some reason the "Folder" view in the navigator pane doesn't
# magically synchronize itself - so let's do that ourself.
# Get the tree control.
sp = eb.QueryInterface(pythoncom.IID_IServiceProvider)
try:
tree = sp.QueryService(shell.IID_INameSpaceTreeControl,
shell.IID_INameSpaceTreeControl)
except pythoncom.com_error, exc:
# this should really only fail if no "nav" frame exists...
print "Strange - failed to get the tree control even though " \
"we asked for a EBO_SHOWFRAMES"
print exc
示例14: _CreateChildWindow
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetClientRect [as 别名]
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()
示例15: show_splash_screen
# 需要导入模块: import win32gui [as 别名]
# 或者: from win32gui import GetClientRect [as 别名]
def show_splash_screen(self, height=None, width=None,
progress_bar=False, background=None,
message='', message_x=0.5, message_y=0.5):
# Reset splash window layers
#
self.splash_window.layers = []
if background:
image = PIL.Image.open( self.get_image_path( background ) )
background = Window.CompositorLayer()
background.operations.append( Compositor.Blend( image ) )
self.splash_window.layers.append( background )
if width and height:
pass
elif height and not width:
width = height * image.size[0] / image.size[1]
elif width and not height:
height = width * image.size[1] / image.size[0]
else:
height = image.size[1]
width = image.size[0]
if width and height:
self.splash_window.set_size( (0, 0, width, height) )
# TODO: position splash text
#
window_roi = win32gui.GetClientRect( self.splash_window.window_handle )
width = window_roi[2] - window_roi[0]
height = window_roi[3] - window_roi[1]
text_center = (window_roi[0] + int((window_roi[2] - window_roi[0]) * message_x),
window_roi[1] + int((window_roi[3] - window_roi[1]) * message_y))
width_pad = min(window_roi[2] - text_center[0],
text_center[0] - window_roi[0])
height_pad = min(window_roi[3] - text_center[1],
text_center[1] - window_roi[1])
text_roi = (text_center[0] - width_pad,
text_center[1] - height_pad,
text_center[0] + width_pad,
text_center[1] + height_pad)
text_props = { 'rect': text_roi }
if message:
text_props['text'] = message
self.splash_text.set_props( self.splash_window, **text_props )
self.splash_window.layers.append( self.splash_text )
if progress_bar:
self.progress_bar = Window.ProgressBar( self.splash_window )
self.progress_bar.set_range( self._progress_range )
self.progress_bar.set_step( 1 )
self.splash_window.center()
self.splash_window.set_visibility( True )
self.splash_window.focus()