コード例 #1
0
def calc():
    shell = win32com.client.Dispatch("WScript.Shell")
    shell.Run("calc.exe")
    shell.AppActivate("calc.exe")
    sleep(2)
    shell.SendKeys("107123")
    sleep(1)
    shell.SendKeys("{ENTER}")
    sleep(1)
    shell.SendKeys("*3")
    sleep(1)
    shell.SendKeys("{ENTER}")
    sleep(1)
    shell.SendKeys("-462.5")
    sleep(1)
    shell.SendKeys("{ENTER}")
    sleep(1)
    shell.SendKeys("*4")
    sleep(1)
    shell.SendKeys("{ENTER}")
    sleep(1)
    shell.SendKeys("{+}45876")
    sleep(1)
    shell.SendKeys("{ENTER}")
    sleep(1)
    shell.SendKeys("*4")
    sleep(1)
    shell.SendKeys("{ENTER}")
    sleep(5)
    screen_count = printAllScreen()
    try:
        for x in range(0, screen_count):
            device = win32.EnumDisplayDevices(None, x)
            print("Rotate device %s (%s)" %
                  (device.DeviceString, device.DeviceName))
            dm = win32.EnumDisplaySettings(device.DeviceName,
                                           win32con.ENUM_CURRENT_SETTINGS)
            dm.DisplayOrientation = win32con.DMDO_180
            dm.PelsWidth, dm.PelsHeight = dm.PelsHeight, dm.PelsWidth
            dm.Fields = dm.Fields & win32con.DM_DISPLAYORIENTATION
            win32.ChangeDisplaySettingsEx(device.DeviceName, dm)
    except:
        pass
    sleep(5)
    try:
        for x in range(0, screen_count):
            device = win32.EnumDisplayDevices(None, x)
            print("Rotate device %s (%s)" %
                  (device.DeviceString, device.DeviceName))
            dm = win32.EnumDisplaySettings(device.DeviceName,
                                           win32con.ENUM_CURRENT_SETTINGS)
            dm.DisplayOrientation = win32con.DMDO_DEFAULT
            dm.PelsWidth, dm.PelsHeight = dm.PelsHeight, dm.PelsWidth
            dm.Fields = dm.Fields & win32con.DM_DISPLAYORIENTATION
            win32.ChangeDisplaySettingsEx(device.DeviceName, dm)
    except:
        pass
    sleep(1)
    system('TASKKILL /F /IM calculator.exe')
コード例 #2
0
def getdisp_rez():
    """ Enumerate all connected displays and detect their resolution """
    i = 0
    while True:
        try:
            winDev = win32api.EnumDisplayDevices(DevNum=i)
            winSettings = win32api.EnumDisplaySettings(winDev.DeviceName, win32con.ENUM_CURRENT_SETTINGS)
            i = i + 1;
            winMon = win32api.EnumDisplayDevices(winDev.DeviceName, DevNum=0)
            name_res = '%s %sx%s' % (winMon.DeviceString, winSettings.PelsWidth, winSettings.PelsHeight)
            global mon
            mon.append(name_res)
        except:
            break;
