Ignore:
Timestamp:
06/05/06 10:35:12 (18 years ago)
Author:
Nicholas Riley
Message:

StreamVision.py: cmd-ctrl-backslash zooms windows in most apps (yeah, this should be somewhere else, but this app was convenient)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/StreamVision/StreamVision.py

    r211 r232  
    22# -*- coding: utf-8 -*-
    33
    4 from appscript import app, k
     4from appscript import app, k, its, CommandError
    55from AppKit import NSApplication, NSBeep, NSSystemDefined, NSURL, NSWorkspace
    66from Foundation import NSDistributedNotificationCenter
    77from PyObjCTools import AppHelper
    88from Carbon.CarbonEvt import RegisterEventHotKey, GetApplicationEventTarget
    9 from Carbon.Events import cmdKey, shiftKey
     9from Carbon.Events import cmdKey, shiftKey, controlKey
    1010import struct
    1111import scrape
     
    140140            else:
    141141                XTensionApp().turnoff('Stereo')
     142               
     143    def zoomWindow(self):
     144        systemEvents = app(id='com.apple.systemEvents')
     145        frontName = systemEvents.processes.filter(its.frontmost)[1].name()
     146        if frontName is 'iTunes':
     147            systemEvents.processes['iTunes'].menu_bars[1]. \
     148                menu_bar_items['Window'].menus.menu_items['Zoom'].click()
     149            return
     150        try:
     151            zoomed = app(frontName).windows[1].zoomed
     152            zoomed.set(not zoomed())
     153        except CommandError:
     154            systemEvents.processes[frontName].windows. \
     155                filter(its.subrole == 'AXStandardWindow').windows[1]. \
     156                buttons.filter(its.subrole == 'AXZoomButton').buttons[1].click()
    142157
    143158    def finishLaunching(self):
     
    150165        self.registerHotKey(lambda: self.incrementRatingBy(-20), 109, shiftKey) # shift-F10
    151166        self.registerHotKey(lambda: self.incrementRatingBy(20), 103, shiftKey) # shift-F11
     167        self.registerHotKey(self.zoomWindow, 42, cmdKey | controlKey) # cmd-ctrl-\
    152168        NSDistributedNotificationCenter.defaultCenter().addObserver_selector_name_object_(self, self.displayTrackInfo, 'com.apple.iTunes.playerInfo', None)
    153169
Note: See TracChangeset for help on using the changeset viewer.