コード例 #1
0
def get_active_monitor():
    #for hMonitor, hdcMonitor, rect in win32api.EnumDisplayMonitors(None, None):
    #    print rect, win32api.GetMonitorInfo(hMonitor)
    #    #print win32api.GetMonitorInfo(hMonitor)
    return win32api.GetMonitorInfo(
        win32api.MonitorFromPoint(get_cursor_pos(),
                                  win32con.MONITOR_DEFAULTTONEAREST))
コード例 #2
0
    def resize(self, width=250, height=450):
        monitor_info = win32api.GetMonitorInfo(
            win32api.MonitorFromPoint((0, 0)))
        work_area = monitor_info["Work"]

        self.root.minsize(width, height)
        self.root.geometry('%dx%d+%d+%d' % (width, height,
                                            (work_area[2] / 2) - (width / 2),
                                            (work_area[3] / 2) - (height / 2)))
コード例 #3
0
ファイル: __init__.py プロジェクト: QGB/QPSU
def is_monitor_off():
    ''' #TODO msg loop
只有这四种:
'MONITORINFOF_PRIMARY',
'MONITOR_DEFAULTTONEAREST',
'MONITOR_DEFAULTTONULL',
'MONITOR_DEFAULTTOPRIMARY',
 
 '''
    import win32gui, win32con, win32api
    hMonitor = win32api.MonitorFromPoint((0, 0),
                                         win32con.MONITOR_DEFAULTTOPRIMARY)

    return
コード例 #4
0
    def identify_monitor_params(self):
        monitor_info = win32api.GetMonitorInfo(
            win32api.MonitorFromPoint(win32api.GetCursorPos()))
        self.logger.debug('Monitor info,: %s ', str(monitor_info))

        self.width_offset = monitor_info.get('Monitor')[0]
        all_width = monitor_info.get('Monitor')[2]
        self.width = all_width - self.width_offset

        self.logger.debug('Monitor detection, width: %s ', str(self.width))

        self.height_offset = monitor_info.get('Monitor')[1]
        all_height = monitor_info.get('Monitor')[3]
        self.height = all_height - self.height_offset

        self.logger.debug('Monitor detection, height: %s ', str(self.height))
コード例 #5
0
 def __init__(self, filePath):
     #   窗体创建
     super(MenuBar, self).__init__()
     self.setupUi(self)
     self.mainWindow = None
     self.ADP_filePath = filePath
     work_area = win32api.GetMonitorInfo(win32api.MonitorFromPoint(
         (0, 0))).get("Work")
     self.monitor_width = work_area[2] - 20
     self.monitor_height = work_area[3]
     # self.setGeometry(0, 0, self.monitor_width, 25)
     self.resize(self.monitor_width, 25)
     self.move(0, 0)
     # mainWindow是否被打开
     self.is_mainWindow_showed = False
     # 菜单栏事件
     self.actionupdateATP.triggered.connect(self.updateATP)
     self.actionrunATP.triggered.connect(self.runATP)
     self.actionloadADP.triggered.connect(self.load_new_project)
コード例 #6
0
    def get_monitor_params(self):
        monitor_info = win32api.GetMonitorInfo(
            win32api.MonitorFromPoint(win32api.GetCursorPos()))
        # self.logger.debug('Monitor info,: %s ', str(monitor_info))

        width_offset = monitor_info.get('Monitor')[0]
        all_width = monitor_info.get('Monitor')[2]
        width = all_width - width_offset

        self.logger.debug('Monitor detection, width: %s ', str(width))

        height_offset = monitor_info.get('Monitor')[1]
        all_height = monitor_info.get('Monitor')[3]
        height = all_height - height_offset

        self.logger.debug('Monitor detection, height: %s ', str(height))

        params_list = [width, height, width_offset, height_offset]
        return params_list