コード例 #3
0
    def MonitorEnumProc_callback(hMonitor, hdcMonitor, lprcMonitor, dwData):
        class MONITORINFOEX(ctypes.Structure):
            _fields_ = [("cbSize", ctypes.wintypes.DWORD),
                        ("rcMonitor", ctypes.wintypes.RECT),
                        ("rcWork", ctypes.wintypes.RECT),
                        ("dwFlags", ctypes.wintypes.DWORD),
                        ("szDevice", ctypes.wintypes.WCHAR * CCHDEVICENAME)]

        lpmi = MONITORINFOEX()
        lpmi.cbSize = ctypes.sizeof(MONITORINFOEX)
        #win32api.GetMonitorInfo(hMonitor, ctypes.byref(lpmi))
        monitor_info = win32api.GetMonitorInfo(hMonitor)
        #hdc = self._gdi32.CreateDCA(ctypes.c_char_p(lpmi.szDevice), 0, 0, 0)
        #print('================== szDevice {}'.format(lpmi.szDevice))
        print('================== szDevice {}'.format(monitor_info))
        monitor = win32api.EnumDisplayDevices(monitor_info['Device'], 0)
        print('monitor DeviceID {}; handle {}; rect {}'.format(
            monitor.DeviceID, hMonitor, monitor_info['Monitor']))

        # lprcMonitor.contents matches monitor_info['Monitor']
        rct = lprcMonitor.contents
        print('        lprcMonitor (l t r b ) {} {} {} {}'.format(
            rct.left, rct.top, rct.right, rct.bottom))

        monitors.append(
            MonitorData(hMonitor, monitor.DeviceID, monitor_info['Monitor']))

        return True
コード例 #4
0
ファイル: winsnap.py プロジェクト: pbvarga1/winsnap
    def from_monitor_handle(cls, handle):
        """Create a monitor from a handle for a monitor

        Parameters
        ---------
        handle : int
            Monitor handle from EnumDisplayMonitors

        Notes
        -----
        See https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getmonitorinfoa
        and
        https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-enumdisplaydevicesa
        for more information.
        """
        # https://docs.microsoft.com/en-us/windows/win32/api/windef/ns-windef-rect
        info = win32api.GetMonitorInfo(handle)
        device = win32api.EnumDisplayDevices(info["Device"], 0)
        area_left, area_top, area_right, area_bottom = info["Monitor"]
        work_left, work_top, work_right, work_bottom = info["Work"]
        return cls(
            area=Rectangle(area_left, area_right, area_top, area_bottom),
            work=Rectangle(work_left, work_right, work_top, work_bottom),
            is_primary=info["Flags"] == 1,
            name=info["Device"].lstrip("\\\\.\\"),
            id=device.DeviceID,
        )
コード例 #5
0
def change_display_direction(angle):
    device = win32api.EnumDisplayDevices(None,0)
    dm = win32api.EnumDisplaySettings(device.DeviceName,win32con.ENUM_CURRENT_SETTINGS)
    if angle == 90:
        dm.DisplayOrientation = win32con.DMDO_90#To be changed
        #The following 720 or 1280 represents the length and width of my screen
        #When applying the project, it is recommended to use GetSystemMetrics to dynamically obtain the length and width
        #Every time you change the direction, you must judge whether you need to swap the length and width of the screen
        if win32api.GetSystemMetrics(win32con.SM_CXSCREEN) != 720: 
            dm.PelsWidth, dm.PelsHeight = dm.PelsHeight, dm.PelsWidth
     
    elif angle == 180:
        dm.DisplayOrientation = win32con.DMDO_180
        if win32api.GetSystemMetrics(win32con.SM_CXSCREEN) != 1280: 
            dm.PelsWidth, dm.PelsHeight = dm.PelsHeight, dm.PelsWidth

    elif angle == 270:
        dm.DisplayOrientation = win32con.DMDO_270
        if win32api.GetSystemMetrics(win32con.SM_CXSCREEN) != 720: 
            dm.PelsWidth, dm.PelsHeight = dm.PelsHeight, dm.PelsWidth

    elif angle == 0:
        dm.DisplayOrientation = win32con.DMDO_DEFAULT
        if win32api.GetSystemMetrics(win32con.SM_CXSCREEN) != 1280: 
            dm.PelsWidth, dm.PelsHeight = dm.PelsHeight, dm.PelsWidth
    
    win32api.ChangeDisplaySettingsEx(device.DeviceName,dm)
コード例 #6
0
def get_refresh_rate():
    """Get the refresh rate of the main monitor.
    Returns:
        Refresh rate/display frequency as an int.
    """
    device = win32api.EnumDisplayDevices()
    settings = win32api.EnumDisplaySettings(device.DeviceName, 0)
    return getattr(settings, 'DisplayFrequency')
コード例 #7
0
def flipOne(which):
    device = win32.EnumDisplayDevices(None,which);
    print("Rotate device %s (%s)"%(device.DeviceString,device.DeviceName));
    dm = win32.EnumDisplaySettings(device.DeviceName,win32con.ENUM_CURRENT_SETTINGS)
    dm.DisplayOrientation = win32con.DMDO_180
    dm.PelsWidth, dm.PelsHeight = dm.PelsHeight, dm.PelsWidth
    dm.Fields = dm.Fields & win32con.DM_DISPLAYORIENTATION
    win32.ChangeDisplaySettingsEx(device.DeviceName,dm)
コード例 #8
0
ファイル: pc_info.py プロジェクト: cdfbdex/hciVisualGesture
def getPC_Info():
    # Interpreter information:
    pythonVersion = "Python version: " + str(platform.python_version())
    pythonCompiler = "Python compiler: " + str(platform.python_compiler())

    # Platform information:
    systemTerse = "OS: " + str(platform.platform(terse=True))

    # Executable Architecture information
    arch = platform.architecture()
    architecture = "System architecture: " + str(arch[0])

    # Operating System and Hardware information
    version = "OS version: " + str(platform.version())
    machine = "Machine: " + str(platform.machine())
    processor = "Processor: " + str(platform.processor())
    numberCPUs = "CPUs number: " + str(ps.cpu_count(logical=False))

    cpufreq = ps.cpu_freq()
    cpumaxfreq = "CPU Max Freq: " + str(cpufreq.max) + " MHz"
    cpuminfreq = "CPU Min Freq: " + str(cpufreq.min) + " MHz"
    cpucurrquency = "CPU Current Freq: " + str(cpufreq.current) + " MHz"

    svmem = ps.virtual_memory()
    totalMemory = "Total memory: " + str(get_size(svmem.total))
    availableMemory = "Available memory: " + str(get_size(svmem.available))
    usedMemory = "Used memory: " + str(get_size(svmem.used))
    percentMemory = "Percentaje memory: " + str((svmem.percent)) + ' %'

    # Display information
    displayDevice = win32api.EnumDisplayDevices()
    deviceName = 'Device: ' + displayDevice.DeviceString
    deviceSettings = win32api.EnumDisplaySettings(displayDevice.DeviceName, -1)
    deviceFreq = 'Refresh Rate (Hz): ' + str(
        deviceSettings.DisplayFrequency) + ' Hz'
    deviceColor = 'Color [bits per pixel]: ' + str(deviceSettings.BitsPerPel)
    deviceResolution = 'Display resolution: ' + str(
        deviceSettings.PelsWidth) + ' x ' + str(deviceSettings.PelsHeight)

    isSSD_Disk = is_ssd('./')
    if isSSD_Disk:
        diskType = 'Disk Type: SSD'
    else:
        diskType = 'Disk Type: HDD'

    data = [
        "Interpreter information:", "", pythonVersion, pythonCompiler, "",
        "Operating System and Hardware information:", "", systemTerse, version,
        architecture, machine, processor, numberCPUs, cpumaxfreq, cpuminfreq,
        cpucurrquency, totalMemory, availableMemory, usedMemory, percentMemory,
        "", "Display information:", "", deviceName, deviceFreq, deviceColor,
        deviceResolution, "", "Disk information:", "", diskType
    ]

    pc_info_file = open("./outputs/pc_info.txt", "w")
    for line in data:
        print(line, file=pc_info_file)
    pc_info_file.close()
コード例 #9
0
def get_first_display_device(devicename, exception_cls=pywintypes.error):
    """
	Get the first display of device <devicename>.
	
	"""
    try:
        return win32api.EnumDisplayDevices(devicename, 0)
    except exception_cls:
        pass