コード例 #7
0
    def has_point(self, point):
        """
        Looks if the monitor contains the point
        """

        try:

            if self.hMonitor == win32api.MonitorFromPoint(point, MONITOR_DEFAULTTONEAREST):

                return True

            else:

                return False

        except win32api.error:
        
            logging.exception("Error while grabbing the monitor with point")

            return None
コード例 #8
0
    def is_main(self):
        """
        Looks if the monitor is the main monitor
        """

        try:

            if self.hMonitor == win32api.MonitorFromPoint((0, 0), MONITOR_DEFAULTTOPRIMARY):

                return True

            else:

                return False

        except win32api.error:
        
            logging.exception("Error while grabbing the monitor with point 0,0")

            return None
コード例 #9
0
ファイル: screens.py プロジェクト: peppy0510/PyWinLayout
def get_screens():

    screens = try_to_get_screens()

    for screen in screens:
        monitor_info = win32api.GetMonitorInfo(
            win32api.MonitorFromPoint((screen.offset.x, screen.offset.y)))

        monx, mony, monw, monh = monitor_info.get('Monitor')
        workx, worky, workw, workh = monitor_info.get('Work')

        if monw == workw and worky != mony:  # taskbar top
            screen.offset.y += worky - mony
        if monw == workw and worky == mony:  # taskbar bottom
            screen.finish.y -= monh - workh
        if monh == workh and workx != monx:  # taskbar left
            screen.offset.x += workx - monx
        if monh == workh and workx == monx:  # taskbar right
            screen.finish.x -= monw - workw

    return screens
コード例 #10
0
    def on_load_adp_btn_clicked(self):
        """
        加载adp按钮
        打开atpdraw,并调整窗口大小
        :return:
        """
        # 获取文件名
        file, n_1 = QFileDialog.getOpenFileName(self, "选取项目文件", '', 'ADP or ACP Files(*.adp *.acp)')
        # 没有选择文件
        if not file:
            return

        # 选择文件后,解析路径和文件名
        self.__adp_file = file
        self.__adp_path, self.__adp_file_name = os.path.split(file)
        self.__adp_file_name = os.path.splitext(self.__adp_file_name)[0]
        print("adpfile: path: %s, file name: %s" % (self.__adp_path, self.__adp_file_name))

        win32api.ShellExecute(0, 'open', file, '', '', 1)
        time.sleep(1)

        # 获取句柄
        self.handle_atpdraw = win32gui.FindWindow(None, u"ATPDraw")
        self.handle_myatp = win32gui.FindWindow(None, u"MainWindow")

        # 获得当前工作屏幕长宽
        work_area = win32api.GetMonitorInfo(win32api.MonitorFromPoint((0, 0))).get("Work")
        width = work_area[2]
        height = work_area[3]
        print("width =", width)
        print("height =", height)

        # 修改窗口大小
        win32gui.SetWindowPos(self.handle_atpdraw, None, 0, 0, width - 620, height,
                              win32con.SWP_NOSENDCHANGING | win32con.SWP_SHOWWINDOW)
        win32gui.SetWindowPos(self.handle_myatp, None, width - 620, 0, 620, height,
                              win32con.SWP_NOSENDCHANGING | win32con.SWP_SHOWWINDOW)

        # 更新一下atp
        self.on_atp_update_clicked()
コード例 #11
0
ファイル: winscreens.py プロジェクト: peppy0510/PyWinSecure
def get_screens():
    screens = sorted([
        Rectangle(v.x, v.y, v.x + v.width, v.y + v.height)
        for v in screeninfo.get_monitors()
    ],
                     key=operator.attrgetter('offset.x'))

    for screen in screens:
        monitor_info = win32api.GetMonitorInfo(
            win32api.MonitorFromPoint((screen.offset.x, screen.offset.y)))

        monx, mony, monw, monh = monitor_info.get('Monitor')
        workx, worky, workw, workh = monitor_info.get('Work')

        if monw == workw and worky != mony:  # taskbar top
            screen.offset.y += worky - mony
        if monw == workw and worky == mony:  # taskbar bottom
            screen.finish.y -= monh - workh
        if monh == workh and workx != monx:  # taskbar left
            screen.offset.x += workx - monx
        if monh == workh and workx == monx:  # taskbar right
            screen.finish.x -= monw - workw

    return screens