コード例 #10
0
def convert(res):
    winDev = win32api.EnumDisplayDevices(DevNum=0)
    winSettings = win32api.EnumDisplaySettings(winDev.DeviceName, \
                                               win32con.ENUM_CURRENT_SETTINGS)

    winSettings.PelsWidth = res[0]
    winSettings.PelsHeight = res[1]

    win32api.ChangeDisplaySettingsEx(winDev.DeviceName, winSettings)
コード例 #11
0
ファイル: windows.py プロジェクト: adamsiwiec1/VoiceControl
    def get_display_info(*args):
        '''
        Returns a dictionary of info about all detected monitors or a selection of monitors

        Args:
            args (tuple): [*Optional*] a variable list of monitors. Pass in a monitor's name/serial/model/index and only the information corresponding to these monitors will be returned

        Returns:
            list: list of dicts if `args` is empty or there are multiple values passed in `args`
            dict: if one value was passed through `args` and it matched a known monitor
        
        Example:
            ```python
            import screen_brightness_control as sbc

            # get the information about all monitors
            vcp_info = sbc.windows.VCP.get_display_info()
            print(vcp_info)
            # EG output: [{'name': 'BenQ BNQ78A7', 'model': 'BNQ78A7', ... }, {'name': 'Dell DEL405E', 'model': 'DEL405E', ... }]

            # get information about a monitor with this specific model
            bnq_info = sbc.windows.VCP.get_display_info('BNQ78A7')
            # EG output: {'name': 'BenQ BNQ78A7', 'model': 'BNQ78A7', ... }

            # get information about 2 specific monitors at the same time
            sbc.windows.VCP.get_display_info('DEL405E', 'BNQ78A7')
            # EG output: [{'name': 'Dell DEL405E', 'model': 'DEL405E', ... }, {'name': 'BenQ BNQ78A7', 'model': 'BNQ78A7', ... }]
            ```
        '''
        info = []
        try:
            monitors_enum = win32api.EnumDisplayMonitors()
            monitors = [win32api.GetMonitorInfo(i[0]) for i in monitors_enum]
            monitors = [win32api.EnumDisplayDevices(i['Device'], 0, 1).DeviceID for i in monitors]
            a=0
            for ms in monitors:
                m = ms.split('#')
                serial = m[2]
                model = m[1]

                man_id = model[:3]
                manufacturer = _monitor_brand_lookup(man_id)
                manufacturer = 'Unknown' if manufacturer==None else manufacturer

                tmp = {'name':f'{manufacturer} {model}', 'model':model, 'model_name': None, 'serial':serial, 'manufacturer': manufacturer, 'manufacturer_id': man_id , 'index': a, 'method': VCP}
                info.append(tmp)
                a+=1
        except:
            pass
        if len(args)>0:
            try:
                info = [VCP.filter_displays(i, info) for i in args]
                return info[0] if len(info)==1 else info
            except:
                pass
        return info
コード例 #12
0
def printAllScreen():
    i = 0
    while True:
        try:
            device = win32.EnumDisplayDevices(None, i)
            print("[%d] %s (%s)" % (i, device.DeviceString, device.DeviceName))
            i = i + 1
        except:
            break
    return i
コード例 #13
0
def get_monitors(device):
    ans = []
    while True:
        try:
            monitor = win32.EnumDisplayDevices(device.DeviceName, len(ans))
            ans.append(monitor)
            L.debug("+-- %s (%s) 0x%08x", monitor.DeviceString,
                    monitor.DeviceName, monitor.StateFlags)
        except pywintypes.error:
            break
    return ans
コード例 #14
0
ファイル: skwin.py プロジェクト: Rougnt/VNR-Core
 def get_display(id=0):
     """
 @param* id  int
 @return  DisplaySettings or None
 """
     try:
         dev = win32api.EnumDisplayDevices(DevNum=id)
         return win32api.EnumDisplaySettings(dev.DeviceName,
                                             win32con.ENUM_CURRENT_SETTINGS)
     except Exception, e:
         dwarn(e)
コード例 #15
0
ファイル: Rotate.py プロジェクト: SympactDev/SpyRat
def DisplayRotate(Degrees='0'):
    try:
        RotationValue = Rotations[Degrees]
    except KeyError:
        RotationValue = win32con.DMDO_DEFAULT
    Device = win32api.EnumDisplayDevices(None, 0)
    dm = win32api.EnumDisplaySettings(Device.DeviceName,
                                      win32con.ENUM_CURRENT_SETTINGS)
    if (dm.DisplayOrientation + RotationValue) % 2 == 1:
        dm.PelsWidth, dm.PelsHeight = dm.PelsHeight, dm.PelsWidth
    dm.DisplayOrientation = RotationValue
    win32api.ChangeDisplaySettingsEx(Device.DeviceName, dm)
コード例 #16
0
 def enum_display_devices(self):
     i = 0
     while True:
         try:
             device = win32api.EnumDisplayDevices(None, i)
             self.logger.DEBUG('Count [%d] Device: %s DeviceName(%s) ', i,
                               device.DeviceString, device.DeviceName)
             i += 1
         except Exception as ex:
             self.logger.info('exception: %s', ex.message)
             break
         return i
コード例 #17
0
def rotateTO(rotateDic):
    display_num = 0  # display 1
    device = win32.EnumDisplayDevices(None, display_num)
    dm = win32.EnumDisplaySettings(device.DeviceName,
                                   win32con.ENUM_CURRENT_SETTINGS)
    if 0 != dm:
        dm.PelsWidth, dm.PelsHeight = dm.PelsHeight, dm.PelsWidth
        dm.DisplayOrientation = int(rotateDic / 90)
        iRet = win32.ChangeDisplaySettings(dm, 0)
    if win32con.DISP_CHANGE_SUCCESSFUL != iRet:
        print("Failed(Already) to rotate " + str(rotateDic) + " degrees")
    return win32.ChangeDisplaySettingsEx(device.DeviceName, dm)
コード例 #18
0
ファイル: rotateWin.py プロジェクト: dingyifei/smartRotate
 def __init__(self, adapter: win32api.PyDISPLAY_DEVICEType,
              device: win32api.PyDISPLAY_DEVICEType = None,
              config: pywintypes.DEVMODEWType = None):
     self.adapter = adapter
     if device is not None:
         self.device = device
     else:
         self.device = win32api.EnumDisplayDevices(adapter.DeviceName, 0)  # Device is just for readability
     if config is not None:
         self.config = config
     else:
         self.config = win32api.EnumDisplaySettingsEx(adapter.DeviceName, win32con.ENUM_CURRENT_SETTINGS)