コード例 #12
0
def taskbar_information():
    monitor_info = win32api.GetMonitorInfo(win32api.MonitorFromPoint((0, 0)))
    monitor_area = monitor_info.get("Monitor")
    work_area = monitor_info.get("Work")
    return monitor_area[3] - work_area[3]
コード例 #13
0
    def __init__(self, tk_overlay, latest_version, changelog,
                 download_version):

        print("Update Prompt > Started")

        self.download_version = download_version
        self.latest_version = latest_version["version"]

        tk_overlay.generate_frames()
        tk_overlay.generate_title()

        self.tk_overlay = tk_overlay
        self.root = tk_overlay.root
        self.back_frame = tk_overlay.back_frame
        self.front_frame = tk_overlay.front_frame

        self.root.attributes("-alpha", 1)

        self.root.bind("<Key>", self.key_press)

        width, height = 450, 400
        monitor_info = win32api.GetMonitorInfo(
            win32api.MonitorFromPoint((0, 0)))
        work_area = monitor_info["Work"]

        self.root.minsize(width, height)
        self.root.geometry('%dx%d+%d+%d' %
                           (width, height, work_area[2] -
                            (width + 13), work_area[3] - (height + 36)))

        self.version_label = Label(self.front_frame,
                                   text=f"Version: {self.latest_version}",
                                   font=("Courier", 12),
                                   bg="#212121",
                                   fg="white")
        self.version_label.pack(side=TOP)

        self.date_label = Label(self.front_frame,
                                text=changelog["date"],
                                font=("Courier", 8),
                                bg="#212121",
                                fg="white")
        self.date_label.pack(side=TOP, pady=(0, 10))

        self.changelog_frame = Frame(self.front_frame, bg="#212121")
        self.changelog_frame.pack(side=TOP, pady=(0, 5))

        self.changelog_scrollbar_x = Scrollbar(self.changelog_frame,
                                               orient=HORIZONTAL)
        self.changelog_scrollbar_x.pack(side=BOTTOM, fill=X)
        self.changelog_scrollbar_y = Scrollbar(self.changelog_frame)
        self.changelog_scrollbar_y.pack(side=RIGHT, fill=Y)

        self.changelog_listbox = Listbox(
            self.changelog_frame,
            font=("Courier", 8),
            bg="#212121",
            fg="white",
            width=50,
            height=8,
            xscrollcommand=self.changelog_scrollbar_x.set,
            yscrollcommand=self.changelog_scrollbar_y.set,
            relief=FLAT)
        self.changelog_listbox.pack(side=TOP)

        self.changelog_scrollbar_x.config(command=self.changelog_listbox.xview)
        self.changelog_scrollbar_y.config(command=self.changelog_listbox.yview)

        for change in changelog["changes"]:
            self.changelog_listbox.insert(END, f"{change}\n")

        self.button_label = Label(
            self.front_frame,
            text=f"An update is available\nWould you like to install it?",
            font=("Courier", 16),
            bg="#212121",
            fg="white")
        self.button_label.pack(side=TOP, pady=10)

        self.divider_frame = Frame(self.front_frame,
                                   bg="white",
                                   width=120,
                                   height=1)
        self.divider_frame.pack(side=TOP, pady=(0, 10))

        self.button_frame = Label(self.front_frame, bg="#212121")
        self.button_frame.pack(side=TOP)

        self.generate_button("Update", self.update)
        self.generate_button("Cancel", self.destroy_root)

        self.root.after(1, self.root.focus_force)

        self.root.mainloop()
コード例 #14
0
 def _is_primary_display(self):
     primary_hwnd = win32api.MonitorFromPoint((0, 0), win32con.MONITOR_DEFAULTTOPRIMARY)
     return primary_hwnd == self.hwnd