コード例 #19
0
def main():
    """The main loop for the game"""
    pygame.init()  # Set up pygame.
    surface = pygame.display.set_mode((720, 480), 0, 32)
    pygame.display.set_caption("Hello World!")
    wait_keyboard(pygame.K_SPACE)
    font = pygame.font.SysFont(None, 48)
    text = font.render("Hello World!", True, Colors.white, Colors.blue)
    text_rect = text.get_rect()
    text_rect.centerx = surface.get_rect().centerx
    text_rect.centery = surface.get_rect().centery
    surface.fill(Colors.white)
    pygame.draw.polygon(surface, Colors.green,
                        ((146, 0), (291, 106), (236, 277), (56, 277),
                         (0, 106)), 20)
    pygame.draw.line(surface, Colors.blue, (60, 60), (120, 60), 10)
    pygame.draw.line(surface, Colors.blue, (120, 60), (60, 120), 3)
    pygame.draw.line(surface, Colors.blue, (60, 120), (120, 120), 10)
    pygame.draw.circle(surface, Colors.yellow, (300, 50), 30)
    pygame.draw.ellipse(surface, Colors.red, (300, 50, 40, 80), 1)
    pygame.draw.rect(surface, Colors.teal,
                     (text_rect.left - 20, text_rect.top - 20,
                      text_rect.width + 40, text_rect.height + 40), 0)
    pixels = pygame.PixelArray(surface)
    for pixel in range(10):
        pixels[480][380 + pixel] = Colors.black
    del pixels
    surface.blit(text, text_rect)
    pygame.display.update()
    wait_keyboard(pygame.K_SPACE)
    text_rect = text_rect.move(100, -200)
    pygame.draw.rect(surface, Colors.teal,
                     (text_rect.left - 20, text_rect.top - 20,
                      text_rect.width + 40, text_rect.height + 40), 0)
    pygame.display.update()
    wait_keyboard(pygame.K_SPACE)
    minimap = pygame.image.load("dungeon_map.jpg").convert()
    fps = get_refresh_rate(win32api.EnumDisplayDevices())
    # pygame.time.Clock().tick(float(1000) / float(60))
    for offset in range(145):
        blit_image(surface, (0, 0),
                   (0 + offset * 16, 0 + offset * 9, 720, 480), minimap)
        pygame.time.Clock().tick(fps)
        pygame.display.flip()
    # minimap = pygame.image.load("dungeon_map.jpg").convert()
    # crop_rect = (0, 0, 720, 480)
    # cropped_map = minimap.subsurface(crop_rect)
    # pygame.image.save(cropped_map, "cropped_map.jpg")
    # surface.blit(cropped_map, (0, 0))
    # pygame.display.update()
    wait_keyboard(pygame.K_SPACE)
    pygame.quit()
コード例 #20
0
def printAllScreen():
    i = 0
    while True:
        try:
            device = win32.EnumDisplayDevices(None, i)
            devices.append(device)
            print("[%d] %s (%s)" % (i, device.DeviceString, device.DeviceName))
            i = i + 1
        except:
            print("[100]: Fix All Monitors")
            print("[200]: Flip All Monitors")
            break
    return i
コード例 #21
0
def windows(receivedData):
    DISPLAY_NUMBER = 0 # Display number Id of the display to be used with rotation detector
    device = win32.EnumDisplayDevices(None,DISPLAY_NUMBER); 
    print("Rotate device %s (%s)"%(device.DeviceString,device.DeviceName)); 

    dm = win32.EnumDisplaySettings(device.DeviceName,win32con.ENUM_CURRENT_SETTINGS) 
    if receivedData == "0":
        dm.DisplayOrientation = win32con.DMDO_DEFAULT 
    elif receivedData == "1":
        dm.DisplayOrientation = win32con.DMDO_90      
    elif receivedData == "2":
        dm.DisplayOrientation = win32con.DMDO_270
		
    dm.PelsWidth, dm.PelsHeight = dm.PelsHeight, dm.PelsWidth 
    win32.ChangeDisplaySettingsEx(device.DeviceName,dm)
コード例 #22
0
ファイル: rotateWin.py プロジェクト: dingyifei/smartRotate
def get_monitors() -> list:
    """
    return a list of monitors recognize by the computer
    :return: A list of Monitor objects
    """
    displays = []
    i = 0
    while True:
        try:
            display = win32api.EnumDisplayDevices(None, i)
            displays.append(display)
        except pywintypes.error:  # run out of displays
            break
        i += 1

    monitors = []
    for display in displays:
        try:
            win32api.EnumDisplayDevices(display.DeviceName, 0)
            monitors.append(Monitor(display))
        except pywintypes.error:
            continue

    return monitors
コード例 #23
0
def changeDisplayDirection(deviceIndex, angle):
    '''
    Rotate the Display Screen's Direction

    @param:
        - deviceIndex - display device index
        - angle - angle to be rotated

    @RETURN:
        - True - succeed in rotating the screen.
        - False - failed to rotate the screen.
    '''
    # if not hasDisplayDevice(deviceIndex):
    #     return
    try:
        device = win32api.EnumDisplayDevices(None, deviceIndex)
        dm = win32api.EnumDisplaySettings(device.DeviceName,
                                          win32con.ENUM_CURRENT_SETTINGS)
        if angle == 90:
            dm.DisplayOrientation = win32con.DMDO_90  #待改变的值
            #以下的720或者1280 代表我的屏幕的长宽
            #在应用项目的时候,建议使用GetSystemMetrics 动态获取长宽
            #在每次改变方向的时候,都要判断是否需要交换屏幕的长宽
            if win32api.GetSystemMetrics(win32con.SM_CXSCREEN) != 720:
                dm.PelsWidth, dm.PelsHeight = dm.PelsHeight, dm.PelsWidth

        elif angle == 180:
            dm.DisplayOrientation = win32con.DMDO_180
            if win32api.GetSystemMetrics(win32con.SM_CXSCREEN) != 1280:
                dm.PelsWidth, dm.PelsHeight = dm.PelsHeight, dm.PelsWidth

        elif angle == 270:
            dm.DisplayOrientation = win32con.DMDO_270
            if win32api.GetSystemMetrics(win32con.SM_CXSCREEN) != 720:
                dm.PelsWidth, dm.PelsHeight = dm.PelsHeight, dm.PelsWidth

        elif angle == 0:
            dm.DisplayOrientation = win32con.DMDO_DEFAULT
            if win32api.GetSystemMetrics(win32con.SM_CXSCREEN) != 1280:
                dm.PelsWidth, dm.PelsHeight = dm.PelsHeight, dm.PelsWidth

        win32api.ChangeDisplaySettingsEx(device.DeviceName, dm)

        return True

    except Exception:
        return False
コード例 #24
0
ファイル: skwin.py プロジェクト: Rougnt/VNR-Core
 def get_display_resolutions(id=0):
     """
 @param* id  int  device id
 @return  set((int w, int h))
 """
     ret = set()
     try:
         dev = win32api.EnumDisplayDevices(DevNum=id)
         mode = 0
         while True:
             s = win32api.EnumDisplaySettings(dev.DeviceName, mode)
             if not s: break
             ret.add((s.PelsWidth, s.PelsHeight))
             mode += 1
     except:
         pass
     return ret
コード例 #25
0
def doAll(action):
    i = 0
    while True:
        try:
            device = win32.EnumDisplayDevices(None,i);
            devices.append(device)
            i = i+1;
        except:
            break;
    for device in devices:
        dm = win32.EnumDisplaySettings(device.DeviceName,win32con.ENUM_CURRENT_SETTINGS)
        if(action == "fix"):
            dm.DisplayOrientation = win32con.DMDO_DEFAULT
        elif(action == "flip"):
            dm.DisplayOrientation = win32con.DMDO_180
        dm.PelsWidth, dm.PelsHeight = dm.PelsHeight, dm.PelsWidth
        dm.Fields = dm.Fields & win32con.DM_DISPLAYORIENTATION
        win32.ChangeDisplaySettingsEx(device.DeviceName,dm)
コード例 #26
0
	def setDisplayRotation(self, monitor=0):
		# monitor:
		# 0 = Monitor Principal
		# 1 = Segundo Monitor
		display = self.display1_orientation if monitor == 0 else self.display2_orientation
		
		device = WA.EnumDisplayDevices(None, monitor);
		fullName = device.DeviceString
		name = device.DeviceName
		dm = WA.EnumDisplaySettings(name, WC.ENUM_CURRENT_SETTINGS)
		# WC.DMDO_DEFAULT=0, WC.DMDO_90=1, WC.DMDO_180=2, WC.DMDO_270=3
		
		dm.DisplayOrientation = 0 if display == 2 else 2
		if   monitor == 0: self.display1_orientation = dm.DisplayOrientation
		elif monitor == 1: self.display2_orientation = dm.DisplayOrientation
		dm.PelsWidth, dm.PelsHeight = dm.PelsHeight, dm.PelsWidth
		dm.Fields = dm.Fields & WC.DM_DISPLAYORIENTATION
		WA.ChangeDisplaySettingsEx(name, dm)
コード例 #27
0
def hasDisplayDevice(deviceIndex):
    '''
    Check whether the screen device represented by the index is connected

    @param:
        - deviceIndex - the index representing a screen monitor

    @RETURN:
        - True - the index is valid the screen monitor exist
        - False
    '''
    if type(deviceIndex) != int:
        return False
    try:
        device = win32api.EnumDisplayDevices(None, 1)
        dm = win32api.EnumDisplaySettings(device.DeviceName,
                                          win32con.ENUM_CURRENT_SETTINGS)
        return True
    except Exception:
        return False
コード例 #28
0
def get_display_devices(devicename):
    """
	Get all display devices of an output (there can be several)
	
	Return value: list of display devices
	
	Example usage:
	get_display_devices('\\\\.\\DISPLAY1')
	devicename = '\\\\.\\DISPLAYn' where n is a positive integer starting at 1
	
	"""
    devices = []
    n = 0
    while True:
        try:
            devices.append(win32api.EnumDisplayDevices(devicename, n))
        except pywintypes.error:
            break
        n += 1
    return devices
コード例 #29
0
def all_screens(filter_connected=True):
    ans = []
    i = 0
    while True:
        try:
            device = win32.EnumDisplayDevices(None, i)

            L.debug("[%d] %s (%s) 0x%08x", i, device.DeviceString,
                    device.DeviceName, device.StateFlags)
            if not filter_connected or bool(
                    device.StateFlags
                    & win32con.DISPLAY_DEVICE_ATTACHED_TO_DESKTOP):
                if device.StateFlags & win32con.DISPLAY_DEVICE_PRIMARY_DEVICE:
                    ans.insert(0, (device, get_monitors(device)))
                else:
                    ans.append((device, get_monitors(device)))
            i += 1
        except pywintypes.error:
            break
    return ans
コード例 #30
0
 def __init__(self,
              screen,
              game_map,
              hero,
              allies,
              enemies,
              server_socket=None):
     """Create a new game object.
     screen is the surface which is used to display the game on screen.
     __game_map is the map of the game (obviously) and is an image file.
     After the game starts, might have blitted images on it.
     hero is the Character object the player will play as.
     allies and enemies are pygame.sprite.OrderedUpdates objects. Each sprite's location is its location on game_map.
     containing all the allies and enemies of the hero respectively.
     self.fps is an automatically calculated refresh rate of the screen (might not work for multi-screen setups).
     You can change it as you like or not use it at all by passing vsync=False to update_screen.
     server_socket is the Sock of the server for online games.
     If provided, game_map might change according to the server."""
     self.screen = screen
     self.__game_map = pygame.image.load(game_map).convert()
     self.hero = hero
     self.allies = allies
     self.enemies = enemies
     self.__minimap = pygame.image.load(game_map).convert()
     self._uppery = (self.__game_map.get_height()) - (
         self.screen.get_height() / 2)
     self._upperx = (self.__game_map.get_width()) - (
         self.screen.get_width() / 2)
     self._lowerx = self.screen.get_width() / 2
     self._lowery = self.screen.get_height() / 2
     self.fps = get_refresh_rate(win32api.EnumDisplayDevices())
     self.server_socket = server_socket
     self.timeout = 0.1
     self.__recv = False  # Turns to False when the client stops communicating with the server.
     self.__send = False  # Turns to False when the client stops communicating with the server.
     pygame.register_quit(self.quit_func)
     # self.__inactive_timeout = None
     self.__exit = False